| 
					
				 | 
			
			
				@@ -548,7 +548,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getSumLoadFinalData(sid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.pid, cf.cid, cf.cbid, cf.qty, cf.stimes, cf.sorder, c.code As c_code' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.pid, cf.cid, cf.cbid, cf.qty, cf.stimes, cf.sorder, cf.minus, cf.no_value, c.code As c_code,' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  FROM ' + this.tableName + ' cf' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  Where cf.sid = ?'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -618,44 +618,45 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (change.length === 0) return []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                where: { cid: change.map(x => { return x.cid; }) } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const changeBillsIndex = {}, changeBillsPart = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (const cb of changeBills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                changeBillsIndex[cb.id] = cb; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!changeBillsPart[cb.cid]) changeBillsPart[cb.cid] = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                changeBillsPart[cb.cid].push(cb); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const stageChangeBills = await this.getChangeBillsWithUsedInfo(stage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (const scb of stageChangeBills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!scb.qty) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const cb = changeBillsIndex[scb.cbid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (cb) cb.used_qty = this.ctx.helper.add(cb.used_qty, scb.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (const cid in changeBillsPart) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const c = change.find(x => { return x.cid === cid }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!c) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                for (const cb of changeBillsPart[cid]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    cb.tp = this.ctx.helper.mul(cb.spamount, cb.unit_price, c.tp_decimal || this.ctx.tender.info.decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    cb.used_tp = this.ctx.helper.mul(cb.used_qty, cb.unit_price, this.ctx.tender.info.decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    c.used_tp = this.ctx.helper.add(c.used_tp, cb.used_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (cb.spamount > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        c.p_tp = this.ctx.helper.add(c.p_tp, cb.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        c.p_used_tp = this.ctx.helper.add(c.p_used_tp, cb.used_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } else if (cb.spamount < 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        c.n_tp = this.ctx.helper.add(c.n_tp, cb.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        c.n_used_tp = this.ctx.helper.add(c.n_used_tp, cb.used_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                c.used_pt = c.total_price ? this.ctx.helper.mul(this.ctx.helper.div(c.used_tp, c.total_price, 4), 100) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                c.p_used_pt = c.p_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.p_used_tp, c.p_tp, 4), 100) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                c.n_used_pt = c.n_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.n_used_tp, c.n_tp, 4), 100) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return change; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 因为总包导入后,单价不一定与分包相关,为了避免错误,不计算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     where: { cid: change.map(x => { return x.cid; }) } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const changeBillsIndex = {}, changeBillsPart = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // for (const cb of changeBills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     changeBillsIndex[cb.id] = cb; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     if (!changeBillsPart[cb.cid]) changeBillsPart[cb.cid] = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     changeBillsPart[cb.cid].push(cb); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const stageChangeBills = await this.getChangeBillsWithUsedInfo(stage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // for (const scb of stageChangeBills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     if (!scb.qty) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     const cb = changeBillsIndex[scb.cbid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     if (cb) cb.used_qty = this.ctx.helper.add(cb.used_qty, scb.qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // for (const cid in changeBillsPart) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     const c = change.find(x => { return x.cid === cid }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     if (!c) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     for (const cb of changeBillsPart[cid]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         cb.tp = this.ctx.helper.mul(cb.spamount, cb.unit_price, c.tp_decimal || this.ctx.tender.info.decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         cb.used_tp = this.ctx.helper.mul(cb.used_qty, cb.unit_price, this.ctx.tender.info.decimal.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         c.used_tp = this.ctx.helper.add(c.used_tp, cb.used_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         if (cb.spamount > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //             c.p_tp = this.ctx.helper.add(c.p_tp, cb.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //             c.p_used_tp = this.ctx.helper.add(c.p_used_tp, cb.used_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         } else if (cb.spamount < 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //             c.n_tp = this.ctx.helper.add(c.n_tp, cb.tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //             c.n_used_tp = this.ctx.helper.add(c.n_used_tp, cb.used_tp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     c.used_pt = c.total_price ? this.ctx.helper.mul(this.ctx.helper.div(c.used_tp, c.total_price, 4), 100) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     c.p_used_pt = c.p_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.p_used_tp, c.p_tp, 4), 100) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     c.n_used_pt = c.n_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.n_used_tp, c.n_tp, 4), 100) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // return change; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getStageMinusChange(stage) { 
			 |