瀏覽代碼

lib_detail.js no.2 up

laiguoran 7 年之前
父節點
當前提交
975c6b7c4f
共有 2 個文件被更改,包括 16 次插入12 次删除
  1. 1 1
      app/controller/lib_controller.js
  2. 15 11
      app/public/js/lib_detail.js

+ 1 - 1
app/controller/lib_controller.js

@@ -214,7 +214,7 @@ module.exports = app => {
                 if (isNaN(id) || id <= 0) {
                     throw '参数错误';
                 }
-                if(text === undefined || text !== '确认删除'){
+                if(text === undefined || text.trim() !== '确认删除'){
                     throw '参数错误';
                 }
                 //获取指标源数据

+ 15 - 11
app/public/js/lib_detail.js

@@ -65,17 +65,7 @@ $(document).ready(function() {
                 bills_id: billsInfo.id
             };
             postData(postUrl, postInfo, function (result) {
-                let index_html = '';
-                const index_list = result.indexList;
-                for(let i in index_list) {
-                    index_html += '<tr> <td>'+ index_list[i].code +'</td> <td>'+ index_list[i].name +'</td>' +
-                        '<td>'+ (index_list[i].unit1 !== null ? index_list[i].unit1 : '') +'</td>' +
-                        '<td>'+ (index_list[i].unit2 !== null ? index_list[i].unit2 : '') +'</td>' +
-                        '<td>'+ index_list[i].rule +'</td> <td>'+ (index_list[i].eval_rule !== null ? index_list[i].eval_rule : '') +'</td>' +
-                        '<td>'+ (index_list[i].value !== null ? index_list[i].value : '') +'</td> </tr>';
-                }
-                $('#indexList').html(index_html);
-
+                updateIndexHTML(result.indexList);
                 let param_html = '';
                 const param_list = result.paramList;
                 for(let i in param_list) {
@@ -90,6 +80,19 @@ $(document).ready(function() {
             });
         }
     }
+    
+    function updateIndexHTML(indexlist) {
+        let index_html = '';
+        const index_list = indexlist;
+        for(let i in index_list) {
+            index_html += '<tr> <td>'+ index_list[i].code +'</td> <td>'+ index_list[i].name +'</td>' +
+                '<td>'+ (index_list[i].unit1 !== null ? index_list[i].unit1 : '') +'</td>' +
+                '<td>'+ (index_list[i].unit2 !== null ? index_list[i].unit2 : '') +'</td>' +
+                '<td>'+ index_list[i].rule +'</td> <td>'+ (index_list[i].eval_rule !== null ? index_list[i].eval_rule : '') +'</td>' +
+                '<td>'+ (index_list[i].value !== null ? index_list[i].value : '') +'</td> </tr>';
+        }
+        $('#indexList').html(index_html);
+    }
 
     $('body').on('blur', '#paramList input', function () {
         const self = $(this);
@@ -104,6 +107,7 @@ $(document).ready(function() {
             const postUrl = '/lib/updateParamValue';
             postData(postUrl, postInfo, function (result) {
                 self.attr('data-old-value', result.param.calc_value);
+                updateIndexHTML(result.indexes);
             },function (result) {
                 self.val(self.attr('data-old-value'));
             });