Browse Source

台账修订,总分包更新相关

MaiXinRong 5 months ago
parent
commit
903a199cf3
2 changed files with 29 additions and 9 deletions
  1. 28 8
      app/lib/sum_load.js
  2. 1 1
      app/view/tender/detail_modal.ejs

+ 28 - 8
app/lib/sum_load.js

@@ -55,6 +55,24 @@ class loadGclBaseTree {
         return null;
     }
 
+    findBCodeNode(b_code, mustParent) {
+        for (const bn of this.baseNodes) {
+            if (bn.b_code === b_code && (!mustParent || !bn.is_leaf)) return bn;
+        }
+        for (const i of this.items) {
+            if (i.b_code === b_code && (!mustParent || !i.is_leaf)) return i;
+        }
+        return null;
+    }
+    findBCodeParent(b_code) {
+        const codeArr = b_code.split('-');
+        if (codeArr.length === 1) return null;
+        codeArr.length = codeArr.length - 1;
+        const parentCode = codeArr.join('-');
+        const result = this.findBCodeNode(parentCode, true);
+        return result || this.findBCodeParent(parentCode);
+    }
+
     /**
      * 添加 树节点 并完善该节点的树结构
      * @param {Object} node - 添加节点
@@ -108,14 +126,15 @@ class loadGclBaseTree {
     addNodeWithoutParent(source, check) {
         let node = this.findLeaf(source, check);
         if (!node) {
+            const parent = this.findBCodeParent(source.b_code) || this.parent;
             node = {
                 id: this.ctx.app.uuid.v4(),
                 tender_id: this.ctx.tender.id,
                 ledger_id: this.keyNodeId,
-                ledger_pid: this.parent.ledger_id,
-                level: this.parent.level + 1,
-                full_path: this.parent.full_path + '-' + this.keyNodeId,
-                order: this.parent.children.length + 1,
+                ledger_pid: parent.ledger_id,
+                level: parent.level + 1,
+                full_path: parent.full_path + '-' + this.keyNodeId,
+                order: parent.children.length + 1,
                 b_code: source.b_code,
                 name: source.name,
                 unit: source.unit,
@@ -128,7 +147,7 @@ class loadGclBaseTree {
                 hasPos: false,
             };
             this.keyNodeId += 1;
-            this.parent.children.push(node);
+            parent.children.push(node);
             this.items.push(node);
         }
         return node;
@@ -254,7 +273,7 @@ class updateReviseGclTree extends loadGclBaseTree {
         }
     }
     gather(source, parent) {
-        const node = this.addNode(source, parent);
+        const node =  this.ignoreParent ? this.addNodeWithoutParent(source) : this.addNode(source, parent);
         node.deal_qty = this.ctx.helper.add(node.deal_qty, source.deal_qty);
         node.sgfh_qty = this.ctx.helper.add(node.sgfh_qty, source.sgfh_qty);
         node.qtcl_qty = this.ctx.helper.add(node.qtcl_qty, source.qtcl_qty);
@@ -494,8 +513,9 @@ class sumLoad {
     }
 
     async updateGatherGcl(select, maxId, tenders, defaultData) {
+        const ignoreParent = this.ctx.tender.info.fun_rela.sum_load.ignoreParent;
         this.loadTree = new updateReviseGclTree(this.ctx, {
-            parent: select, maxId, type: 'ledger', defaultData,
+            parent: select, maxId, type: 'ledger', defaultData, ignoreParent,
         });
         const posterity = await this.ctx.service.reviseBills.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
         const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
@@ -518,7 +538,7 @@ class sumLoad {
             });
             for (const top of billsTree.children) {
                 if ([1].indexOf(top.node_type) < 0) continue;
-                this.recusiveLoadGatherGcl(top, null);
+                this.recusiveLoadGatherGcl(top, null, ignoreParent);
             }
         }
         this.loadTree.resortByCode();

+ 1 - 1
app/view/tender/detail_modal.ejs

@@ -2065,7 +2065,7 @@
                     <div class="form-group">
                         <div class="custom-control custom-checkbox mb-2">
                             <input type="checkbox" class="custom-control-input" id="sl_ignoreParent" checked="">
-                            <label class="custom-control-label" for="sl_ignoreParent">计量台账-导入其他标段数据-忽略父项</label>
+                            <label class="custom-control-label" for="sl_ignoreParent">更新/导入其他标段数据-忽略父项</label>
                         </div>
                     </div>
                     <div class="form-group">