| 
					
				 | 
			
			
				@@ -0,0 +1,265 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * Created by Mai on 2017/4/1. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+var quantity_detail = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    createNew: function (project) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 用户定义private方法 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var tools = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var quantity_detail = function (proj) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.gljTree = cacheTree.createNew(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           // this.project = proj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.datas = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var sourceType = ModuleNames.quantity_detail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.getSourceType = function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return sourceType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            proj.registerModule(ModuleNames.quantity_detail, this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.temList=[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // prototype用于定义public方法 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.loadData = function (datas) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.datas = datas; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 提交数据后返回数据处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.doAfterUpdate = function(err, data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(!err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(data.updateTpye=='ut_update'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.refreshAfterUpdate(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else if(data.updateTpye=='ut_delete'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.refreshAfterDelete(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.refreshAfterSave(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alert("输入的表达式有误,请重新输入"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.refreshSheetData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.refreshAfterSave=function(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.datas.push(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            gljOprObj.detailData.push(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            gljOprObj.detailData=_.sortBy(gljOprObj.detailData,'seq'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.refreshSheetData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.refreshAfterUpdate=function(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var detail_list = this.datas; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var detail_index= _.findIndex(detail_list,(detail)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return detail.ID==data.query.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _.forEach(data.doc, function(n, key) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                detail_list[detail_index][key] = n; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var filter_object; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(detail_list[detail_index].hasOwnProperty('rationID')){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                filter_object={'rationID':detail_list[detail_index].rationID}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                filter_object={'billID':detail_list[detail_index].billID}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var showList = _.filter(this.datas,filter_object); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            gljOprObj.detailData=showList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.refreshSheetData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.refreshAfterDelete=function(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var glj_list = projectObj.project.ration_coe.datas; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _.remove(glj_list,data.query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _.remove(gljOprObj.sheetData,data.query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.refreshSheetData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.refreshSheetData=function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sheetCommonObj.showData(gljOprObj.detailSheet,gljOprObj.detailSetting,gljOprObj.detailData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.getUpdateData=function(type,query,doc,callfunction){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var updateData = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var newobj = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'updateType': type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'query': query, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(doc){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                newobj['doc']=doc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(callfunction){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                newobj['updateFunction']=callfunction; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateData.push(newobj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return updateData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.saveQuantityDetail=function (args,dataCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var doc={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var selected = projectObj.project.mainTree.selected; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(selected.sourceType==ModuleNames.ration){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doc.rationID=selected.data.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(selected.sourceType==ModuleNames.bills){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doc.billID=selected.data.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            doc.projectID = selected.data.projectID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            doc[dataCode]=args.editingText; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            doc.seq=args.row; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var updateData = this.getUpdateData('ut_create',null,doc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            project.pushNow('saveQuantityDetail',[this.getSourceType()],updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.updateQuantityDetail=function (args,dataCode,recode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var doc ={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var query={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ID:recode.ID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                projectID:recode.projectID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            doc[dataCode]=args.editingText; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (dataCode == 'regex') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(recode.hasOwnProperty('rationID')){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    query.rationID=recode.rationID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    query.billID = recode.billID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                query.index = args.row; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.updateQuantityRegex(query,doc,args) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.normalUpdate(query,doc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.updateQuantityRegex=function(query,doc,args){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var needupdate = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(args.editingText==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                needupdate =true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                args.editingText = _.trim(args.editingText,/\r\n/); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(this.regexChecking(args.editingText)&&this.referenceChecking(args.editingText,args.row,doc)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    needupdate = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(needupdate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var updateData = this.getUpdateData('ut_update',query,doc,'updateQuantityRegex'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                project.pushNow('updateQuantityDetail',[this.getSourceType()],updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.isSummationUpdate=function (args,detailList,newval) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var query={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ID:detailList[args.row].ID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                projectID:detailList[args.row].projectID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var doc={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                isSummation:newval 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.normalUpdate(query,doc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.normalUpdate=function(query,doc){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var updateData = this.getUpdateData('ut_update',query,doc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            project.pushNow('updateQuantityDetail',[this.getSourceType()],updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.regexChecking=function(text){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var regex=/^[0-9Cc\+\-\*\^/\(\)\.]*$/g; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(!regex.test(text)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alert("输入了非法字符,请重新输入!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.referenceChecking=function (text,row,doc) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            text = text.toUpperCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //text= this.replaceSqr(text); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var me = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var refReg = /C\d+/g; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var self ='C'+(row+1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var refList = text.match(refReg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var invalidate = _.includes(refList,self); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var referenceIndexs = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var indexOut = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _.forEach(refList,function (item) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var ref_index = parseInt(item.substring(1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(ref_index>me.datas.length){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    indexOut=true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    referenceIndexs.push(ref_index); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(indexOut){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alert("引用有误,请重新输入!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            referenceIndexs=_.uniq(referenceIndexs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            doc.referenceIndexs = referenceIndexs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.temList = referenceIndexs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            invalidate=this.getAllReferenceList((row+1),referenceIndexs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(invalidate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alert("计算式中产生了循环引用,请重新输入!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.getAllReferenceList=function(original,refList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var me =this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var invalidate=false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _.forEach(refList,function (item) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(me.getReferenceList(item,original)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    invalidate=true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return invalidate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        quantity_detail.prototype.getReferenceList=function(item,original) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var invalidate =false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var recode = this.datas[item - 1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (recode.referenceIndexs.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(_.includes(recode.referenceIndexs,original)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    invalidate = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return invalidate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.temList = this.temList.concat(recode.referenceIndexs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _.forEach(recode.referenceIndex, function (item) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(this.getReferenceList(item,original)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        invalidate = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return invalidate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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=converSqrByArr(sqararr,text); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(sqararr2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                text=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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log(temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return new quantity_detail(project); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}; 
			 |