|  | @@ -14,6 +14,7 @@ import GLJTypeConst from "../../common/const/glj_type_const";
 | 
	
		
			
				|  |  |  import RationGLJFacade from "../../ration_glj/facade/ration_glj_facade";
 | 
	
		
			
				|  |  |  import STDGLJLibGLJListModel from "../../common/std/std_glj_lib_glj_list_model";
 | 
	
		
			
				|  |  |  import MixRatioModel from "./mix_ratio_model";
 | 
	
		
			
				|  |  | +import GljModel from "../../complementary_glj_lib/models/gljModel";
 | 
	
		
			
				|  |  |  const ProjectModel = require('../../pm/models/project_model').project;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  class GLJListModel extends BaseModel {
 | 
	
	
		
			
				|  | @@ -204,19 +205,16 @@ class GLJListModel extends BaseModel {
 | 
	
		
			
				|  |  |              glj.quantity = totalComposition[glj.code] !== undefined ? totalComposition[glj.code] : glj.quantity;
 | 
	
		
			
				|  |  |              glj.quantity = compositionConsumption[gljId] !== undefined ?  glj.quantity + compositionConsumption[gljId] : glj.quantity;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            // 消耗值为0的数据不显示
 | 
	
		
			
				|  |  | -            if (glj.quantity === 0) {
 | 
	
		
			
				|  |  | -                delete gljList[index];
 | 
	
		
			
				|  |  | -                continue;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |              // 组成物数据
 | 
	
		
			
				|  |  |              gljList[index].ratio_data = mixRatioData[gljId] !== undefined ? mixRatioData[gljId] : [];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            glj.unit_price.base_price = parseFloat(glj.unit_price.base_price).toFixed(2);
 | 
	
		
			
				|  |  | +            glj.unit_price.market_price = parseFloat(glj.unit_price.market_price).toFixed(2);
 | 
	
		
			
				|  |  |              // 计算调整基价
 | 
	
		
			
				|  |  |              switch (glj.unit_price.type + '') {
 | 
	
		
			
				|  |  |                  // 人工: 调整基价=基价单价*调整系数
 | 
	
		
			
				|  |  |                  case GLJTypeConst.LABOUR:
 | 
	
		
			
				|  |  | -                    glj.adjust_price = glj.adjustment * glj.unit_price.base_price;
 | 
	
		
			
				|  |  | +                    glj.adjust_price = parseFloat(glj.adjustment * glj.unit_price.base_price).toFixed(2);
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  // 机械类型的算法
 | 
	
		
			
				|  |  |                  case GLJTypeConst.MACHINE:
 | 
	
	
		
			
				|  | @@ -266,7 +264,7 @@ class GLJListModel extends BaseModel {
 | 
	
		
			
				|  |  |              // 判断类型,如果是混凝土、砂浆或者配合比则查找对应的组成物(前提是没有对应的项目工料机数据)
 | 
	
		
			
				|  |  |              if (isAddProjectGLJ && (data.type === GLJTypeConst.CONCRETE || data.type === GLJTypeConst.MORTAR ||
 | 
	
		
			
				|  |  |                  data.type === GLJTypeConst.MIX_RATIO || data.type === GLJTypeConst.GENERAL_MACHINE)) {
 | 
	
		
			
				|  |  | -                this.compositionInit(data.code, data.project_id, unitPriceFileId);
 | 
	
		
			
				|  |  | +                this.compositionInit(data, unitPriceFileId);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // 新增单价文件
 | 
	
	
		
			
				|  | @@ -416,14 +414,20 @@ class GLJListModel extends BaseModel {
 | 
	
		
			
				|  |  |       * 工料机中组成物操作
 | 
	
		
			
				|  |  |       * 该方法只在确保没有对应项目工料机的时候才会调用
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param {String} code
 | 
	
		
			
				|  |  | +     * @param {Object} data
 | 
	
		
			
				|  |  |       * @param {Number} projectId
 | 
	
		
			
				|  |  | -     * @param {Number} unitPriceFileId
 | 
	
		
			
				|  |  |       * @return {void}
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    async compositionInit(code, projectId, unitPriceFileId) {
 | 
	
		
			
				|  |  | +    async compositionInit(data, unitPriceFileId) {
 | 
	
		
			
				|  |  | +        let gljId = data.glj_id === undefined ? 0 : data.glj_id;
 | 
	
		
			
				|  |  | +        let projectId = data.project_id === undefined ? 0 : data.project_id;
 | 
	
		
			
				|  |  | +        if (code === 0 || projectId === 0) {
 | 
	
		
			
				|  |  | +            throw '参数错误';
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        let fromTable = data.from === undefined ? 'std' : data.from;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          // 查找对应组成物的项目工料机数据
 | 
	
		
			
				|  |  | -        let [projectGljList, compositionGljList] = await this.getCompositionGLJList(code, projectId, 'name');
 | 
	
		
			
				|  |  | +        let [projectGljList, compositionGljList] = await this.getCompositionGLJList(gljId, projectId, 'name', fromTable);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 整理配合比待插入数据
 | 
	
		
			
				|  |  |          let mixRatioInsertData = [];
 | 
	
	
		
			
				|  | @@ -567,15 +571,16 @@ class GLJListModel extends BaseModel {
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 获取混凝土等有组成物相关工料机对应的组成物项目工料机数据
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param {String} code
 | 
	
		
			
				|  |  | +     * @param {Number} gljId
 | 
	
		
			
				|  |  |       * @param {Number} projectId
 | 
	
		
			
				|  |  |       * @param {String} indexBy
 | 
	
		
			
				|  |  | +     * @param {String} fromTable
 | 
	
		
			
				|  |  |       * @return {Promise} 返回组成物工料机数据和组成物列表数据
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    async getCompositionGLJList(code, projectId, indexBy = null) {
 | 
	
		
			
				|  |  | +    async getCompositionGLJList(gljId, projectId, indexBy = null, fromTable = 'std') {
 | 
	
		
			
				|  |  |          // 获取对应的组成物数据
 | 
	
		
			
				|  |  | -        let stdGljLibGljListModel = new STDGLJLibGLJListModel();
 | 
	
		
			
				|  |  | -        let componentGljList = await stdGljLibGljListModel.getComponent(code);
 | 
	
		
			
				|  |  | +        let gljListModel = fromTable === 'std' ? new STDGLJLibGLJListModel() : new GljModel();
 | 
	
		
			
				|  |  | +        let componentGljList = await gljListModel.getComponent(gljId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (componentGljList.length <= 0) {
 | 
	
		
			
				|  |  |              throw '不存在对应的组成物';
 |