Browse Source

总分包,兼容总包标段,存在计量单元的情况

MaiXinRong 4 years ago
parent
commit
74f92da4f1
1 changed files with 13 additions and 6 deletions
  1. 13 6
      app/lib/sum_load.js

+ 13 - 6
app/lib/sum_load.js

@@ -40,7 +40,7 @@ class loadGclBaseTree {
         for (const child of parent.children) {
             const checkLeaf = (child.is_leaf && node.is_leaf) || (!child.is_leaf && !node.is_leaf);
             if (child.b_code === node.b_code && child.name === node.name && child.unit === node.unit
-                && checkLeaf && (!check || check(child, node))) {
+                && checkLeaf && !child.hasPos && (!check || check(child, node))) {
                 return child;
             }
         }
@@ -75,6 +75,7 @@ class loadGclBaseTree {
                 sjcl_qyt: 0,
                 quantity: 0,
                 is_leaf: source.is_leaf,
+                hasPos: false,
             };
             this.keyNodeId += 1;
             parent.children.push(node);
@@ -146,7 +147,7 @@ class updateReviseGclTree extends loadGclBaseTree {
         this.baseNodes = [];
         this.errors = [];
     }
-    loadBase(datas) {
+    loadBase(datas, pos) {
         datas.sort((x, y) => { return x.level === y.level ? x.order - y.order : x.level - y.level; });
         const Index = {};
         for (const d of datas) {
@@ -154,6 +155,7 @@ class updateReviseGclTree extends loadGclBaseTree {
             if (!parent) continue;
 
             if (!parent.children) parent.children = [];
+            const relaPos = pos.filter(x => {return x.lid === d.id});
             const baseNode = {
                 id: d.id,
                 ledger_id: d.ledger_id,
@@ -174,6 +176,7 @@ class updateReviseGclTree extends loadGclBaseTree {
                 sjcl_qty: 0,
                 qtcl_qty: 0,
                 quantity: 0,
+                hasPos: relaPos.length > 0,
             };
             parent.children.push(baseNode);
             Index[baseNode.ledger_id] = baseNode;
@@ -226,7 +229,7 @@ class gatherStageGclTree extends loadGclBaseTree {
         super(ctx, setting);
         this.baseNodes = [];
     }
-    loadBase(datas) {
+    loadBase(datas, pos) {
         datas.sort((x, y) => { return x.level === y.level ? x.order - y.order : x.level - y.level; });
         const Index = {};
         for (const d of datas) {
@@ -234,6 +237,7 @@ class gatherStageGclTree extends loadGclBaseTree {
             if (!parent) continue;
 
             if (!parent.children) parent.children = [];
+            const relaPos = pos.filter(x => {return x.lid === d.id});
             const baseNode = {
                 id: d.id,
                 ledger_id: d.ledger_id,
@@ -251,6 +255,7 @@ class gatherStageGclTree extends loadGclBaseTree {
                 contract_qty: 0,
                 contract_tp: 0,
                 is_tp: d.is_tp,
+                hasPos: relaPos.length > 0,
             };
             parent.children.push(baseNode);
             Index[baseNode.ledger_id] = baseNode;
@@ -274,7 +279,7 @@ class gatherStageGclTree extends loadGclBaseTree {
     gather(source, parent) {
         parent = parent ? parent : this.parent;
         const node = this.addNode(source, parent, function (node, source) {
-            return (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
+            return  (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
         });
         if (node.is_tp) {
             node.contract_tp = this.ctx.helper.add(node.contract_tp, source.contract_tp);
@@ -360,7 +365,8 @@ class sumLoad {
             parent: select, maxId, type: 'ledger', defaultData,
         });
         const posterity = await this.ctx.service.reviseBills.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
-        this.loadTree.loadBase(posterity);
+        const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
+        this.loadTree.loadBase(posterity, pos);
 
         for (const tender of tenders) {
             const billsData = await this.ctx.service.ledger.getData(tender.tid);
@@ -415,7 +421,8 @@ class sumLoad {
             parent: select, maxId, type: 'ledger', defaultData,
         });
         const posterity = await this.ctx.service.ledger.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
-        this.loadTree.loadBase(posterity);
+        const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
+        this.loadTree.loadBase(posterity, pos);
 
         for (const tender of tenders) {
             if (!tender.stage) continue;