Kaynağa Gözat

中间计量,生成规则调整

MaiXinRong 5 yıl önce
ebeveyn
işleme
f2f0e826e0
2 değiştirilmiş dosya ile 78 ekleme ve 17 silme
  1. 39 8
      app/lib/stage_im.js
  2. 39 9
      app/public/js/stage_im.js

+ 39 - 8
app/lib/stage_im.js

@@ -61,7 +61,7 @@ class StageIm {
         this.ImData = [];
         this.ImBillsData = [];
         //
-        this.imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position', 'jldy'];
+        this.imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_memo_org', 'calc_memo_remark', 'calc_img', 'position', 'jldy'];
         this.splitChar = '-';
     }
 
@@ -316,7 +316,7 @@ class StageIm {
         const posRange = this.pos.getLedgerPos(node.id);
         if (!posRange) { return; }
         for (const p of posRange) {
-            if (!p.gather_qty || this.ctx.helper.checkZero(p.gather_qty)) { continue; }
+            if (this.ctx.helper.checkZero(p.contract_qty) && this.ctx.helper.checkZero(p.contract_qty)) { continue; }
             let lp = this._.find(gclBills.pos, { name: p.name });
             if (!lp) {
                 lp = { name: p.name };
@@ -335,7 +335,8 @@ class StageIm {
                 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)) {
+                if (!this.ctx.helper.checkZero(p.contract_qty) || !this.ctx.helper.checkZero(p.contract_tp) ||
+                    !this.ctx.helper.checkZero(p.qc_qty) || !this.ctx.helper.checkZero(p.qc_tp)) {
                     continue;
                 }
                 let b = this._.find(im.gclBills, { bid: p.id });
@@ -412,12 +413,41 @@ class StageIm {
             }
         }
     }
+
+    _checkUsed(node) {
+        const helper = this.ctx.helper;
+        if (node.children && node.children.length > 0) {
+            const posterity = this.billsTree.getPosterity(node);
+            for (const p of posterity) {
+                if (!p.children || p.children.length === 0) continue;
+                if (!helper.checkZero(p.contract_qty) || !helper.checkZero(p.contract_tp) ||
+                    !helper.checkZero(p.qc_qty) || !helper.checkZero(p.qc_tp))
+                    return true;
+                const pPos = this.pos.getLedgerPos(p.id);
+                if (!pPos || pPos.length === 0) continue;
+                for (const pp of pPos) {
+                    if (!helper.checkZero(pp.contract_qty) || !helper.checkZero(pp.qc_qty)) return true;
+                }
+            }
+            return false;
+        } else {
+            if (!helper.checkZero(node.contract_qty) || !helper.checkZero(node.contract_tp) ||
+                !helper.checkZero(node.qc_qty) || !helper.checkZero(node.qc_tp))
+                return true;
+            const pPos = this.pos.getLedgerPos(node.id);
+            if (!pPos || pPos.length === 0) return false;
+            for (const pp of pPos) {
+                if (!helper.checkZero(pp.contract_qty) || !helper.checkZero(pp.qc_qty)) return true;
+            }
+        }
+    }
+
     /**
      * 生成 0号台账 中间计量数据
      * @param {Object} node - 生成中间计量表的节点
      */
     _generateTzImData(node) {
-        if (node.gather_tp) {
+        if (this._checkUsed(node)) {
             const nodeIndex = this.billsTree.getNodeSerialNo(node);
             const peg = this._getPegNode(node);
             const im = {
@@ -559,7 +589,7 @@ class StageIm {
         return im;
     }
     _generateBwBillsImData (node) {
-        if (!node.gather_tp && !node.contract_tp && !node.qc_tp) return;
+        if (!this._checkUsed(node)) return;
 
         const nodeIndex = this.billsTree.getNodeSerialNo(node);
         const peg = this._getPegNode(node);
@@ -569,7 +599,7 @@ class StageIm {
         for (const p of posterity) {
             if (p.children && p.children.length > 0) continue;
             if (!p.b_code || p.b_code === '') continue;
-            if (!p.gather_tp || p.gather_tp === 0) continue;
+            if (!this._checkUsed(p)) continue;
 
             const pPos = this.pos.getLedgerPos(p.id);
             if (pPos && pPos.length > 0) {
@@ -598,11 +628,12 @@ class StageIm {
 
                 imDefault.contract_jl = this.ctx.helper.add(imDefault.contract_jl, p.contract_qty);
                 imDefault.qc_jl = this.ctx.helper.add(imDefault.qc_jl, p.qc_qty);
+                imDefault.used = true;
 
                 this._addBwBillsGclBills(imDefault, p);
             }
         }
-        if (imDefault.contract_jl || imDefault.qc_jl) {
+        if (imDefault.used) {
             imDefault.jl = this.ctx.helper.add(imDefault.contract_jl, imDefault.qc_jl);
             imDefault.id = this.ImData.length + 1;
             this.ImData.push(imDefault);
@@ -694,7 +725,7 @@ class StageIm {
         for (const p of posterity) {
             if (p.children && p.children.length > 0) { continue; }
             if (!p.b_code || p.b_code === '') { continue; }
-            if (!p.gather_tp || p.gather_tp === 0) { continue; }
+            if (!this._checkUsed(p)) { continue; }
             // if (this.ctx.helper.checkZero(p.contract_qty) && this.ctx.helper.checkZero(p.qc_qty)) { continue; }
             let im = nodeImData.find(function(d) {
                 return d.lid === node.id &&

+ 39 - 9
app/public/js/stage_im.js

@@ -343,7 +343,7 @@ const stageIm = (function () {
         const posRange = gsPos.getLedgerPos(node.id);
         if (!posRange) { return }
         for (const p of posRange) {
-            if (!p.gather_qty || checkZero(p.gather_qty)) { continue; }
+            if (checkZero(p.contract_qty) && checkZero(p.qc_qty)) { continue; }
             let lp = _.find(gclBills.pos, {name: p.name});
             if (!lp) {
                 lp = {name: p.name};
@@ -362,7 +362,8 @@ const stageIm = (function () {
                 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)) {
+                if (checkZero(p.contract_qty) && checkZero(p.contract_tp) &&
+                    checkZero(p.qc_qty) && checkZero(p.qc_tp)) {
                     continue;
                 }
                 let b = _.find(im.gclBills, {bid: p.id});
@@ -416,12 +417,40 @@ const stageIm = (function () {
             }
         }
     }
+
+    function checkUsed(node) {
+        if (node.children && node.children.length > 0) {
+            const posterity = gsTree.getPosterity(node);
+            for (const p of posterity) {
+                if (p.children && p.children.length > 0) continue;
+                if (!checkZero(p.contract_qty) || !checkZero(p.contract_tp) ||
+                    !checkZero(p.qc_qty) || !checkZero(p.qc_tp))
+                    return true;
+                const pPos = gsPos.getLedgerPos(p.id);
+                if (!pPos || pPos.length === 0) continue;
+                for (const pp of pPos) {
+                    if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
+                }
+            }
+            return false;
+        } else {
+            if (!checkZero(node.contract_qty) || !checkZero(node.contract_tp) ||
+                !checkZero(node.qc_qty) || !checkZero(node.qc_tp))
+                return true;
+            const pPos = gsPos.getLedgerPos(node.id);
+            if (!pPos || pPos.length === 0) return false;
+            for (const pp of pPos) {
+                if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
+            }
+        }
+    }
+
     /**
      * 生成 0号台账 中间计量数据
      * @param {Object} node - 生成中间计量表的节点
      */
     function generateTzImData (node) {
-        if (node.gather_tp) {
+        if (checkUsed(node)) {
             const nodeIndex = gsTree.getNodeIndex(node);
             const peg = getPegNode(node);
             const im = {
@@ -476,7 +505,7 @@ const stageIm = (function () {
         im.jl = ZhCalc.add(im.contract_jl, im.qc_jl);
     }
     function generateBwBillsImData (node) {
-        if (node.gather_tp) {
+        if (checkUsed(node)) {
             const nodeIndex = gsTree.getNodeIndex(node);
             const peg = getPegNode(node);
             const nodeImData = [], posterity = gsTree.getPosterity(node);
@@ -496,11 +525,11 @@ const stageIm = (function () {
             for (const p of posterity) {
                 if (p.children && p.children.length > 0) continue;
                 if (!p.b_code || p.b_code === '') continue;
-                if (!p.gather_tp || p.gather_tp === 0) continue;
+                if (!checkUsed(p)) continue;
                 const pPos = gsPos.getLedgerPos(p.id);
                 if (pPos && pPos.length > 0) {
                     for (const pp of pPos) {
-                        if (!pp.gather_qty && !pp.contract_qty && !pp.qc_qty) continue;
+                        if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) continue;
                         let im = nodeImData.find(function (d) {
                             return d.lid === node.id && d.pos_name === pp.name;
                         });
@@ -545,6 +574,7 @@ const stageIm = (function () {
 
                     imDefault.contract_jl = ZhCalc.add(imDefault.contract_jl, p.contract_tp);
                     imDefault.qc_jl = ZhCalc.add(imDefault.qc_jl, p.qc_tp);
+                    imDefault.used = true;
 
                     addBwBillsGclBills(imDefault, {
                         b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
@@ -552,7 +582,7 @@ const stageIm = (function () {
                     });
                 }
             }
-            if (imDefault.contract_jl || imDefault.qc_jl) {
+            if (imDefault.used) {
                 imDefault.jl = ZhCalc.add(imDefault.contract_jl, imDefault.qc_jl);
                 ImData.push(imDefault);
             }
@@ -642,7 +672,7 @@ const stageIm = (function () {
         for (const p of posterity) {
             if (p.children && p.children.length > 0 ) { continue; }
             if (!p.b_code || p.b_code === '') { continue }
-            if (!p.gather_tp || p.gather_tp === 0) { continue; }
+            if (!checkUsed(p)) { continue; }
             let im = nodeImData.find(function (d) {
                 return d.lid === node.id &&
                     d.code === p.b_code && p.name === d.name && p.unit === d.unit && checkZero(ZhCalc.sub(p.unit_price, d.unit_price));
@@ -693,7 +723,7 @@ const stageIm = (function () {
             if (pPos && pPos.length > 0) {
                 const nodeIndex = gsTree.getNodeIndex(node);
                 for (const pp of pPos) {
-                    if ((!pp.contract_qty || pp.contract_qty === 0) && (!pp.qc_qty || pp.qc_qty === 0)) { continue }
+                    if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) { continue }
                     const im = {
                         lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price, pid: pp.id,
                         jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty,