| 
					
				 | 
			
			
				@@ -31,7 +31,6 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     startReplace:function (nodes,result) {//其实应该是批量修改工料机属性,与替换工料机不同 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let me = this,updateData = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for(let n of nodes){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -41,6 +40,10 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if(r_list.length > 0) updateData.push(...r_list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        me.postReplace(updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    postReplace:function (updateData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let me = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(updateData.length == 0) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $.bootstrapLoading.start(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         CommonAjax.post("/material/replace",updateData,function(result){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -48,7 +51,6 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             me.updateCacheAfterReplace(result) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     updateCacheAfterReplace:function (result){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let nodes = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for(let data of result){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -72,7 +74,6 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ration_glj_model.refreshTreeNodeIfNeeded(glj);//刷新造价书上的树节点(如果需要) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     eachNode:function (node,item) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let replaceDatas =[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(item && item.bills.rule){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -83,7 +84,6 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return replaceDatas; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     getReplaceData:function (billsItemID,materialMap,replace_property) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let list = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let replace_glj_list = this.findMatchRationGLJ(billsItemID,materialMap);//取出需要替换的工料机和对替换的材料内容 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -93,8 +93,6 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     getDoc:function (glj,material,replace_property) {//取定额工料机中需要修改的内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let doc = {},keyList = ['name','specs','type','unit']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for(let key of keyList){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -106,8 +104,6 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return doc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     findMatchRationGLJ:function (billsItemID,materialMap) {//查找清单下匹配的需要替换的定额工料机 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let replaceList=[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for(let g of projectObj.project.ration_glj.datas){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -136,7 +132,6 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             callback(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     getKeyString:function (itemText,matchStr) {//截取关键数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         itemText = itemText.replace(/:/g, ":");//中文字符转换为英文字符 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         itemText = itemText.replace(matchStr,"@$@");//用特殊符号取代关键字,方便截取 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -149,6 +144,91 @@ let MaterialController = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     trim:function (str) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return str.replace(/(^\s*)|(\s*$)/g, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //--------------2018-10-08新加替换表格----------------- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    setting:{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        header:[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {headerName: "项目特征", headerWidth: 100, dataCode: "character", dataType: "String"}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {headerName: "内容", headerWidth: 225, dataCode: "context", dataType: "String"}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {headerName: "名称", headerWidth: 50, dataCode: "name", dataType: "String",hAlign: "center",cellType:"replaceButton"}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {headerName: "规格", headerWidth: 50, dataCode: "specs", dataType: "String",hAlign: "center",cellType:"replaceButton"}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        view: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lockColumns: [0,1,2,3], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rowHeaderWidth:25 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    spread:null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sheet:null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    datas:[], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    showReplaceDiv:function (node) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#subSpread").addClass("ration_glj_spread"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#replaceM").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.showReplaceSpread(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        refreshSubSpread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    hideReplaceDiv:function(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#subSpread").removeClass("ration_glj_spread"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#replaceM").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        refreshSubSpread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    showReplaceSpread:function(node){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.initSpread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.showData(node); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    initSpread:function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!this.spread){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.spread = SheetDataHelper.createNewSpread($("#replaceM")[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.initSheet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.spread.refresh(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    initSheet:function(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.sheet = this.spread .getSheet(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sheetCommonObj.initSheet( this.sheet, this.setting); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.sheet.name('materialReplace'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    showData:function(node){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.datas = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let parent = node.parent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(parent){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.getItems(parent.data.itemCharacterText); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sheetCommonObj.showData(this.sheet, this.setting,this.datas); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.sheet.setRowCount(this.datas.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    getItems:function(characterText){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!characterText) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let strArray =  characterText.split(/\n/); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(let tem of strArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            tem = tem.replace(/:/g, ":");//中文字符转换为英文字符 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(tem.indexOf(":") != -1){//有:号才提取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let proArr = tem.split(":"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //如果内容为空的话也不提取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let context = this.trim(proArr[1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(context!="") this.datas.push({character:proArr[0],context:context,name:"换",specs:"换"}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    onReplaceButtonClick:function(e, args){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let me = MaterialController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let sheet = args.sheet, row = args.row, col = args.col; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let dataCode = me.setting.header[col].dataCode, item = me.datas[row], doc = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(dataCode && item){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            doc[dataCode] = item.context; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            me.replaceByClick(doc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    replaceByClick:function (tem) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let ration_glj = gljOprObj.getSelectedRationGlj(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let doc = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(ration_glj && !ration_glj.isMixRatio){//有选中并且不是组成物 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for(let key in tem){//检查属性是否做了改变,如果没有改变不用提交替换 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(ration_glj[key] != tem[key]) doc[key] = tem[key] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(!_.isEmpty(doc)) this.postReplace([{glj:ration_glj,doc:doc}]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 |