| 
					
				 | 
			
			
				@@ -9,9 +9,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const imFields = ['uuid', 'doc_code', 'bgl_code', 'start_peg', 'end_peg', 'bw', 'jldy', 'drawing_code', 'calc_memo', 'calc_img']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const imFields = ['uuid', 'doc_code', 'bgl_code', 'bgl_drawing_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const splitChar = '-'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    let stage, imType, details, ImData, pre; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let stage, imType, details, changes, ImData, pre; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const gsTreeSetting = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         id: 'ledger_id', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         pid: 'ledger_pid', 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -57,14 +57,14 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     function initCheck () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const gatherNodes = stage.im_gather_node ? _.map(stage.im_gather_node.split(','), _.toNumber) : []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const gatherNodes = stage.im_gather_node ? stage.im_gather_node.split(',') : []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (const node of gsTree.datas) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             node.check = gatherNodes.indexOf(node.id) !== -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function loadData (ledger, pos, stageDetail) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function loadData (ledger, pos, stageDetail, stageChange) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         gsTree.loadDatas(ledger); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         treeCalc.calculateAll(gsTree); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -73,6 +73,8 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         initCheck(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         details = stageDetail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        changes = stageChange; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // function loadData (ledger, curStage, pos, curPosStage, stageDetail) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -161,13 +163,64 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function getZlNormalBw(node, peg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (peg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const subPeg1 = getNodeByLevel(node, peg.level + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const subPeg2 = getNodeByLevel(node, peg.level + 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let result = peg.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (subPeg1 && subPeg1.id !== peg.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result = result + '-' + subPeg1.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (subPeg2 && subPeg2.id !== subPeg1.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    result = result + '-' + subPeg2.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (node.level === 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return node.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else if (node.level >= 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let parent = node, result = parent.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                while (parent.level > 3 && parent) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    parent = getNodeByLevel(node, parent.level - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    result = parent.name + '-' + result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function getZlGatherBw(node, peg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (peg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const subPeg1 = getNodeByLevel(node, peg.level + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let result = peg.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (subPeg1 && subPeg1.id !== peg.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result = result + '-' + subPeg1.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (node.level < 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return node.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let parent = node, result = parent.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                while (parent.level > 3 && parent) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    parent = getNodeByLevel(node, parent.level - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    result = parent.name + '-' + result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     function checkCustomDetail(im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const cd = _.find(details, function (d) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return im.lid === d.lid && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 (!im.code || im.code === d.code) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 (!im.name || im.name === d.name) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 (!im.unit || im.unit === d.unit) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                checkZero(ZhCalc.sub(im.unit_price, d.unit_price)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                checkZero(ZhCalc.sub(im.unit_price, d.unit_price)) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                (!im.pid || im.pid === d.pid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (cd) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             _.assignInWith(im, cd, function (oV, sV, key) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -176,58 +229,117 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function generatePosData(node, lx) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!lx.pos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            lx.pos = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function getCalcMemo(im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (im.calc_memo !== undefined && im.calc_memo !== null && im.calc_memo !== '') return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (im.leafXmjs && im.leafXmjs.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const memo = ['本期计量:' + im.jl + ' ' + im.unit]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const lx of im.leafXmjs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (const p of lx.pos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    memo.push(p.name + ':' + p.jl + ' ' + im.unit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.calc_memo = memo.join('\n'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if (im.gclBills && im.gclBills.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const memo = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const [i, b] of im.gclBills.entries()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (b.pos && b.pos.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    memo.push('清单' + (i+1) + b.b_code + ' ' + b.name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for (const p of b.pos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        memo.push(p.name + ':' + p.jl + ' ' + b.unit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    memo.push('清单' + (i+1) + b.b_code + ' ' + b.name + ':' + b.jl + ' ' + b.unit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.calc_memo = memo.join('\n'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.calc_memo =  ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function getChangeInfo(im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (im.changes && im.changes.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const code = _.uniq(_.map(im.changes, 'c_code')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!im.bgl_code || im.bgl_code === '') im.bgl_code = code.join(';'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const new_code = _.uniq(_.map(im.changes, 'c_new_code')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!im.bgl_drawing_code || im.bgl_drawing_code === '') im.bgl_drawing_code = new_code.join(';'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function generateTzPosData(node, gclBills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!gclBills.pos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            gclBills.pos = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const posRange = gsPos.getLedgerPos(node.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!posRange) { return } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (const p of posRange) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!p.gather_qty || checkZero(p.gather_qty)) { continue; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            let lp = _.find(lx.pos, {name: p.name}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let lp = _.find(gclBills.pos, {name: p.name}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!lp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                lp = {name: p.name, qty: p.gather_qty}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                lx.pos.push(lp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                lp = {name: p.name}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gclBills.pos.push(lp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             lp.jl = ZhCalc.add(lp.jl, p.gather_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lp.contract_jl = ZhCalc.add(lp.contract_jl, p.contract_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lp.qc_jl = ZhCalc.add(lp.qc_jl, p.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 生成所属项目节数据(取最底层项目节) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @param node - 生成数据基于的台账节点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @param im - 中间计量数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function generateLeafXmjData(node, im, jlField) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!im.leafXmjs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            im.leafXmjs = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function generateTzGclBillsData(node, im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!im.gclBills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.gclBills = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const leafXmj = gsTree.getLeafXmjParent(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!leafXmj) { return } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let lx = _.find(im.leafXmjs, {lxid: leafXmj.id}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!lx) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            lx = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                lxid: leafXmj.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                code: leafXmj.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                name: leafXmj.name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            im.leafXmjs.push(lx); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        lx.jl = ZhCalc.add(lx.jl, node[jlField]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        generatePosData(node, lx); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function getCalcMemo(im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (im.calc_memo !== undefined && im.calc_memo !== null && im.calc_memo !== '') return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const memo = ['本期计量:' + im.jl + ' ' + im.unit]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (const lx of im.leafXmjs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (const p of lx.pos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                memo.push(p.name + ':' + p.qty + ' ' + im.unit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function generateTzChangeData(node, im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!im.changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.changes = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const posterity = gsTree.getPosterity(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const p of posterity) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (p.children && p.children.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ((!p.qc_tp || p.qc_tp === 0)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const posRange = gsPos.getLedgerPos(p.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!posRange) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (const c of changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (c.lid === p.id && c.pid == -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        im.changes.push(c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (const pp of posRange) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if ((!pp.qc_tp || pp.qc_tp === 0)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for (const c of changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (c.lid === p.id && c.pid === pp.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            im.changes.push(c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return memo.join('\n'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 生成 0号台账 中间计量数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Object} node - 生成中间计量表的节点 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -236,28 +348,92 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (node.gather_tp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const peg = getPegNode(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const im = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                lid: node.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                code: node.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                jl: node.gather_tp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                contract_jl: node.contract_tp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                qc_jl: node.qc_tp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                lid: node.id, code: node.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                jl: node.gather_tp, contract_jl: node.contract_tp, qc_jl: node.qc_tp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 im_code: getNewImCode(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                fbfx: getFbfx(node, peg), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                peg: peg ? peg.name : '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                drawing_code: getDrawingCode(node), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                peg: peg ? peg.name : '', drawing_code: getDrawingCode(node), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (stage.im_gather && node.check) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                im.bw = node.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                im.bw = getZlGatherBw(node, peg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                im.xm = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                im.jldy = node.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                im.bw = node.name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                im.bw = getZlNormalBw(node, peg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                im.xm = node.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             checkCustomDetail(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            generateLeafXmjData(node, im, 'gather_tp'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!stage.im_gather || !node.check) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                generateTzGclBillsData(node, im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ImData.push(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            generateTzChangeData(node, im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function generateZlPosData(node, lx) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!lx.pos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lx.pos = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const posRange = gsPos.getLedgerPos(node.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!posRange) { return } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const p of posRange) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!p.gather_qty || checkZero(p.gather_qty)) { continue; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let lp = _.find(lx.pos, {name: p.name}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!lp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                lp = {name: p.name}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                lx.pos.push(lp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lp.jl = ZhCalc.add(lp.jl, p.gather_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lp.contract_jl = ZhCalc.add(lp.contract_jl, p.contract_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lp.qc_jl = ZhCalc.add(lp.qc_jl, p.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function generateZlLeafXmjData(node, im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!im.leafXmjs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.leafXmjs = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const leafXmj = gsTree.getLeafXmjParent(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!leafXmj) { return } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let lx = _.find(im.leafXmjs, {lxid: leafXmj.id}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!lx) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lx = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                lxid: leafXmj.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                code: leafXmj.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                name: leafXmj.name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.leafXmjs.push(lx); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        lx.jl = ZhCalc.add(lx.jl, node.gather_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        lx.contract_jl = ZhCalc.add(lx.contract_jl, node.contract_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        lx.qc_jl = ZhCalc.add(lx.qc_jl, node.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        generateZlPosData(node, lx); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function generateZlChangeData(node, im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!im.changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            im.changes = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ((!node.qc_tp || node.qc_tp === 0)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const posRange = gsPos.getLedgerPos(node.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!posRange) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const c of changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (c.lid === node.id && c.pid == -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    im.changes.push(c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const p of posRange) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if ((!p.qc_tp || p.qc_tp === 0)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (const c of changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (c.lid === node.id && c.pid === p.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        im.changes.push(c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 生成 总量控制 中间计量数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Object} node - 生成中间计量表的节点 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -269,41 +445,97 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!p.b_code || p.b_code === '') { continue } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!p.gather_qty || p.gather_qty === 0 ) { continue; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let im = nodeImData.find(function (d) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return d.code === p.b_code && p.name === d.name && p.unit === d.unit && checkZero(ZhCalc.sub(p.unit_price, d.unit_price)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!im) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const peg = getPegNode(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 im = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    lid: node.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    code: p.b_code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    name: p.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    unit: p.unit, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    unit_price: p.unit_price, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    jl: 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    contract_jl: 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    qc_jl: 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jl: 0, contract_jl: 0, qc_jl: 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     im_code: getNewImCode(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    fbfx: getFbfx(node, peg), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    peg: peg ? peg.name : '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    drawing_code: getDrawingCode(node), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    bw: node.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    peg: peg ? peg.name : '', drawing_code: getDrawingCode(node), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (stage.im_gather && node.check) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    im.bw = getZlGatherBw(node, peg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    im.xm = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    im.jldy = p.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    im.bw = getZlNormalBw(node, peg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    im.xm = node.name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 nodeImData.push(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 checkCustomDetail(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ImData.push(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            generateLeafXmjData(p, im, 'gather_qty'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!stage.im_gather || !node.check) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                generateZlLeafXmjData(p, im, 'gather_qty'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            generateZlChangeData(p, im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             im.jl = ZhCalc.add(im.jl, p.gather_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             im.contract_jl = ZhCalc.add(im.contract_jl, p.contract_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             im.qc_jl = ZhCalc.add(im.qc_jl, p.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function generateBwImData (node) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const posterity = gsTree.getPosterity(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const p of posterity) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (p.children && p.children.length > 0 ) { continue; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!p.b_code || p.b_code === '') { continue } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const peg = getPegNode(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const pPos = gsPos.getLedgerPos(p.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const bw = getZlNormalBw(node, peg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (pPos && pPos.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (const pp of pPos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if ((!pp.contract_qty || pp.contract_qty === 0) && (!pp.qc_qty || pp.qc_qty === 0)) { 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, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        im_code: getNewImCode(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        bw: bw, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        peg: CheckPeg(pp.name) ? pp.name : (peg ? peg.name : ''), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        xm: pp.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        drawing_code: pp.drawing_code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        changes: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    im.calc_memo = '本期计量:' + im.jl + ' ' + im.unit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    checkCustomDetail(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ImData.push(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (pp.qc_qty && pp.qc_qty !== 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (const c of changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (c.lid === p.id && c.pid === pp.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                im.changes.push(c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if ((!p.contract_qty || p.contract_qty === 0) && (!p.qc_qty || p.qc_qty === 0)) { continue } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const im = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price, pid: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    im_code: getNewImCode(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    bw: bw, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    peg: peg ? peg.name : '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    xm: node.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    drawing_code: getDrawingCode(node), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    changes: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                im.calc_memo = '本期计量:' + im.jl + ' ' + im.unit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                checkCustomDetail(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ImData.push(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (p.qc_qty && p.qc_qty !== 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for (const c of changes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (c.lid === p.id && c.pid == -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            im.changes.push(c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 递归 生成中间计量表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Array} nodes 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -311,11 +543,13 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     function recursiveBuildImData (nodes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!nodes || nodes.length === 0) { return; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (const node of nodes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (gsTree.isLeafXmj(node) || (stage.im_gather && node.check)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (gsTree.isLeafXmj(node) || (stage.im_type !== imType.bw.value && stage.im_gather && node.check)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (stage.im_type === imType.tz.value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     generateTzImData(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else if (stage.im_type === imType.zl.value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     generateZlImData(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else if (stage.im_type === imType.bw.value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    generateBwImData(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 recursiveBuildImData(node.children); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -337,10 +571,8 @@ const stageIm = (function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 生成数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         recursiveBuildImData(gsTree.children); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (const im of ImData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            im.calc_memo = getCalcMemo(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (im.leafXmjs && im.leafXmjs.length === 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                im.leaf_xmj_name = im.leafXmjs[0].name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getCalcMemo(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getChangeInfo(im); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ImData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |