chenjunkai il y a 5 ans
Parent
commit
6bb6b0d5bd
1 fichiers modifiés avec 53 ajouts et 40 suppressions
  1. 53 40
      web/index.html

+ 53 - 40
web/index.html

@@ -208,13 +208,19 @@
         if (!page) {
             page = 1
         }
+        let searchKey = $('input[name="optionsRadios"]:checked').val();
+        let searchVal = $('#searchInput').val()
+
         let post_data = {
             'token': $.cookie('access_token'),
             'page': page,
             'line': line,
-            'orderByupdate': orderByupdate
+            'orderByupdate': orderByupdate,
+                     'searchKey': searchKey?searchKey:"key",
+
+            'searchVal': searchVal
         };
-        InitIndex(post_data)
+        InitIndex(post_data,1)
         // $('#pagination').pagination({
         //     pages: 50, //总页数
         //     edges: 2,
@@ -241,23 +247,43 @@
         if (!page) {
             page = 1
         }
+        let searchKey = $('input[name="optionsRadios"]:checked').val();
+        let searchVal = $('#searchInput').val()
         let post_data = {
             'token': $.cookie('access_token'),
             'page': page,
             'line': 10,
-            'orderByupdate': orderByupdate
+            'orderByupdate': orderByupdate,
+                            'searchKey': searchKey?searchKey:"key",
+
+
+            'searchVal': searchVal
         };
-        InitIndex(post_data)
+        InitIndex(post_data,1)
     }
 
-    function InitIndex(post_data) {
+    function InitSearchTab(data) {
+        let head_data = data['la_list'];
+        // body部详细语言
+        let search_tab = '<label><input type="radio" name="optionsRadios" value="key" checked>key</label>'
+        //头部标签添加
+        $.each(head_data.reverse(), function (idx, obj) {
+            search_tab += '&nbsp;&nbsp;&nbsp;<label><input type="radio" name="optionsRadios" value="' + obj['lang'] + '">' + obj['lang'] + '</label>'
+        });
+        $('#searchCheckBox').html(search_tab)
+    }
 
+    function InitIndex(post_data,type) {
+        console.log(post_data)
         $.postJSON(
             http_ip_prot + 'langWord/query', JSON.stringify(post_data),
             function (data) {
                 if (data['code'] == 0) {
                     // console.log(data['res'])
                     console.log(data)
+                    if(type==1) {
+                        InitSearchTab(data['res'])
+                    }
                     addTable(data['res'])
                     let count_page = Math.ceil(data['res']['count'] / line)
                     $('#pagination').pagination({
@@ -287,9 +313,6 @@
             http_ip_prot + 'user/init', JSON.stringify(post_data),
             function (data) {
                 if (data['code'] == 0) {
-                    console.log('initData__start')
-                    console.log(data)
-                    console.log('initData__end')
                     initData = data['res']
                 } else {
                     window.location.href = "http://" + domain + ":7724/web/login.html";
@@ -312,7 +335,7 @@
                 'page': page,
                 'line': 10,
                 'orderByupdate': orderByupdate,
-                'searchKey': searchKey,
+                'searchKey': searchKey?searchKey:"key",
                 'searchVal': searchVal
             };
         } else {
@@ -320,11 +343,15 @@
                 'token': $.cookie('access_token'),
                 'page': page,
                 'line': 10,
-                'orderByupdate': orderByupdate
+                'orderByupdate': orderByupdate,
+                'searchKey': searchKey?searchKey:"key",
+                'searchVal': searchVal
             };
         }
 
-
+        console.log('----')
+        console.log(post_data)
+        console.log('====')
         $.postJSON(
             http_ip_prot + 'langWord/query', JSON.stringify(post_data),
             function (data) {
@@ -347,33 +374,19 @@
         let body_data = data['lw_dict'];
         lw_data = body_data
         let head_html = '<tr><th width="180px"><a href="javascript:void(0);" onclick="addRow()">add</a></th><th>key</th>';
-        let search_tab = '<label><input type="radio" name="optionsRadios" value="key" checked>key</label>'
-
         //头部标签添加
-
         $.each(head_data.reverse(), function (idx, obj) {
             // console.log(idx)
             head_html += ('<th>' + obj['lang'] + '</th>')
-            search_tab += '&nbsp;&nbsp;&nbsp;<label><input type="radio" name="optionsRadios" value="' + obj['lang'] + '">' + obj['lang'] + '</label>'
         });
-        // head_html += '<th>udpateTime &nbsp;<i class="fa fa-arrow-down" aria-hidden="true"></i></td><th width="180px"><a href="#" onclick="addRow()">add</a></th></tr>';
         head_html += ('<th><a href="javascript:void(0);" onclick="orderByUpdateTimeFunc(' + orderByupdate + ')">udpateTime &nbsp;<i class="fa ' + (orderByupdate == 1 ? 'fa-arrow-up' : 'fa-arrow-down') + '" aria-hidden="true"></i></a></td></tr>');
-        // search_tab += '<td width="180px"><button class="btn-primary btn">搜索</button></td></tr>';
-        $('#searchCheckBox').html(search_tab)
         let body_html = '';
-
-        console.log('--------');
         $.each(body_data, function (idx, obj) {
-            // console.log(idx)
-            console.log(obj)
-            //let edit_btn = '<a href="javascript:void(0);" title="Edit" onclick="editFunc(\'' + idx + '\')"><i class="fa fa-edit"></i></a>';
-            //let del_btn = '<a href="javascript:void(0);" title="Delete" onclick="deleteFunc(\'' + idx + '\')"><i class="fa fa-ban"></i></a>';
             let edit_btn = '<a href="javascript:void(0);" title="Edit" onclick="editFunc(this)"><i class="fa fa-edit"></i></a>';
             let del_btn = '<a href="javascript:void(0);" title="Delete" onclick="deleteFunc(this)"><i class="fa fa-ban"></i></a>';
             // let del_btn = '';
             body_html += '<tr><td>' + edit_btn + '&nbsp;&nbsp;&nbsp;' + del_btn + '</td>';
             body_html += ('<td>' + idx + '</td>');
-
             $.each(la_list, function (x, y) {
                 if (obj[y['lang']]) {
                     body_html += ('<td>' + obj[y['lang']] + '</td>')
@@ -384,7 +397,6 @@
             let updTime = $.DateChange.UnixToDate(obj['updTime'], true, 8);
             body_html += ('<td>' + updTime + '<span class="arrow dsc"></td></tr>');
         });
-
         $('#langTableHead').empty().html(head_html);
         $('#langTableBody').empty().html(body_html);
         addDelFunc()
@@ -460,7 +472,7 @@
         let user_perm = initData['user_perm']
         console.log(initData)
         // let post_data = {'token': $.cookie('access_token')};
-        let html_per = '<label for="lang_key_edit">KEY</label><input class="form-control" '+(user_perm==1?'':'disabled="disabled"')+' type="text" id="lang_key_edit" oldkey="' + langKey + '" value="' + langKey + '"> '
+        let html_per = '<label for="lang_key_edit">KEY</label><input class="form-control" ' + (user_perm == 1 ? '' : 'disabled="disabled"') + ' type="text" id="lang_key_edit" oldkey="' + langKey + '" value="' + langKey + '"> '
         $.each(la_list, function (idx, obj) {
             let lang_perm_ls = initData['lang_perm_ls']
             let check_perm_flag = $.inArray(obj['lang'], lang_perm_ls)
@@ -471,7 +483,7 @@
             }
             //console.log(obj);
             html_per += ('<label for="InputLangArea">' + obj['lang'] + ':</label>' +
-                '<textarea type="text" ' + inputAttr + ' class="form-control disabled" lang="' + obj['lang'] + '">'+(lw_data[langKey][obj['lang']] ? lw_data[langKey][obj['lang']] : '')+'</textarea>')
+                '<textarea type="text" ' + inputAttr + ' class="form-control disabled" lang="' + obj['lang'] + '">' + (lw_data[langKey][obj['lang']] ? lw_data[langKey][obj['lang']] : '') + '</textarea>')
             //html_per += ('<label for="InputLangArea">' + obj['lang'] + ':</label>' +
             //    '<input type="text" ' + inputAttr + ' class="form-control disabled" lang="' + obj['lang'] + '" value="' + (lw_data[langKey][obj['lang']] ? lw_data[langKey][obj['lang']] : '') + '"/>')
         });
@@ -520,11 +532,11 @@
         post_data['word_key'] = $('#lang_key_edit').val()
         post_data['old_word_key'] = $('#lang_key_edit').attr('oldkey')
         post_data['word_arr'] = {}
-       // $('#edit_model_form').find('input').each(function () {
-         //   let langArea = $(this).attr('lang')
-           // if (langArea) {
-             //   post_data['word_arr'][langArea] = $(this).val()
-            //}
+        // $('#edit_model_form').find('input').each(function () {
+        //   let langArea = $(this).attr('lang')
+        // if (langArea) {
+        //   post_data['word_arr'][langArea] = $(this).val()
+        //}
         //})
         $('#edit_model_form').find('textarea').each(function () {
             let langArea = $(this).attr('lang')
@@ -558,11 +570,16 @@
         if (!page) {
             page = 1
         }
+        let searchKey = $('input[name="optionsRadios"]:checked').val();
+        let searchVal = $('#searchInput').val()
         let post_data = {
             'token': $.cookie('access_token'),
             'page': page,
             'line': line,
-            'orderByupdate': orderByupdate
+            'orderByupdate': orderByupdate,
+                            'searchKey': searchKey?searchKey:"key",
+
+            'searchVal': searchVal
         };
         $.postJSON(
             http_ip_prot + 'langWord/query', JSON.stringify(post_data),
@@ -587,17 +604,13 @@
         }
         let searchKey = $('input[name="optionsRadios"]:checked').val();
         let searchVal = $('#searchInput').val()
-        console.log('-------------------------------')
-        console.log(searchKey)
-        console.log(searchVal)
-        console.log('-------------------------------')
         let post_data = {}
         if (searchVal && searchKey) {
             post_data = {
                 'token': $.cookie('access_token'),
                 'page': page,
                 'line': 10,
-                'searchKey': searchKey,
+                'searchKey': searchKey ? searchKey : "key",
                 'searchVal': searchVal
             };
         } else {
@@ -607,7 +620,7 @@
                 'line': 10,
             };
         }
-        InitIndex(post_data)
+        InitIndex(post_data,2)
     }
 </script>
 </body>