|
@@ -90,9 +90,12 @@
|
|
|
<div class="col-md-12">
|
|
|
<table class="table table-bordered table-hover">
|
|
|
<thead id="tabHead">
|
|
|
- <tr><th>编号</th>
|
|
|
+ <tr>
|
|
|
+ <th>编号</th>
|
|
|
<th>用户</th>
|
|
|
- <th>操作</th></tr>
|
|
|
+ <th>语言</th>
|
|
|
+ <th>操作</th>
|
|
|
+ </tr>
|
|
|
</thead>
|
|
|
<tbody id="tabBody"></tbody>
|
|
|
</table>
|
|
@@ -139,7 +142,6 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<!--模态框end-->
|
|
|
- <!--<input type="checkbox" aria-label="Checkbox for following text input">-->
|
|
|
|
|
|
</section>
|
|
|
</div>
|
|
@@ -147,7 +149,7 @@
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
let index_data
|
|
|
- let user_data
|
|
|
+ let lang_data
|
|
|
$(function () {
|
|
|
let post_data = {
|
|
|
'token': $.cookie('access_token'),
|
|
@@ -168,14 +170,13 @@
|
|
|
http_ip_prot + 'langArea/query', JSON.stringify(post_data),
|
|
|
function (data) {
|
|
|
if (data['code'] == 0) {
|
|
|
- user_data = data['res']
|
|
|
- console.log(user_data)
|
|
|
+ lang_data = data['res']
|
|
|
+ console.log(lang_data)
|
|
|
} else {
|
|
|
alert(data['msg'])
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
-
|
|
|
});
|
|
|
|
|
|
function addTable(data) {
|
|
@@ -183,7 +184,12 @@
|
|
|
$.each(data, function (idx, obj) {
|
|
|
let edit_btn = '<a href="#" title="Edit" onclick="editFunc(\'' + obj['id'] + '\')"><i class="fa fa-edit"></i></a>';
|
|
|
let del_btn = '<a href="#" title="Delete" onclick="delArea(\'' + obj['id'] + '\')"><i class="fa fa-ban"></i></a>';
|
|
|
- body_html += '<tr><td>' + obj['id'] + '</td><td>' + obj['username'] + '</td><td>' + edit_btn + ' ' + del_btn + '</td></tr>'
|
|
|
+ let langArr_td = '<td>';
|
|
|
+ $.each(obj['lang_arr'], function (x, y) {
|
|
|
+ langArr_td += (y + '  ')
|
|
|
+ });
|
|
|
+ langArr_td += '</td>';
|
|
|
+ body_html += '<tr><td>' + obj['id'] + '</td><td>' + obj['username'] + '</td>' + langArr_td + '<td>' + edit_btn + ' ' + del_btn + '</td></tr>'
|
|
|
})
|
|
|
$('#tabBody').html(body_html)
|
|
|
}
|
|
@@ -232,53 +238,62 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function editFunc(lang_id) {
|
|
|
+ function editFunc(id) {
|
|
|
// alert(langKey)
|
|
|
console.log(index_data)
|
|
|
$('#modal-container-edit').modal('show')
|
|
|
- let html_edit = ''
|
|
|
+ let html_edit = '<label for="editDataInput" class="form-group">用户名:</label>'
|
|
|
+ let user_lang_arr
|
|
|
$.each(index_data, function (idx, obj) {
|
|
|
- if (lang_id == obj['id']) {
|
|
|
- html_edit = '<input type="text" class="form-control" id="editDataInput" value="' + obj['username'] + '" lid="' + lang_id + '">'
|
|
|
+ if (id == obj['id']) {
|
|
|
+ user_lang_arr = obj['lang_arr']
|
|
|
+ html_edit += '<input type="text" class="form-control" id="editDataInput" value="' + obj['username'] + '" lid="' + id + '">'
|
|
|
}
|
|
|
});
|
|
|
+ html_edit += '<hr><span class="form-group">显示语言:</span>';
|
|
|
+ $.each(lang_data, function (idx, obj) {
|
|
|
+ let checkbox_val=''
|
|
|
+ if(user_lang_arr){
|
|
|
+ let check_flag = $.inArray(obj['lang'],user_lang_arr)
|
|
|
+ console.log(check_flag)
|
|
|
+ if(check_flag>=0){
|
|
|
+ checkbox_val+='checked="checked"'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ html_edit += ('<label class="form-control"><input type="checkbox" '+checkbox_val+' aria-label="Checkbox for following text input" value="' + obj['id'] + '">' + obj['lang'] + '</label>')
|
|
|
+ })
|
|
|
+ console.log(user_lang_arr)
|
|
|
+
|
|
|
$('#edit_model_form').html(html_edit)
|
|
|
- return
|
|
|
- // let post_data = {'token': $.cookie('access_token')};
|
|
|
- // let html_per = '<label for="lang_key_edit">KEY</label><input class="form-control" type="text" id="lang_key_edit" oldkey="' + langKey + '" value="' + langKey + '"> '
|
|
|
- // $.each(la_list, function (idx, obj) {
|
|
|
- // console.log(obj);
|
|
|
- // html_per += ('<label for="InputLangArea">' + obj['lang'] + ':</label>' +
|
|
|
- // '<input type="text" class="form-control" lang="' + obj['lang'] + '" value="' + (lw_data[langKey][obj['lang']] ? lw_data[langKey][obj['lang']] : '') + '"/>')
|
|
|
- // });
|
|
|
- // // console.log(html_per)
|
|
|
- // $('#edit_model_form').html(html_per)
|
|
|
}
|
|
|
|
|
|
function editRow() {
|
|
|
- let lang_id = $('#editDataInput').attr('lid')
|
|
|
- let lang_area = $('#editDataInput').val()
|
|
|
- if (lang_id && lang_area) {
|
|
|
- let post_data = {
|
|
|
- 'token': $.cookie('access_token'),
|
|
|
- 'id': lang_id,
|
|
|
- 'lang': lang_area
|
|
|
- }
|
|
|
- $.postJSON(
|
|
|
- http_ip_prot + 'langArea/update', JSON.stringify(post_data),
|
|
|
- function (data) {
|
|
|
- if (data['code'] == 0) {
|
|
|
- console.log(data)
|
|
|
- // alert(data['msg'])
|
|
|
- window.location.reload()
|
|
|
- } else {
|
|
|
- alert(data['msg'])
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- } else {
|
|
|
- alert('none')
|
|
|
+ let sub_lang_arr = []
|
|
|
+ $.each($('input:checkbox:checked'), function () {
|
|
|
+ sub_lang_arr.push($(this).val())
|
|
|
+ });
|
|
|
+ console.log('--------')
|
|
|
+ console.log(sub_lang_arr)
|
|
|
+ console.log('--------')
|
|
|
+ let post_data = {
|
|
|
+ 'token': $.cookie('access_token'),
|
|
|
+ 'id': $('#editDataInput').attr('lid'),
|
|
|
+ 'username': $('#editDataInput').val(),
|
|
|
+ 'langSetArr': sub_lang_arr
|
|
|
}
|
|
|
+ console.log(post_data)
|
|
|
+ $.postJSON(
|
|
|
+ http_ip_prot + 'user/update', JSON.stringify(post_data),
|
|
|
+ function (data) {
|
|
|
+ if (data['code'] == 0) {
|
|
|
+ console.log(data)
|
|
|
+ // alert(data['msg'])
|
|
|
+ window.location.reload()
|
|
|
+ } else {
|
|
|
+ alert(data['msg'])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
function subRegAction() {
|