| 
					
				 | 
			
			
				@@ -297,6 +297,7 @@ class GLJListModel extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw '没有对应的单价文件'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let CompositionGLJ=[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let unitPriceModel = new UnitPriceModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 判断类型,如果是混凝土、砂浆或者配合比则查找对应的组成物(前提是没有对应的项目工料机数据) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (data.type === GLJTypeConst.CONCRETE || data.type === GLJTypeConst.MORTAR || 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 data.type === GLJTypeConst.MIX_RATIO || data.type === GLJTypeConst.GENERAL_MACHINE) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -305,11 +306,20 @@ class GLJListModel extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     await this.compositionInit(data, unitPriceFileId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 CompositionGLJ=await this.getCompositionGLJByData(data,unitPriceFileId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(isAddProjectGLJ==false&&CompositionGLJ.length==0){//如果不是新增,并且是有组成物的类型但又没有发现组成物的情况下,有可能是错误数据,重新在库中查找一下组成物,有则插入 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    await this.compositionInit(data, unitPriceFileId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    CompositionGLJ=await this.getCompositionGLJByData(data,unitPriceFileId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(CompositionGLJ.length>0){//如果这次发现又有组成物了,则把旧的单价数据删除,在后面的操作中会重新增加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        let de_condition ={unit_price_file_id: unitPriceFileId,code:data.code,name:data.name,unit:data.unit,type:data.type}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        data.specs!=null&&data.specs!=undefined&&data.specs!=""?de_condition.specs = data.specs:de_condition; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        await unitPriceModel.db.delete(de_condition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             projectGljData.subList=CompositionGLJ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 新增单价文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            let unitPriceModel = new UnitPriceModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let [unitPriceInsertData, isAdd] = await unitPriceModel.addUnitPrice(data, unitPriceFileId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!unitPriceInsertData) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -550,7 +560,6 @@ class GLJListModel extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 查找对应组成物的项目工料机数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let indexs=['code','name','specs','unit','type']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let [projectGljList, compositionGljList] = await this.getCompositionGLJList(gljId, projectId, indexs, fromTable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 整理配合比待插入数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let mixRatioInsertData = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (let tmp of compositionGljList) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -572,13 +581,16 @@ class GLJListModel extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 插入配合比表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 因为有可能项目工料机与单价数据已存在,但配合比数据不存在,所以先插入配合比,后续判断如果存在项目工料机则可以省下数据库操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let mixRatioModel = new MixRatioModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let addMixRatioResult = await mixRatioModel.add(mixRatioInsertData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!addMixRatioResult) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw '组成物插入单价数据失败!'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(mixRatioInsertData.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let mixRatioModel = new MixRatioModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let addMixRatioResult = await mixRatioModel.add(mixRatioInsertData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!addMixRatioResult) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw '组成物插入单价数据失败!'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let pglj_length = projectGljList instanceof Array ? projectGljList.length:Object.getOwnPropertyNames(projectGljList).length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 如果已经存在则后续操作停止 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(Object.getOwnPropertyNames(projectGljList).length === compositionGljList.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(pglj_length === compositionGljList.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -691,9 +703,8 @@ class GLJListModel extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 获取对应的组成物数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let gljListModel = fromTable === 'std' ? new STDGLJLibGLJListModel() : new GljModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let componentGljList = await gljListModel.getComponent(gljId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (componentGljList.length <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw '不存在对应的组成物'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return [{},[]]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let codeList = []; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -742,7 +753,7 @@ class GLJListModel extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let typeList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let unitList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(mixRatios.length<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw  '不存在对应的组成物'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return [[],[],[]]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let mixRatioData={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for(let tmp of mixRatios) { 
			 |