| 
					
				 | 
			
			
				@@ -657,7 +657,7 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case 'dagl': data.dagl_url && window.open(data.dagl_url); break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case 'gxby': data.gxby_url && window.open(data.gxby_url); break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case 'qc_qty': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (data.children && data.children.length > 0 || data.lock) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (data.children && data.children.length > 0 || data.lock || data.is_import) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const nodePos = stagePos.getLedgerPos(data.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (nodePos && nodePos.length > 0) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 changesObj.loadChanges({bills: data}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1455,8 +1455,12 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const addTag = newTag({ledgerSheet: slSpread.getActiveSheet(), billsTag}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const tenderSelect = TenderSelect({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         type: 'stage', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        afterLoad: function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        afterLoad: function (result, select) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const nodes = stageTree.loadPostStageData(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const posterity = stageTree.getPosterity(select); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const p of posterity) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                p.is_import = !!result.import_change.data.find(x => { return x.lid === p.id }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (detail) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 detail.loadStageLedgerUpdateData(result, nodes); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1469,6 +1473,8 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 sumLoadMiss.clearMissData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // todo 优化,仅加载需要刷新的变更令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (checkedChanges) checkedChanges.reloadChangeData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $.contextMenu({ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2025,7 +2031,7 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 加载计量单元数据 - 暂时统一加载,如有需要,切换成动态加载并缓存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    postData(window.location.pathname + '/load', { filter: 'ledger;pos;detail;change;tag;cooperation' }, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    postData(window.location.pathname + '/load', { filter: 'ledger;pos;detail;change;import_change;tag;cooperation' }, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 加载树结构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         stageTree.loadDatas(result.ledgerData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         checkShowLast(result.ledgerData.length); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2051,7 +2057,7 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 加载中间计量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         stageIm.init(stage, imType, tenderInfo.decimal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        stageIm.loadData(result.ledgerData, result.posData, result.detailData, result.changeData, result.detailAtt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        stageIm.loadData(result.ledgerData, result.posData, result.detailData, result.changeData, result.import_change, result.detailAtt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         errorList.loadHisErrorData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         checkList.loadHisCheckData(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3500,17 +3506,6 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $('#view-calc-remark').text(img_remark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $('#edit-img').modal('hide'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // updateImageData = updateData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // $('#edit-img').modal('hide'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // postData(window.location.pathname + '/detail/merge-img', updateData, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     stageIm.loadUpdateDetailData(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     data.calc_img = result.calc_img; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     data.calc_img_org = result.calc_img_org; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#show-calc-img').attr('src', calcImgSrc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#calc-img').attr('src', calcImgSrc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#view-calc-img').attr('src', calcImgSrc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#edit-img').modal('hide'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else if (data.calc_img) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     self.updateImageData = {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid, calc_img_remark: img_remark}; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3522,16 +3517,6 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $('#view-calc-remark').val(img_remark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $('#text-edit').val(img_remark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $('#edit-img').modal('hide'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // postData(window.location.pathname + '/detail/merge-img', {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid}, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     stageIm.loadUpdateDetailData(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     data.calc_img = result.calc_img; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     data.calc_img_org = result.calc_img_org; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#show-calc-img').attr('src', calcImgSrc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#calc-img').attr('src', calcImgSrc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#view-calc-img').attr('src', calcImgSrc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //     $('#edit-img').modal('hide'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     self.updateImageData = updateData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $('#show-calc-img').attr('src', ''); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3660,7 +3645,7 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.changeSpreadSetting = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 cols: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    {title: '变更令号', colSpan: '1', rowSpan: '1', field: 'p_code', hAlign: 0, width: 100, formatter: '@'}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {title: '变更令号', colSpan: '1', rowSpan: '1', field: 'p_code', hAlign: 0, width: 100, formatter: '@', cellType: 'tip', getTip: function (x) { return x.t_name ? `所属标段:${x.t_name}` : ''; }}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     {title: '变更名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 180, formatter: '@'}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     {title: '金额', colSpan: '1', rowSpan: '1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     {title: '批复文号', colSpan: '1', rowSpan: '1', field: 'w_code', hAlign: 0, width: 100, formatter: '@'}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3673,6 +3658,13 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 headerFont: '12px 微软雅黑', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 font: '12px 微软雅黑', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 readOnly: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                getColor: function (sheet, data, row, col, defaultColor) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (data && data.is_import) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return '#eee'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return defaultColor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.changeSpread = SpreadJsObj.createNewSpread(setting.changeObj[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.changeSheet = this.changeSpread.getActiveSheet(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3718,7 +3710,7 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (change.detail) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     self.loadChangeDetailData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    postData(window.location.pathname + '/change/detail', {cid: change.cid}, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    postData(window.location.pathname + '/change/detail', {cid: change.cid, is_import: change.is_import}, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         change.detail = result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         self.analyzeChange(change); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         self.loadChangeDetailData(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3741,8 +3733,14 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         name: '定位至台账', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         icon: 'fa-sign-in', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         callback: function (key, opt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            const change = SpreadJsObj.getSelectObject(self.changeSheet); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             const changeBills = SpreadJsObj.getSelectObject(self.changeBillsSheet); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if (changeBills.gcl_id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (change.is_import) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (changeBills.pos && changeBills.pos.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), changeBills.pos[0].ledger_id, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    stagePosSpreadObj.loadCurPosData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } else if (changeBills.gcl_id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 const node = stageTree.nodes.find(x => {return x.id === changeBills.gcl_id}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), node.ledger_id, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 stagePosSpreadObj.loadCurPosData(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3793,23 +3791,23 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         reloadChangeData() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             postData(window.location.pathname + '/change/data', null, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                self.changes = result.changes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                self.changes = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result.changes.forEach(x => { x.is_import = 0; self.changes.push(x); }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result.import_changes.forEach(x => { x.is_import = 1; delete x.total_price; self.changes.push(x); }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (result.changes.length > 0) self.analyzeChange(result.changes[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (result.import_changes.length > 0) self.analyzeChange(result.import_changes[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 SpreadJsObj.loadSheetData(self.changeSheet, SpreadJsObj.DataType.Data, self.changes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.changeSheet.setSelection(0, 0, 1, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (self.changes.length > 0) self.analyzeChange(result.changes[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.curChangeId = self.changes.length > 0 ? self.changes[0].id : null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 self.loadChangeDetailData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        analyzeChange(change) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            change.bills = change.detail.bills; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        _analyzeCommon(change) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for (const b of change.bills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const aub = change.detail.addUsedBills.find(function (x) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    return x.id === b.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const eub = change.detail.endUsedBills.find(function (x) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return x.cbid === b.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (aub) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    b.used_qty = aub.used_qty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (eub) b.used_qty = eub.qty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 b.qty = _.toNumber(b.samount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 b.valid_qty = ZhCalc.sub(b.qty, b.used_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 b.tp = ZhCalc.round(ZhCalc.mul(b.qty, b.unit_price), tenderInfo.decimal.tp); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3821,6 +3819,33 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        _analyzeImport(change) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const b of change.bills) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const eub = change.detail.endUsedBills.find(function (x) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return x.rela_cbid === b.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (eub) b.used_qty = eub.rela_qty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                delete b.unit_price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                delete b.bwmx; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                b.pos = _.filter(change.detail.curUsedBills, { rela_cbid: b.id }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                b.cur_qty = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (const p of b.pos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    b.qty = b.rela_qty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const node = stageTree.datas.find(x => { return x.id === p.lid; }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    p.ledger_id = node.ledger_id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    p.f_qty = node.quantity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    b.cur_qty = ZhCalc.add(b.cur_qty, p.rela_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        analyzeChange(change) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            change.bills = change.detail.bills; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (change.is_import) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this._analyzeImport(change); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this._analyzeCommon(change); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 展开收起附件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $('a', '.right-nav').bind('click', function () { 
			 |