MaiXinRong 3 лет назад
Родитель
Сommit
49e71b314a

+ 1 - 1
app/const/tender_info.js

@@ -163,7 +163,7 @@ const defaultInfo = {
     },
     fun_rela: {
         sum_load: {
-            ignoreParent: 1,
+            ignoreParent: false,
         }
     }
 };

+ 2 - 2
app/controller/tender_controller.js

@@ -636,12 +636,12 @@ module.exports = app => {
         async saveTenderInfo2(ctx) {
             try {
                 const data = JSON.parse(ctx.request.body.data);
-                if (!data || !data.ledger_check) throw '提交数据错误';
+                if (!data || (!data.ledger_check && !data.fun_rela)) throw '提交数据错误';
                 if (!ctx.session.sessionUser.is_admin) throw '您无权修改该内容';
 
                 const updateData = {};
                 if (data.ledger_check) updateData.ledger_check = data.ledger_check;
-                if (data.sum_load) updateData.sum_load = data.sum_load;
+                if (data.fun_rela) updateData.fun_rela = data.fun_rela;
                 await ctx.service.tenderInfo.saveTenderInfo(ctx.tender.id, data);
 
                 ctx.body = { err: 0, msg: '', data: JSON.parse(ctx.request.body.data) };

+ 10 - 7
app/lib/sum_load.js

@@ -26,6 +26,8 @@ class loadGclBaseTree {
         // this.parent下原来的节点
         this.baseNodes = [];
 
+        this.ignoreParent = setting.ignoreParent;
+
         // 缓存
         this.keyNodeId = setting.maxId ? setting.maxId + 1 : 1;
     }
@@ -120,7 +122,7 @@ class loadGclBaseTree {
                 quantity: 0,
                 is_leaf: source.is_leaf,
                 hasPos: false,
-            }
+            };
             this.keyNodeId += 1;
             this.parent.children.push(node);
             this.items.push(node);
@@ -329,9 +331,10 @@ class gatherStageGclTree extends loadGclBaseTree {
     }
     gather(source, parent) {
         parent = parent ? parent : this.parent;
-        const node = this.addNode(source, parent, function (node, source) {
+        const checkFun = function (node, source) {
             return  (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
-        });
+        };
+        const node = this.ignoreParent ? this.addNodeWithoutParent(source, checkFun) : this.addNode(source, parent, checkFun);
         if (node.is_tp) {
             node.contract_tp = this.ctx.helper.add(node.contract_tp, source.contract_tp);
         } else {
@@ -377,12 +380,12 @@ class sumLoad {
         this.ctx = ctx;
     }
 
-    recusiveLoadGatherGcl(node, parent, ignoreParent) {
+    recusiveLoadGatherGcl(node, parent, ignoreParent = false) {
         const isLeaf = !node.children || node.children.length === 0;
-        const cur = (!ignoreParent || isLeaf) &&  node.b_code ? this.loadTree.gather(node, parent) : parent;
+        const cur = (!ignoreParent || isLeaf) && node.b_code ? this.loadTree.gather(node, parent) : parent;
         if (isLeaf) return;
         for (const child of node.children) {
-            this.recusiveLoadGatherGcl(child, cur);
+            this.recusiveLoadGatherGcl(child, cur, ignoreParent);
         }
     }
 
@@ -469,7 +472,7 @@ class sumLoad {
     }
 
     async stageGatherGcl(select, maxId, tenders, defaultData) {
-        const ignoreParent = this.ctx.tender.info.fun_rela.ignoreParent;
+        const ignoreParent = this.ctx.tender.info.fun_rela.sum_load.ignoreParent;
         this.loadTree = new gatherStageGclTree(this.ctx, {
             parent: select, maxId, type: 'ledger', defaultData, ignoreParent,
         });

+ 6 - 4
app/view/tender/detail_modal.ejs

@@ -1827,7 +1827,7 @@
     }
 
     const loadFunRelaProperty = function () {
-        // $('#lc_same_code')[0].checked = property.sum_load.ignoreParent;
+        $('#sl_ignoreParent')[0].checked = property.fun_rela.sum_load.ignoreParent;
     };
 
     $('#bd-set-12').on('show.bs.modal', function () {
@@ -1835,13 +1835,15 @@
     });
     function post12 () {
         const prop = {
-            sum_load: {
-                ignoreParent: $('#sl_ignoreParent')[0].checked,
+            fun_rela: {
+                sum_load: {
+                    ignoreParent: $('#sl_ignoreParent')[0].checked,
+                }
             },
         };
         const tenderId = window.location.pathname.split('/')[2];
         postData('/tender/' + tenderId + '/save2', prop, function (data) {
-            property.sum_load = data.sum_load;
+            property.fun_rela = data.fun_rela;
             $('#bd-set-12').modal('hide');
         });
     }