| 
					
				 | 
			
			
				@@ -145,15 +145,41 @@ const gatherGcl = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         '  图册号(drawing_code), 备注(memo), 节点类型(node_type), 总额计量(is_tp)\n' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         '3. 如需汇总"未计入清单章节项",请勾选"章节编号(chapter)"字段\n', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     intro: '根据三级清单树结构,汇总平面工程量清单,目前仅支持mem_stage_bills表', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    fun: function (ctx, data, fieldsKey, options) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const gatherFields = function(gcl, data, fields) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (const f of fields) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (data[f]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    gcl[f] = ctx.helper.add(gcl[f], data[f]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    _gatherCalcField: function (gcl, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const prop in data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (((prop === 'total_price' || prop.indexOf('tp') > 0) || 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                (prop === 'quantity' || prop.indexOf('qty') > 0)) && data[prop]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gcl[prop] = ctx.helper.add(gcl[f], data[f]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!data.mem_stage_bills) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    _gatherTpField: function (ctx, gcl, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const prop in data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ((prop === 'total_price' || prop.indexOf('tp') > 0) && data[prop]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gcl[prop] = ctx.helper.add(gcl[f], data[f]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    _loadGatherInfo: function (gcl, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const prop in data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (/^t_[0-9]*_(id|name)$/.test(prop)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gcl[prop] = data[prop]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    _gatherFields: function(gcl, data, fields) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const f of fields) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (data[f]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gcl[f] = ctx.helper.add(gcl[f], data[f]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fun: function (ctx, data, fieldsKey, options) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const tableName = options ? options.table : 'mem_stage_bills'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const gatherData = data[tableName]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!gatherData || gatherData.length === 0) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const fields = ctx.helper._.map(fieldsKey, 'field'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const needFields = ['b_code', 'name', 'unit', 'unit_price', 'is_leaf']; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -162,9 +188,10 @@ const gatherGcl = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const gatherOther = fields.indexOf('chapter') >= 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const gclBills = [], other = {name: '未计入清单章节项', chapter: '10000'}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this._loadGatherInfo(other, gatherData[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (const b of data.mem_stage_bills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const child = ctx.helper._.find(data.mem_stage_bills, {ledger_pid: b.ledger_id}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const b of gatherData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const child = ctx.helper._.find(gatherData, {ledger_pid: b.ledger_id}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (child) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (b.b_code && b.b_code !== '') { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -179,27 +206,15 @@ const gatherGcl = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         qc_bgl_code: [], chapter: b.chapter, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         deal_bills_qty: b.deal_bills_qty, deal_bills_tp: b.deal_bills_tp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (tableName.indexOf('mem_gather_') >= 0) this._loadGatherInfo(gcl, b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     gclBills.push(gcl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                gatherFields(gcl, b, [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'deal_qty', 'deal_tp', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'final_tp' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this._gatherCalcField(gcl, b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (b.qc_bgl_code && b.qc_bgl_code !== '') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     gcl.qc_bgl_code = gcl.qc_bgl_code.concat(b.qc_bgl_code.split(';')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else if (gatherOther) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                gatherFields(other, b, [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'deal_tp', 'sgfh_tp', 'sjcl_tp', 'qtcl_tp', 'total_price', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'contract_tp', 'qc_tp', 'gather_tp', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'final_tp' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this._gatherTpField(other, b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (gatherOther) gclBills.push(other); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -208,7 +223,7 @@ const gatherGcl = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             g.final_ratio = ctx.helper.mul(ctx.helper.div(g.end_gather_tp, g.final_ratio), 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        data.mem_stage_bills = gclBills; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        data[tableName] = gclBills; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const sortGcl = { 
			 |