소스 검색

中间计量,计算式说明

MaiXinRong 5 년 전
부모
커밋
1891de2876
2개의 변경된 파일57개의 추가작업 그리고 45개의 파일을 삭제
  1. 33 27
      app/lib/stage_im.js
  2. 24 18
      app/public/js/stage_im.js

+ 33 - 27
app/lib/stage_im.js

@@ -303,37 +303,43 @@ class StageIm {
             lp.qc_jl = this.ctx.helper.add(lp.qc_jl, p.qc_qty);
         }
     }
+    _recursiveGenerateTzGclBills(node, im) {
+        for (const p of node.children) {
+            if (p.children && p.children.length > 0) {
+                this._recursiveGenerateTzGclBills(p, im);
+            } else {
+                if ((!p.b_code || p.b_code === '') || (p.children && p.children.length > 0)) {
+                    continue;
+                }
+                if ((!p.contract_tp || p.contract_tp === 0) && (!p.qc_tp || p.qc_tp === 0)) {
+                    continue;
+                }
+                let b = this._.find(im.gclBills, {bid: p.id});
+                if (!b) {
+                    b = {imid: im.id, bid: p.id, b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price};
+                    im.gclBills.push(b);
+                    this.ImBillsData.push(b);
+                }
+                b.jl = this.ctx.helper.add(b.jl, p.gather_qty);
+                b.contract_jl = this.ctx.helper.add(b.contract_jl, p.contract_qty);
+                b.qc_jl = this.ctx.helper.add(b.qc_jl, p.qc_qty);
+
+                b.pre_jl = this.ctx.helper.add(b.pre_jl, p.pre_gather_qty);
+                b.pre_contract_jl = this.ctx.helper.add(b.pre_contract_jl, p.pre_contract_qty);
+                b.pre_qc_jl = this.ctx.helper.add(b.pre_qc_jl, p.pre_qc_qty);
+
+                b.end_jl = this.ctx.helper.add(b.end_jl, p.end_gather_qty);
+                b.end_contract_jl = this.ctx.helper.add(b.end_contract_jl, p.end_contract_qty);
+                b.end_qc_jl = this.ctx.helper.add(b.end_qc_jl, p.end_qc_qty);
+                this._generateTzPosData(p, b);
+            }
+        }
+    }
     _generateTzGclBillsData(node, im) {
         if (!im.gclBills) {
             im.gclBills = [];
         }
-        const posterity = this.billsTree.getPosterity(node);
-        for (const p of posterity) {
-            if ((!p.b_code || p.b_code === '') || (p.children && p.children.length > 0)) {
-                continue;
-            }
-            if ((!p.contract_tp || p.contract_tp === 0) && (!p.qc_tp || p.qc_tp === 0)) {
-                continue;
-            }
-            let b = this._.find(im.gclBills, {bid: p.id});
-            if (!b) {
-                b = {imid: im.id, bid: p.id, b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price};
-                im.gclBills.push(b);
-                this.ImBillsData.push(b);
-            }
-            b.jl = this.ctx.helper.add(b.jl, p.gather_qty);
-            b.contract_jl = this.ctx.helper.add(b.contract_jl, p.contract_qty);
-            b.qc_jl = this.ctx.helper.add(b.qc_jl, p.qc_qty);
-
-            b.pre_jl = this.ctx.helper.add(b.pre_jl, p.pre_gather_qty);
-            b.pre_contract_jl = this.ctx.helper.add(b.pre_contract_jl, p.pre_contract_qty);
-            b.pre_qc_jl = this.ctx.helper.add(b.pre_qc_jl, p.pre_qc_qty);
-
-            b.end_jl = this.ctx.helper.add(b.end_jl, p.end_gather_qty);
-            b.end_contract_jl = this.ctx.helper.add(b.end_contract_jl, p.end_contract_qty);
-            b.end_qc_jl = this.ctx.helper.add(b.end_qc_jl, p.end_qc_qty);
-            this._generateTzPosData(p, b);
-        }
+        this._recursiveGenerateTzGclBills(node, im);
     }
     _generateTzChangeData(node, im) {
         if (!im.changes) {

+ 24 - 18
app/public/js/stage_im.js

@@ -337,28 +337,34 @@ const stageIm = (function () {
             lp.qc_jl = ZhCalc.add(lp.qc_jl, p.qc_qty);
         }
     }
+    function recursiveGenerateTzGclBills(node, im) {
+        for (const p of node.children) {
+            if (p.children && p.children.length > 0) {
+                recursiveGenerateTzGclBills(p, im)
+            } else {
+                if ((!p.b_code || p.b_code === '') || (p.children && p.children.length > 0)) {
+                    continue;
+                }
+                if ((!p.contract_tp || p.contract_tp === 0) && (!p.qc_tp || p.qc_tp === 0)) {
+                    continue;
+                }
+                let b = _.find(im.gclBills, {bid: p.id});
+                if (!b) {
+                    b = {bid: p.id, b_code: p.b_code, name: p.name, unit: p.unit};
+                    im.gclBills.push(b);
+                }
+                b.jl = ZhCalc.add(b.jl, p.gather_qty);
+                b.contract_jl = ZhCalc.add(b.contract_jl, p.contract_qty);
+                b.qc_jl = ZhCalc.add(b.qc_jl, p.qc_qty);
+                generateTzPosData(p, b);
+            }
+        }
+    }
     function generateTzGclBillsData(node, im) {
         if (!im.gclBills) {
             im.gclBills = [];
         }
-        const posterity = gsTree.getPosterity(node);
-        for (const p of posterity) {
-            if (p.children && p.children.length > 0) {
-                continue;
-            }
-            if ((!p.contract_tp || p.contract_tp === 0) && (!p.qc_tp || p.qc_tp === 0)) {
-                continue;
-            }
-            let b = _.find(im.gclBills, {bid: p.id});
-            if (!b) {
-                b = {bid: p.id, b_code: p.b_code, name: p.name, unit: p.unit};
-                im.gclBills.push(b);
-            }
-            b.jl = ZhCalc.add(b.jl, p.gather_qty);
-            b.contract_jl = ZhCalc.add(b.contract_jl, p.contract_qty);
-            b.qc_jl = ZhCalc.add(b.qc_jl, p.qc_qty);
-            generateTzPosData(p, b);
-        }
+        recursiveGenerateTzGclBills(node, im);
     }
     function generateTzChangeData(node, im) {
         if (!im.changes) {