| 
					
				 | 
			
			
				@@ -25,6 +25,14 @@ var quantity_detail = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.datas = datas; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.getListByID = function (ID,field) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             let condition={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            condition[field] = ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             let details = _.filter(this.datas, condition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            details = _.sortBy(details, 'seq'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return details; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 提交数据后返回数据处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         quantity_detail.prototype.doAfterUpdate = function(err, data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(!err){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,8 +138,8 @@ var quantity_detail = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             doc.projectID = selected.data.projectID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             doc[dataCode]=args.editingText; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             doc.seq=args.row; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(dataCode=='regex'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(!this.regexChecking(args.editingText)||!this.referenceChecking(args.editingText,args.row,doc)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(dataCode=='regex'){//  if(this.checkAndCalcResult(args.editingText,args.row,doc) === false){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(this.checkAndCalcResult(args.editingText,args.row,doc) === false){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     gljOprObj.showQuantityDetailData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -283,6 +291,82 @@ var quantity_detail = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let regExp = new RegExp(FindText, "g"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return str.replace(regExp, RepText); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.calcResult = function (doc) {//return false 代表输入有误 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let field = doc.billID?"billID":"rationID";// doc.rationID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let detailList = this.getListByID(doc[field],field); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let result = this.getEvalResult(doc.referenceIndexs,detailList,doc.regex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(result === null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doc.result = result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.getEvalResult = function(referenceIndexs,detailList,regex) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let decimal = getDecimal("quantity_detail"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for(let i of referenceIndexs){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    regex = this.replaceReference(i,detailList,regex) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                console.log('replace all C reference -----'+regex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                regex = this.replaceSqr(regex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                console.log('replace all sqar reference -----'+regex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return scMathUtil.roundTo(eval(regex), -decimal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }catch (error){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alert('输入的表达式有误,请重新输入!'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.replaceReference = function(index,detailList,str) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            str=str.toUpperCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let rstr= detailList[index-1].regex==null?'0':'('+detailList[index-1].regex+')'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            str=this.replaceAll('C'+index,rstr,str); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(detailList[index-1].referenceIndexs.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (let i of detailList[index-1].referenceIndexs){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    str =this.replaceReference(i,detailList,str); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return str; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.replaceSqr=function(text) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var squarRegex = /\([^\^]+\)\^\d+/g; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var sqararr = text.match(squarRegex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var squarRegex2 = /C[0-9]+\^\d+|[0-9]+([.]{1}[0-9]+){0,1}\^\d+/g; //匹配没有括号的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var sqararr2=text.match(squarRegex2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(sqararr){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                text=this.converSqrByArr(sqararr,text); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(sqararr2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                text=this.converSqrByArr(sqararr2,text); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return text; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.converSqrByArr  = function(sqararr,text) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var temp = text; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sqararr.forEach(function (item) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var arr = item.split('\^'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var y = parseInt(arr[1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var x_arr = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (var i = 0; i < y; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    x_arr.push(arr[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var temStr = x_arr.join('*'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                temp = temp.replace(item, temStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.checkAndCalcResult = function (regex,row,doc) {//return false 表示没有通过检查 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(!this.regexChecking(regex)||!this.referenceChecking(regex,row,doc)||!this.calcResult(doc)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         quantity_detail.prototype.updateQuantityDetail=function (args,dataCode,recode,selected,batchCallback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             var doc ={},me = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             var query={ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -292,7 +376,7 @@ var quantity_detail = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             var selected = selected?selected:projectObj.project.mainTree.selected; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             doc[dataCode]=args.editingText; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (dataCode == 'regex') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(!this.regexChecking(args.editingText)||!this.referenceChecking(args.editingText,args.row,doc)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(this.checkAndCalcResult(args.editingText,args.row,doc) === false){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     gljOprObj.showQuantityDetailData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 |