Переглянути джерело

材料计算bug + 单价文件编辑

zhangweicheng 5 роки тому
батько
коміт
7b8ac26696

+ 1 - 0
modules/all_models/material_calc.js

@@ -86,6 +86,7 @@ let freightSchema = {
     rations:[ration_schema],
     ration_gljs:[ration_glj],
     calcType:String,//计算方式
+    exp:String,//计算式
     materialType:String//材料类型
 };
 mongoose.model("freight_calc", new Schema(freightSchema, {versionKey: false, collection: "freight_calc"}));

+ 11 - 2
modules/glj/controllers/glj_controller.js

@@ -217,6 +217,10 @@ class GLJController extends BaseController {
      * @return {void}
      */
     async deleteMixRatio(request, response) {
+       if(request.body.data){
+        let data = request.body.data;
+        request.body = JSON.parse(data);
+       }
         let id = request.body.id;
         id = parseInt(id);
         let responseData = {
@@ -230,15 +234,20 @@ class GLJController extends BaseController {
 
             let mixRatioModel = new MixRatioModel();
             let result = await mixRatioModel.deleteById(id);
+            let unitPriceModel = new UnitPriceModel();
             if(request.body.unitPrice){
-                let unitPrice = JSON.parse(request.body.unitPrice);
-                let unitPriceModel = new UnitPriceModel();
+                let unitPrice = _.isObject(request.body.unitPrice)?request.body.unitPrice: JSON.parse(request.body.unitPrice);
                 await unitPriceModel.model.update(unitPrice.query,unitPrice.doc);
             }
+            if(request.body.parent){
+              let parent = _.isObject(request.body.parent)?request.body.parent:JSON.parse(request.body.parent);
+              await unitPriceModel.model.update(parent.query,parent.doc);
+            }
             if (!result) {
                 throw '删除失败';
             }
         } catch (error) {
+           console.log(error);
             responseData.err = 1;
             responseData.msg = error;
         }

+ 12 - 2
modules/glj/models/glj_list_model.js

@@ -11,14 +11,13 @@ import CounterModel from "./counter_model";
 import UnitPriceModel from "./unit_price_model";
 import UnitPriceFileModel from "./unit_price_file_model";
 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;
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 let gljUtil = require('../../../public/gljUtil');
-import decimal_facade from "../../main/facade/decimal_facade";
+import ration_facade from "../../main/facade/ration_facade";
 let gljCollectionName = 'glj_list';
 let GLJSchemas = mongoose.model(gljCollectionName);
 let _ = require("lodash");
@@ -122,6 +121,8 @@ class GLJListModel extends BaseModel {
             // 查找组成物的消耗量
             let totalComposition = {};
             let mixRatioData = {};
+
+            let missMaxRatio = [];//由于共享单价文件,单价文件编辑器造成的,存在组成物和对应的单价,但是项目工料机不存的情况
             if (connect_keys.length > 0) {
                 let mixRatioModel = new MixRatioModel();
                 condition = {connect_key: {"$in": connect_keys}, unit_price_file_id: unitPriceFileId};
@@ -145,8 +146,17 @@ class GLJListModel extends BaseModel {
                     } else {
                         mixRatioConnectData[m_index] = [tmp.connect_key];
                     }
+                    //检查该组成物对应的项目工料机是否存在  
+                    if(!keyMap[m_index]) missMaxRatio.push(tmp);//这里可能会有重复,但是后面的添加操作中会去重 
                 }
             }
+            if(missMaxRatio.length > 0){
+              let newList =  await ration_facade.getNewProjectGLJFromMissMixratio(projectId,missMaxRatio,keyMap,[]);
+              await ration_facade.setIDfromCounter("glj_list",newList);
+              await this.model.insertMany(newList);
+              gljData=gljData.concat(newList);         
+            }
+
             // 组合单价数据
             gljData = this.combineData(gljData, unitPriceList, {}, mixRatioData, totalComposition);
             // 排序

+ 8 - 4
modules/glj/models/unit_price_model.js

@@ -329,14 +329,18 @@ class UnitPriceModel extends BaseModel {
         let tasks = [];
         let parentTask = [];
         let newValueMap = {};
+        let needCheckDatas= [];
         for(let d of data){//第一次循环生成更新提交的记录,并生成一个新值的映射表,为更新父节点使用
             let condition = {id:d.unit_price.id,unit_price_file_id:d.unit_price.unit_price_file_id};
-            let doc = {};
-            doc[d.field]=d.newval;
-            newValueMap[d.unit_price.id] = doc;
+            let doc = d.ext?d.ext:{};
+            if(d.field){//共用接口后有可能只更新其它属性,不更新价格
+              doc[d.field]=d.newval;
+              newValueMap[d.unit_price.id] = doc;
+              needCheckDatas.push(d);
+            }
             tasks.push(this.generateUpdateTask(condition,doc));
         }
-        for(let d of data){//第二次更新父节点
+        for(let d of needCheckDatas){//第二次更新父节点
            let rList = await this.checkAndUpdateParent(d.unit_price,d.field,d.project_id,newValueMap,true);
            parentTask = parentTask.concat(rList);
         }

+ 72 - 15
modules/main/facade/ration_facade.js

@@ -1,6 +1,24 @@
 /**
  * Created by zhang on 2018/2/9.
  */
+
+module.exports = {
+  replaceRations: replaceRations,
+  addNewRation:addNewRation,
+  updateMaterialRation:updateMaterialRation,
+  addMaterialRation:addMaterialRation,
+  addMultiRation: addMultiRation,
+  getSameSectionRations:getSameSectionRations,
+  getExtendData:getExtendData,
+  getDefaultProgramID:getDefaultProgramID,
+  deleteSubListByQuery:deleteSubListByQuery,
+  updateCoeAdjust:updateCoeAdjust,
+  getUnitPriceData:getUnitPriceData,
+  setIDfromCounter:setIDfromCounter,
+  getNewProjectGLJFromMissMixratio:getNewProjectGLJFromMissMixratio
+};
+
+
 let mongoose = require('mongoose');
 import SearchDao from '../../complementary_ration_lib/models/searchModel';
 import GLJListModel from "../../glj/models/glj_list_model";
@@ -42,18 +60,6 @@ let vvTaxModel =  mongoose.model("std_vehicleVesselTax_items");
 
 const fs = require('fs');
 
-module.exports = {
-    replaceRations: replaceRations,
-    addNewRation:addNewRation,
-    updateMaterialRation:updateMaterialRation,
-    addMaterialRation:addMaterialRation,
-    addMultiRation: addMultiRation,
-    getSameSectionRations:getSameSectionRations,
-    getExtendData:getExtendData,
-    getDefaultProgramID:getDefaultProgramID,
-    deleteSubListByQuery:deleteSubListByQuery,
-    updateCoeAdjust:updateCoeAdjust
-};
 async function addNewRation(data,compilation) {
     let query = data.itemQuery;
     let stdRation = null;
@@ -603,7 +609,6 @@ async function getProjectGLJinfo(projectID,t_newRationGLJList,gljKeyMap,gljCodes
   //处理车般税相关,车船税是添加项目时,项目工料机,和单价文件里自动添加的 --- todo
  
   let [unitPriceMap,newUnitPriceList] = await getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId);
-  if(newUnitPriceList.length > 0) await unitPriceModel.insertMany(newUnitPriceList);
 
 
   if(mixRatioInsertData.length > 0) await mixRatioModel.insertMany(mixRatioInsertData);
@@ -652,7 +657,7 @@ async function getProjectGLJinfo(projectID,t_newRationGLJList,gljKeyMap,gljCodes
 }
 
 
-
+//找到并返回单价文件信息,如果没有自动插入
 async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
   let unitPriceMap = {};
   let newUnitPriceList = [];
@@ -690,7 +695,10 @@ async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
   }
 
 
-  if(newUnitPriceList.length > 0) await setIDfromCounter("unit_price",newUnitPriceList);
+  if(newUnitPriceList.length > 0){
+    await setIDfromCounter("unit_price",newUnitPriceList);
+    await unitPriceModel.insertMany(newUnitPriceList);
+  } 
 
   return [unitPriceMap,newUnitPriceList];
 
@@ -903,6 +911,55 @@ async function getMixRatioInfo(projectID,projectGLJMap,newProjectGLJList,mixRati
 }
 
 
+//根据缺少项目工料机的组成物信息,反向生成对应的项目工料机
+async function getNewProjectGLJFromMissMixratio(projectID,lessMix,projectGLJMap,newProjectGLJList,ext){
+  let lessIDList=[];
+  let uniqMap ={};//去重
+  let lessStdMix = [];//防止组成物中改了名称等,但是通过glj_id取出来的是还没改前的原始数据
+  if(lessMix.length > 0){
+    for(let lm of lessMix){
+      let parentglj = projectGLJMap[lm.connect_key];
+      if(!parentglj) throw `含有组成物工料机${lm.connect_key},没有找到,添加定额失败`;
+      if((parentglj.from == "std" || lm.from == "std") && lm.code!="80CCS"){//车船税特殊处理
+        if(!uniqMap[lm.glj_id]){
+          lessIDList.push(lm.glj_id);
+          uniqMap[lm.glj_id] = lm;
+        }
+        lessStdMix.push(lm);
+      }else {//来自组成物的直接设置    
+        lm.from = 'cpt';
+        lm.gljType = lm.type;
+        let t_mg = getProjectGLJNewData(lm,projectID);
+        newProjectGLJList.push(t_mg);
+        projectGLJMap[getIndex(lm)] = t_mg;
+      }
+    }
+  }
+
+  if(lessIDList.length > 0){
+    let less_stds =  await std_glj_lib_gljList_model.find({'ID':{'$in':lessIDList}}).lean();
+    let less_stds_map = {};
+    for(let les of  less_stds){
+      less_stds_map[les.ID] = les;
+    }
+    for(let t_l_m of lessStdMix){
+      let t_nglj = less_stds_map[t_l_m.glj_id];
+      t_nglj.from = 'std';
+      //防止组成物中改了名称等,但是通过glj_id取出来的是还没改前的原始数据
+      t_nglj.name = t_l_m.name;
+      t_nglj.code = t_l_m.code;
+      t_nglj.gljType = t_l_m.type;
+      t_nglj.specs = t_l_m.specs;
+      t_nglj.unit = t_l_m.unit;
+      let t_np = getProjectGLJNewData(t_nglj,projectID,ext);
+      newProjectGLJList.push(t_np);
+      projectGLJMap[getIndex(t_l_m)] = t_np;
+    }
+  }
+  return newProjectGLJList;
+}
+
+
 function getProjectGLJNewData(tmp,projectId,ext){
   let gljData = {
       glj_id: tmp.ID,

+ 1 - 1
modules/pm/models/project_model.js

@@ -654,7 +654,7 @@ ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function (unitPriceFile
 
     //let condition = {projType: 'Tender', "property.unitPriceFile.id": unitPriceFileId};
     let condition = {"property.unitPriceFile.id": unitPriceFileId,deleteInfo:null};
-    result = await Projects.find(condition,['name','property']);
+    result = await Projects.find(condition,['ID','name','property']);
 
     return result;
 };

+ 43 - 2
modules/unit_price_file/controllers/unit_price_controller.js

@@ -7,7 +7,9 @@ let projectModel = mongoose.model('projects');
 const ProjectDao = require('../../pm/models/project_model').project;
 let unitPriceModel = mongoose.model('unit_price');
 let mixRatioModel = mongoose.model('mix_ratio');
+let com_electrovalence_model = mongoose.model('com_electrovalence');
 let glj_type_util = require('../../../public/cache/std_glj_type_util');
+let ration_facade = require('../../main/facade/ration_facade');
 let _ = require("lodash");
 
 module.exports={
@@ -19,8 +21,7 @@ module.exports={
       let unitpriceList = await unitPriceModel.find({unit_price_file_id:unitPriceFileID},{supplyLocation:0}).lean();
       let mixRatioList = await mixRatioModel.find({unit_price_file_id:unitPriceFileID}).lean();
       let mixRatioMap = _.groupBy(mixRatioList,"connect_key");
-
-
+      let com_electrovalence = await com_electrovalence_model.findOne({"unit_price_file_id":unitPriceFileID}).lean();
 
       let gljTypeMap = glj_type_util.getStdGljTypeCacheObj().innerGljTypeObj;
       let usedTenderList = [];
@@ -42,8 +43,48 @@ module.exports={
           unitpriceList:JSON.stringify(unitpriceList),
           gljTypeMap:JSON.stringify(gljTypeMap),
           mixRatioMap:JSON.stringify(mixRatioMap),
+          com_electrovalence:JSON.stringify(com_electrovalence),
           LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
         });
+    },
+    addMixRatio:async function(req,res){
+      let result={
+        error:0
+    };
+    try {
+        let data = req.body.data;
+        data = JSON.parse(data);
+        let gljList = data.gljList, parentInfo = data.parentInfo,mixRatios = [],gljCodes=[];
+
+        if(gljList.length > 0){
+          for(let newProjectGLJ of gljList){
+              let mixRatio = {
+                  glj_id:newProjectGLJ.glj_id,
+                  consumption:0,
+                  unit_price_file_id:parentInfo.unit_price_file_id,
+                  connect_key:parentInfo.connect_key,
+                  type: newProjectGLJ.type,
+                  code: newProjectGLJ.code,
+                  specs:newProjectGLJ.specs,
+                  name:newProjectGLJ.name,
+                  unit:newProjectGLJ.unit,
+                  model:newProjectGLJ.model
+              };
+              mixRatios.push(mixRatio);
+              gljCodes.push(newProjectGLJ.code);
+          }
+          let [unitPriceMap,newUnitPriceList] = await ration_facade.getUnitPriceData(gljList,gljCodes,parentInfo.unit_price_file_id); 
+          await ration_facade.setIDfromCounter("mix_ratio",mixRatios);    
+          await mixRatioModel.insertMany(mixRatios);
+          result.data = {mixRatios:mixRatios,newUnitPriceList:newUnitPriceList};
+        }
+       
+    }catch (err){
+        logger.err(err);
+        result.error=1;
+        result.message = err.message;
+    }
+      res.json(result);
     }
 }
 

+ 1 - 1
modules/unit_price_file/routes/unit_price_router.js

@@ -5,7 +5,7 @@ module.exports = function (app) {
 
     var Router = express.Router();
     Router.get('/index/:unitPriceFileID', unitPirceController.index);
-    // Router.post('/getGLJDataByCodes',unitPirceController.getGLJDataByCodes);
+    Router.post('/addMixRatio',unitPirceController.addMixRatio);
     // Router.post('/addGLJ',unitPirceController.addGLJ);
     // Router.post('/replaceGLJ',unitPirceController.replaceGLJ);
     

+ 6 - 1
public/web/gljUtil.js

@@ -493,6 +493,9 @@ let gljUtil = {
         //let hs = scMathUtil.roundForObj(tt*hightFeeRate,process_decimal);//(人工定额消耗量*定额价*定额工程量+机械定额消耗量*定额价*定额工程量)*高原取费类别费率
 
     },
+    getAssUsedPrice:function(g){
+      return g.basePrice;
+    },
     getElecCoe:function () {
         return 0.15;
     },
@@ -501,7 +504,7 @@ let gljUtil = {
     },
     setProperty:function(Obj,updateData) {
         for(let ukey in updateData){
-            if(_.isObject(updateData[ukey]) && _.isObject(Obj[ukey])){
+            if(_.isObject(updateData[ukey]) && _.isObject(Obj[ukey])&&!_.isArray(updateData[ukey])){
                 setProperty(Obj[ukey],updateData[ukey]);
             }else {
                 Obj[ukey] = updateData[ukey];
@@ -516,6 +519,8 @@ let gljUtil = {
         // 施工技术措施项目
         CONSTRUCTION_TECH: 3
     },
+    
+
     gljType : {
         LABOUR: 1,                                  // 人工
         // ==============材料类型 ↓=================

+ 1 - 1
public/web/sheet/sheet_common.js

@@ -199,7 +199,7 @@ var sheetCommonObj = {
             }
             if (setting.owner === 'gljTree') {
                 if (setting.header[col].cellType === "checkBox") {
-                    val == 1 ? val : 0;
+                    val= val == 1 ? val : 0;
                     this.setCheckBoxCell(row, col, sheet, val);
                 }
                 if (setting.header[col].dataCode === 'gljType' && data[row].gljType) {

+ 1 - 1
web/building_saas/main/js/models/composition.js

@@ -90,7 +90,7 @@ Composition.prototype.getCompositionByGLJ = function (glj) {
 Composition.prototype.deleteComposition = function (updateData,recode,pid,callback) {
     let me = this;
     $.bootstrapLoading.start();
-    CommonAjax.specialPost( '/glj/delete-ratio',{id: updateData.id,unitPrice:JSON.stringify(updateData.unitPrice)},function (result){
+    CommonAjax.specialPost('/glj/delete-ratio',{id: updateData.id,parent:JSON.stringify(updateData.parent),unitPrice:JSON.stringify(updateData.unitPrice)},function (result){
         me.updateConsumptionInCache(pid,recode,updateData,"delete");
         if(callback){
             callback();

+ 25 - 10
web/building_saas/main/js/models/project_glj.js

@@ -347,9 +347,6 @@ ProjectGLJ.prototype.calcAllMaterial = function (unitPriecs,isFromFeeRate) {//
     let sumOriginalUpdateMap = {};//存放所有材料下的原价更新信息;
 
     for(let g of this.datas.gljList){
-        if(g.code == "2001001"){
-          console.log("calcMat")
-        }
         if(g.quantity !== 0 && g.quantity !== '0'  && g.unit_price.calcMaterial == 1&&!priceMap[g.id]){//工料机本身不包含在要计算的列表内
             //先判断要不要重算,只有包含相关工料机的定额的材料,才需要重新计算
             let fOrPDataMap = {};
@@ -521,7 +518,7 @@ ProjectGLJ.prototype.freightCalc= function (glj,grossWeightCoe_n,dataMap,tfreigh
         if(gljUtil.isDef(materialType)&&materialType != "") t = scMathUtil.roundForObj(t/1.09,process);  //内蒙古要除以税率1.09; 当材料类型有值时,说明是内蒙古计算
         otherFee = scMathUtil.roundForObj(otherFee,unitPirce);
         t = scMathUtil.roundForObj(t+otherFee,process);//单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用
-        t = scMathUtil.roundForObj(t*grossWeightCoe_n,process); //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重”。 单位毛重:毛重系数
+        if(conveyance !== "自办运输") t = scMathUtil.roundForObj(t*grossWeightCoe_n,process); //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重”。 单位毛重:毛重系数
         weightCoe = scMathUtil.roundForObj(weightCoe,unitPirce);
         t = scMathUtil.roundForObj(t*weightCoe,process);//(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
         sum = scMathUtil.roundForObj(sum + t,process);
@@ -928,6 +925,7 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
         let sum =0;
         let heightFee = 0;
         let gljMap = {};
+        let expList = [];
         let decimal = type == "freight"?getDecimal("glj.unitPrice"):getDecimal("glj.unitPriceHasMix");
         //因为材料计算的数据是保存在单价文件里的,有可能存在共享的情况,这样的话就不能用单价文件里的项目工料机ID来匹配,要用5大项匹配
         let pgljMap = {};
@@ -941,13 +939,17 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
         }
         if(temp.rations) {
             for(let r of temp.rations){
-                let [tsum,thei] = calcRation(r,gljMap[r.ID],pgljMap,priceMap);
+                let [tsum,thei,exp] = calcRation(r,gljMap[r.ID],pgljMap,priceMap);
                 heightFee = scMathUtil.roundForObj(heightFee+thei,6);
                 sum = scMathUtil.roundForObj(sum + tsum,6);
+                expList.push(exp);
             }
         }
         sum = scMathUtil.roundForObj(sum,decimal)+"";
-        if(type == "freight" && temp.unitFreight!= sum) return {ID:temp.ID,doc:{unitFreight:sum,heightFee:heightFee}};
+        if(type == "freight"){
+          let exp = `((${expList.join("+")})+${temp.otherFee})x${temp.weightCoe}` 
+          return {ID:temp.ID,doc:{unitFreight:sum,heightFee:heightFee,exp:exp}};
+        } 
         if(type == "price" && temp.supplyPrice !=sum) return {ID:temp.ID,doc:{supplyPrice:sum,heightFee:heightFee}}
     }
     return null;
@@ -956,31 +958,44 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
     function calcRation(ration,gljs,pMap,priceMap){
         let result = 0;
         let heightFee = 0;
+        let exp = "";
         if(gljs){
             let processDecimal = getDecimal("process");
             let hightFeeRate = projectObj.project.projectGLJ.getHighlandFee(ration.feeType);//高原取费类别费率
             let assFeeRate = scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.assistProductionFeeRate,getDecimal("feeRate")) * 0.01;//辅助生产间接费费率
             let laberSum = 0;
             let machineSum = 0;
+            let assList=[];
+            let expList = [];
             let rationQuantity = scMathUtil.roundForObj(ration.quantity,getDecimal("ration.quantity"));
             for(let g of gljs){
                 gljOprObj.setGLJPrice(g,pMap[gljUtil.getIndex(g)]);
                 if(priceMap && priceMap[g.projectGLJID]) g.marketPrice = scMathUtil.roundForObj(priceMap[g.projectGLJID]);
                 let quantity = scMathUtil.roundForObj(g.quantity,getDecimal("glj.quantity"));
                 let t = scMathUtil.roundForObj(quantity * g.marketPrice * rationQuantity,processDecimal);//市场价
-                let rt = scMathUtil.roundForObj(quantity * g.basePrice * rationQuantity,processDecimal);//定额价
-                if(g.type == gljUtil.gljType.LABOUR) laberSum = scMathUtil.roundForObj(laberSum+rt,processDecimal);
-                if(gljUtil.getMainType(g.type) == 3) machineSum = scMathUtil.roundForObj(machineSum+rt,processDecimal);
+                let r_price = gljUtil.getAssUsedPrice(g);//浙江定额时特殊处理,这里取市场价
+                let rt = scMathUtil.roundForObj(quantity * r_price * rationQuantity,processDecimal);//定额价
+                let calString = `${quantity}x${r_price}x${rationQuantity}`;  
+                if(g.type == gljUtil.gljType.LABOUR){
+                  laberSum = scMathUtil.roundForObj(laberSum+rt,processDecimal);
+                  assList.push(`${calString}x${assFeeRate*100}%`) 
+                } 
+                if(gljUtil.getMainType(g.type) == 3) machineSum = scMathUtil.roundForObj(machineSum+rt,processDecimal); 
+               
+                expList.push(`${quantity}x${g.marketPrice}x${rationQuantity}`); 
                 result = scMathUtil.roundForObj(result + t,processDecimal);
             }
             let as = scMathUtil.roundForObj(laberSum * assFeeRate,processDecimal);//人工消耗量*定额价*定额工程量*辅助生产间接费费率
             let tt = scMathUtil.roundForObj(laberSum + machineSum,processDecimal);//人工定额消耗量*定额价*定额工程量+机械定额消耗量*定额价*定额工程量
             let hs = scMathUtil.roundForObj(tt*hightFeeRate,processDecimal);//(人工定额消耗量*定额价*定额工程量+机械定额消耗量*定额价*定额工程量)*高原取费类别费率
+            exp = expList.join("+");
+            if(hightFeeRate!=0) exp += `+${tt}x${hightFeeRate*100}%`;
+            if(assFeeRate!=0) exp += '+'+assList.join("+");
             result = scMathUtil.roundForObj(as + result,processDecimal);
             result = scMathUtil.roundForObj(hs + result,processDecimal);
             heightFee = hs;
         }
-        return  [result,heightFee];
+        return  [result,heightFee,exp];
     }
 
 

+ 16 - 32
web/building_saas/main/js/views/glj_view.js

@@ -321,6 +321,7 @@ var gljOprObj = {
         style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         let colorOpts = optionsOprObj.getOption(optionsOprObj.optionsTypes.COLOROPTS);
+        if(!colorOpts) colorOpts = {SELECTED:{backColor:"#FFFACD"}};
         let selectedColor = colorOpts.SELECTED.backColor,
             recColor = rcolor?rcolor:'White';
         style.backColor = selected ? selectedColor : recColor;
@@ -353,17 +354,19 @@ var gljOprObj = {
         }
     },
     onCheckBoxClick: function (sender, args) {
-        let selected = projectObj.project.mainTree.selected;
-        if(selected.sourceType == ModuleNames.ration_glj){//选中的是工料机时不可编辑
-            return ;
+        if(typeof projectObj != 'undefined'){
+          let selected =  projectObj.project.mainTree.selected;
+          if(selected.sourceType == ModuleNames.ration_glj){//选中的是工料机时不可编辑
+              return ;
+          }
+          if(gljOprObj.isInstallationNode(selected)==true){
+            return;
+          }
         }
         let checkboxValue = args.sheet.getCell(args.row, args.col).value();
         if(args.sheetName == 'rationInstallSheet' && checkboxValue){
             return;
         }
-        if(gljOprObj.isInstallationNode(selected)==true){
-            return;
-        }
         let newval = checkboxValue? 0:1;
         args.sheet.getCell(args.row, args.col).value(newval);
         if (args.sheetName == 'ration_glj') {
@@ -753,29 +756,6 @@ var gljOprObj = {
         return data;
 
     },
-   /* testMaterialRationFee:function () {
-        let freightID = "8db5ff10-f495-11e9-bbf9-ef28356eebc5";
-        let rationID = "da995300-05f1-11ea-8265-63369b476c76";
-        let proGLJ =  projectObj.project.projectGLJ;
-        let freightList =  proGLJ.datas.freightList;
-        let calcOptions=projectObj.project.projectInfo.property.calcOptions;
-        let decimalObj = projectObj.project.projectInfo.property.decimal;
-        let labourCoeDatas =  projectObj.project.labourCoe.datas;
-        for(let f of freightList){
-            if(f.ID == freightID){
-                let r = null;
-                let ration_gljs = [];
-                for(let ration of f.rations){
-                    if(ration.ID == rationID) r = ration;
-                }
-                for(let rg of f.ration_gljs){
-                    if(rg.rationID == rationID) ration_gljs.push(rg);
-                }
-                gljUtil.setMaterialCalcRationFee(r,ration_gljs,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,_,scMathUtil)
-                console.log(r);
-            }
-        }
-    },*/
 
     getBasePrice:function (treeNode) {//造价书中的工料机修改的节点要用到
         let proGLJ =  projectObj.project.projectGLJ;
@@ -1004,7 +984,7 @@ var gljOprObj = {
             : me.stdGLJ;
         if ($('#actionType').val() == 'replace' || $('#actionType').val() == 'm_replace') {
             me.filterLibGLJByType();
-        }else if($('#actionType').val() == 'addMix'){
+        }else if($('#actionType').val() == 'addMix' || $('#actionType').val() =='unitPriceAddMix'){
             projectGljObject.filterLibGLJForMixRatio();
         }
         //文本筛选
@@ -1027,7 +1007,7 @@ var gljOprObj = {
         }
     },
     setGLJSelection: function (args, newVal) {
-        if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert'|| $('#actionType').val() == 'insertEquipment' || $('#actionType').val() == 'addMix') {
+        if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert'|| $('#actionType').val() == 'insertEquipment' || $('#actionType').val() == 'addMix'|| $('#actionType').val() == 'unitPriceAddMix') {
             this.addGLJsSelection(args, newVal);
         } else {
             this.replaceGLJSelection(args, newVal);
@@ -1569,7 +1549,9 @@ $(function () {
     });
     // 更改选择库
     $('#glj-lib-select').change(function () {
-        getGLJData('change', false);
+        let getLibFun = null;
+        if(typeof unitPriceObj !='undefined') getLibFun = unitPriceObj.getGLJLibData;
+        getGLJData('change', false,getLibFun);
     })
     /*    //工料机搜索
      $('#gljSearchKeyword').change(function () {
@@ -1603,6 +1585,8 @@ $(function () {
             gljOprObj.replaceGLJConfirm(true);
         }else if($('#actionType').val() == 'addMix'){
             projectGljObject.addMixRatio();
+        }else if($('#actionType').val() == 'unitPriceAddMix'){
+          unitPriceObj.addMixRatio();
         }
         $("#glj_tree_div").modal('hide');
     });

+ 5 - 3
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -392,7 +392,7 @@ var gljContextMenu = {
             gljOprObj.GLJSelection = [connect_key];
             selectMap[connect_key] = true;
             gljOprObj.filterLibGLJByType();
-        }else if($('#actionType').val() =='addMix'){//添加组成物
+        }else if($('#actionType').val() =='addMix'|| $('#actionType').val() =='unitPriceAddMix'){//添加组成物
             gljOprObj.GLJSelection = [];
             projectGljObject.filterLibGLJForMixRatio();
         }
@@ -446,6 +446,7 @@ function getActionUrl(actionType) {
     switch (actionType) {
         case 'add':
         case 'addMix':
+        case 'unitPriceAddMix':
         case 'insertEquipment':
             return `${rootUrl}/0/true`;
         case 'replace':
@@ -459,14 +460,15 @@ function getActionUrl(actionType) {
     }
 }
 
-function getGLJData(actionType, isInitial = true) {
+function getGLJData(actionType, isInitial = true,getLibFunc) {
     const url = getActionUrl(actionType);
     if (actionType === 'change') {
         actionType = $('#actionType').val();
     }
     $('#actionType').val(actionType);
     $.bootstrapLoading.start();
-    projectObj.project.ration_glj.getGLJData(url, function (result) {
+    if(!getLibFunc)getLibFunc = projectObj.project.ration_glj.getGLJData;
+    getLibFunc(url, function (result) {
         // 目前只有浙江2015需要特殊处理处理
         if (gljOprObj.sortSelectViewGLJ) {
             gljOprObj.sortSelectViewGLJ(result.datas.stdGLJ);

+ 36 - 28
web/building_saas/main/js/views/material_calc_view.js

@@ -46,7 +46,7 @@ materialCalcObj = {
             {headerName: "其它\n费用", headerWidth: 41, dataCode: "otherFee", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
             {headerName: "运价增\n加率(%)", headerWidth: 55, dataCode: "freightIncreaseRate", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
             {headerName: "加权\n系数", headerWidth: 41, dataCode: "weightCoe", hAlign: "right", dataType: "Number",validator:"number"},
-            {headerName: "计算式", headerWidth: 170, dataCode: "exp", hAlign: "left", dataType: "Number",getText:'forExp'},//,decimalField:"glj.unitPrice"
+            {headerName: "计算式", headerWidth: 170, dataCode: "exp", hAlign: "left", dataType: "String",getText:'forExp'},//,decimalField:"glj.unitPrice"
             {headerName: "计算方式", headerWidth: 80, dataCode: "calcType",visible: false, dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]}
         ],
         view: {
@@ -54,20 +54,12 @@ materialCalcObj = {
             rowHeaderWidth:25,
             colHeaderHeight:36
         },
-        getText:{
-            forExp:function (item) {
-                let material = materialCalcObj.getMaterialSelected();
-                if(gljUtil.isDef(item.materialType)&&item.materialType != ""){
-                  let uString = materialCalcObj.getNeiMengUnitFreightString(item.kmDistance,item.materialType);
-                  return `((${uString}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes})/1.09+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
-                }
-                //(单位运价×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
-                if(item.conveyance == "自办运输") return `(${item.unitFreight}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
+         getText:{
+          forExp:function (item) {
+             return _.isEmpty(item.exp)?materialCalcObj.getFreightEXP(item):item.exp;
+          }
+      }
 
-                //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
-                return `(${item.unitFreight}x${item.kmDistance}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
-            }
-        }
     },
     priceSpread:null,
     priceSheet:null,
@@ -458,6 +450,23 @@ materialCalcObj = {
          };
         return newData;
     },
+    getFreightEXP:function(obj,doc){
+      let item = _.clone(obj);
+      if(doc) gljUtil.setProperty(item,doc);
+      let material = materialCalcObj.getMaterialSelected();
+      if(gljUtil.isDef(item.materialType)&&item.materialType != ""){
+        let uString = materialCalcObj.getNeiMengUnitFreightString(item.kmDistance,item.materialType);
+        return `((${uString}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes})/1.09+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
+      }
+      //(单位运价×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
+      if(item.conveyance == "自办运输"){
+        let t = projectObj.project.projectGLJ.calcEachFreightOrPrice(item,"freight",{})
+        return t.doc.exp;
+      }
+
+      //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
+      return `(${item.unitFreight}x${item.kmDistance}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
+    },
     getSavedFreight:function (start,material) {
         let t = null;
         for(let f of this.userFreightList){
@@ -560,33 +569,32 @@ materialCalcObj = {
                     } else {
                         if(_.isEmpty(newData)) newData = me.getNewFreightData(material);
                         newData[dataCode] = value;
+                        newData.exp = this.getFreightEXP(newData);
                     }
                 } else {//修改
                     if (recode[dataCode] == value) continue;
                     doc[dataCode] = value;
                     if (dataCode == "conveyance") {//如果运输方式从自办运输切换成其它的东西时,要把底下挂的定额和定额工料机都清空
-                        if (recode[dataCode] == "自办运输") {//没改之前的值
-                            doc["rations"] = [];
-                            doc["ration_gljs"] = [];
-                        }
-                        if (value == "自办运输") {//当运输工具下拉选择“自办运输”时,“Km运距”、“装卸费单价”、“装卸次数”、“运价增加率(%)”列数据归0,且灰选不可编辑
-                            doc["kmDistance"] = '0';
-                            doc["unitLoadingFee"] = '0';
-                            doc["loadingTimes"] = '0';
-                            doc["freightIncreaseRate"] = '0';
-                        }
-                        if (recode[dataCode] == "汽车") doc["materialType"] = "";//当运输方式从汽车切换成其它方式时,清空材料类型
-
+                      if (recode[dataCode] == "自办运输") {//没改之前的值
+                          doc["rations"] = [];
+                          doc["ration_gljs"] = [];
+                      }
+                      if (value == "自办运输") {//当运输工具下拉选择“自办运输”时,“Km运距”、“装卸费单价”、“装卸次数”、“运价增加率(%)”列数据归0,且灰选不可编辑
+                          doc["kmDistance"] = '0';
+                          doc["unitLoadingFee"] = '0';
+                          doc["loadingTimes"] = '0';
+                          doc["freightIncreaseRate"] = '0';
+                      }
+                      if (recode[dataCode] == "汽车") doc["materialType"] = "";//当运输方式从汽车切换成其它方式时,清空材料类型
                     }
 
                     if (dataCode == "materialType" && value != "") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance, value);
                     if (dataCode == "kmDistance" && gljUtil.isDef(recode.materialType) && recode.materialType != "") doc["unitFreight"] = me.calcNeiMengUnitFreight(value, recode.materialType);
-
                     if (dataCode == "start") {
                         let t_f = me.getSavedFreight(value, material);
                         if (t_f) doc = t_f;
                     }
-
+                    doc.exp = this.getFreightEXP(recode,doc);                            
                 }
             }
             if (!_.isEmpty(newData)) addDatas.push(newData);

+ 6 - 6
web/building_saas/main/js/views/options_view.js

@@ -10,7 +10,7 @@ let optionsOprObj = {
         let me = this;
         me.options = projectOptins;
         let gOpts = me.options[me.optionsTypes.GENERALOPTS];
-        if(isDef(gOpts)){
+        if(gljUtil.isDef(gOpts)){
             for(let attr in gOpts){
                 me[attr].prop('checked', gOpts[attr]);
             }
@@ -24,19 +24,19 @@ let optionsOprObj = {
     },
     //更新optionsOprObj对象options数据
     updateOptions: function (options, updateObj) {
-        if(isDef(options[updateObj.type])){
+        if(gljUtil.isDef(options[updateObj.type])){
             options[updateObj.type][updateObj.opt] = updateObj.value;
         }
     },
     getOptsByType: function (options, type) {
-        return isDef(options[type]) ? options[type] : null;
+        return gljUtil.isDef(options[type]) ? options[type] : null;
     },
     getOption: function (type, optionName) {
-        if(!isDef(optionName)){
-            return isDef(this.options[type]) ? this.options[type] : null;
+        if(!gljUtil.isDef(optionName)){
+            return this.options&& gljUtil.isDef(this.options[type]) ? this.options[type] : null;
         }
         else {
-            return isDef(this.options[type][optionName])
+            return this.options&&gljUtil.isDef(this.options[type][optionName])
                 ? this.options[type][optionName]
                     : optionName === this.optionsTypes.GENERALOPTS
                     ? true

+ 93 - 51
web/building_saas/main/js/views/project_glj_view.js

@@ -159,21 +159,92 @@ projectGljObject={
             });
         }
     },
-    addMixRatio:function () {
-        let me = this, projectGLJ = projectObj.project.projectGLJ;
-        for(let mix of me.mixRatioData){
-            let m_key = gljOprObj.getIndex(mix, gljKeyArray);
-            let t_index = gljOprObj.GLJSelection.indexOf(m_key);
-            t_index != -1?gljOprObj.GLJSelection.splice(t_index,1):'';
-        }
-        projectGLJ.addMixRatio(gljOprObj.GLJSelection,function (mixRatios) {
-            me.showMixRatioData();//这里添加的组成物的消耗量默认都是0,所以对父工料机的价格不会有影响,不用触发计算
-            projectGLJ.loadData(function () {
-                me.showProjectGljData();
-                gljOprObj.showRationGLJSheetData();
-                me.onUnitFileChange(me.selectedProjectGLJ);
-            });
+    addMixRatio:async function () {
+      let me = this, projectGLJ = projectObj.project.projectGLJ;
+      for(let mix of me.mixRatioData){
+        let m_key = gljUtil.getIndex(mix);
+        _.remove(gljOprObj.GLJSelection,n =>{
+          return m_key == n;
+        });
+      }
+      await me.addMixRatioFromLib(gljOprObj.GLJSelection,()=>{
+        me.showMixRatioData();//这里添加的组成物的消耗量默认都是0,所以对父工料机的价格不会有影响,不用触发计算
+        projectGLJ.loadData(function () {
+            me.showProjectGljData();
+            gljOprObj.showRationGLJSheetData();
+            me.onUnitFileChange(me.selectedProjectGLJ);
         });
+      });
+    },
+    addMixRatioFromLib:async function(selections,callback){
+      let gljList = [],allGLJ = gljOprObj.AllRecode;
+      let url = "/glj/add-ratio";
+      let result = null;
+      if(selections.length == 0) {
+          return;
+      }
+      try {
+        for(let glj of allGLJ){
+        let i_key = gljUtil.getIndex(glj,gljLibKeyArray);
+        if(_.includes(selections,i_key)){
+            let pglj = {
+                glj_id: glj.ID,
+                name: glj.name,
+                code: glj.code,
+                original_code: glj.code,
+                unit: glj.unit,
+                specs: glj.specs,
+                base_price: glj.basePrice,
+                market_price: glj.basePrice,
+                shortName: glj.shortName,
+                type: glj.gljType,
+                model:glj.model,
+                adjCoe: glj.adjCoe,
+                from:'std',
+                repositoryId:glj.repositoryId,
+                materialType:glj.materialType,
+                materialCoe:glj.materialCoe,
+                grossWeightCoe:glj.grossWeightCoe,
+                purchaseStorageRate:glj.purchaseStorageRate,
+                offSiteTransportLossRate:glj.offSiteTransportLossRate,
+                handlingLossRate:glj.handlingLossRate
+            };
+            if(typeof projectObj !== 'undefined')  pglj.project_id = projectObj.project.ID();
+            if (glj.hasOwnProperty("compilationId")) {
+                pglj.from = "cpt";
+                if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
+                    pglj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
+                }
+            }
+            gljList.push(pglj);
+          }
+        }
+        gljList = _.sortByAll(gljList, ['type', 'code']);
+        if(gljList.length == 0) return;
+        let parentInfo ={};
+        if(typeof unitPriceObj !== 'undefined'){
+          url = "/unitPrice/addMixRatio";
+          pdata = unitPriceObj.getSelectedUnitPrice();
+          parentInfo = {
+            unit_price_file_id:pdata.unit_price_file_id,
+            connect_key:gljUtil.getIndex(pdata)
+          };
+        }else{
+          parentInfo = {
+            unit_price_file_id:projectObj.project.property.unitPriceFile.id,
+            connect_key:gljOprObj.getIndex(projectGljObject.selectedProjectGLJ,gljKeyArray)
+          };
+        }
+
+        $.bootstrapLoading.start();
+        result= await ajaxPost(url,{gljList:gljList,parentInfo:parentInfo})
+        if(callback) callback(result);
+      } catch (error) {
+        alert(error);
+        console.log(error);
+      }
+      $.bootstrapLoading.end();
+      return result;
     },
     getSelectedProjectGLJ:function () {
         let me = this,data = null;
@@ -389,14 +460,15 @@ projectGljObject={
         let me = projectGljObject;
         let canChange = true;
         let changeInfo=[];
-        if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
+       /*  if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
             info.newValue = 0;
             me.onMixRatioValueChange(sender,info);
             info.sheet.getCell(info.row, info.col).text(0);
             return ;
-        }
+        } */
         for(let c of info.changedCells){
             let value = info.sheet.getCell(c.row, c.col).text();
+            if(_.isEmpty(value)) value = 0;
             if (!me.checkData(c.col,me.mixRatioSetting,value)) {
                 alert('输入的数据类型不对,请重新输入!');
                 canChange = false;
@@ -405,12 +477,10 @@ projectGljObject={
                 changeInfo.push({row:c.row,col:c.col,value:value});
             }
         }
-        if(canChange == false){//数据类型不对
-            me.showMixRatioData();
-        }
-        if(changeInfo.length > 0){
-            me.batchUpdateConsumption(changeInfo);
-        }
+        if(canChange == false) me.showMixRatioData();//数据类型不对
+            
+        
+        if(changeInfo.length > 0)me.batchUpdateConsumption(changeInfo);
     },
     batchUpdateProjectGLJ:function(changeInfo,sheetName){
         let projectGLJ = projectObj.project.projectGLJ;
@@ -809,19 +879,6 @@ projectGljObject={
         }
         value = scMathUtil.roundToString(value,getDecimal("glj.quantity"));
         me.batchUpdateConsumption([{row:row,col:col,value}]);
-        //changeInfo.push({row:c.row,col:c.col,value:value});
-      /*  let [parentMarketPrice, parentBasePrice] = me.getCompositionSumPrice('modify', row, value);
-        let updateData ={id: recode.mix_ratio_id, field: 'mix_ratio.' + dataCode, value: value, market_price: parentMarketPrice};//, base_price: parentBasePrice ---20190218 修改机械台班的组成物,仅重新计算机械预算价,定额价保持不变。
-        let prow = parentSheet.getActiveRowIndex();//取父机械或组成物的下标
-        let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
-        composition.updateConsumption(updateData,recode,prowData.id,function (sid) {
-            /!* if(parentSheet.name() == 'projectGljSheet'){ 之前是单行刷新,父工料机与组成物对应的工料机分开刷,发现这样比整个刷新慢所以先整个刷新,当以后数据量大的时候再测试
-             me.refreshProjectGljRowByID(sid);
-             }*!/
-            projectObj.project.projectGLJ.calcQuantity();
-            me.refreshParentData(prow,prowData.id,sid);
-            me.onUnitFileChange(recode);
-        });*/
     },
     onUnitFileChange:function (isInclude,changeMark = 'unitFile') { //include用来标计是否排除本身, true时,不排除本身
         if(isInclude == true) projectObj.project.projectInfo.changeMark = changeMark; //项目单价文件修改标记
@@ -838,6 +895,7 @@ projectGljObject={
         let updateData = {id: deleteRecode.mix_ratio_id, field: 'mix_ratio.consumption' , value: 0, market_price: parentMarketPrice, base_price: parentBasePrice};
         let ext = {};
         ext[prowData.id] = {marketPrice:parentMarketPrice};
+        updateData.parent = {query:{id:prowData.unit_price.id},doc:{market_price: parentMarketPrice}}
         let elecP = electrovalenceObj.clacNewElecPrice(ext);
         if(elecP){
             updateData.unitPrice = {projectGLJID:elecP.projectGLJID,query:{id:elecP.id},doc:elecP.doc};
@@ -971,22 +1029,6 @@ projectGljObject={
     },
     checkData : function(col,setting, value) {
         return sheetCommonObj.checkData(col,setting, value);
-        /*   let result = true;
-         let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
-         if (validator === null) {
-         return result;
-         }
-         switch (validator) {
-         case 'number':
-         let regular = /^\d+(\.\d+)?$/;
-         result = regular.test(value);
-         break;
-         case 'boolean':
-         let booleanValue = [true, false];
-         result = booleanValue.indexOf(value) >= 0;
-         break;
-         }
-         return result;*/
     },
     getProjectGLJSelected:function () {
         let me = projectGljObject;

+ 64 - 2
web/building_saas/unit_price_file/index.html

@@ -40,6 +40,7 @@
   let unitPriceList = JSON.parse(`<%- unitpriceList %>`);
   let gljTypeMap = JSON.parse(`<%- gljTypeMap %>`);
   let mixRatioMap = JSON.parse(`<%- mixRatioMap %>`);
+  let com_electrovalence = JSON.parse(`<%- com_electrovalence %>`);
 </script>
 <body oncontextmenu="return false;">  <!--屏蔽input鼠标右键-->
 <!--<div id="toolToastWrap" style="left: 20px; right: 30px; position: fixed; z-index: 10001; top: 100px;">
@@ -106,7 +107,61 @@
         </div>
     </div>
    
-
+  <!--工料机选择窗口-->
+  <div class="modal fade" id="glj_tree_div" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document" id="modalCon">
+        <div class="modal-content" style="width: 1020px; left:50%; transform: translate(-50%,0%);">
+            <div class="modal-header">
+                <h5 class="modal-title">请选择工料机</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+                <input type="hidden" id="actionType">
+            </div>
+            <div class="modal-body" style="padding-left: 0; padding-right: 3px; margin-left: 0;">
+                    <div style="width: 32%; float: left;">
+                        &nbsp;
+                        <select class="form-control  form-control-sm form-control-inline" id="glj-lib-select">
+                        </select>
+<!--                            <input type="radio" class="glj-radio" name="glj" value="stdGLJ">标准&nbsp;&nbsp;
+                        <input type="radio" class="glj-radio" name="glj" value="complementaryGLJs">补充&nbsp;&nbsp; -->
+                        <div  class="modal-auto-height" id="componentTreeDiv" style=" height: 435px; overflow: hidden;">
+                            <!--<div class="print-list">-->
+                            <div style="width: 100%; height: 100%; overflow: auto">
+                                <ul id="gljTree" class="ztree"></ul>
+                            </div>
+                            <!--</div>-->
+                        </div>
+                    </div>
+                    <div style="width:67%; padding-left: 3px; float: left;">
+                        <div id="gljRadios">
+                            <div class="row">
+                                <div class="col-7" style="margin-top: 5px;">
+                                    <!--<input type="radio" class="glj-radio" name="glj" value="allGljs" checked>所有&nbsp;&nbsp;
+                                    <input type="radio" class="glj-radio" name="glj" value="stdGLJ">标准&nbsp;&nbsp;
+                                    <input type="radio" class="glj-radio" name="glj" value="complementaryGLJs">补充&nbsp;&nbsp;-->
+                                </div>
+                                <div class="input-group col-5" style="margin-bottom: 5px;">
+                                    <input type="text" class="form-control form-control-sm" placeholder="请输入筛选编码或名称" value="" id="gljSearchKeyword">
+                                    <!--  <span class="input-group-btn"><button class="btn btn-secondary btn-sm" type="button" id="gljSearch"><i class="fa fa-search" aria-hidden="true"></i></button></span>-->
+                                </div>
+                            </div>
+                            <!-- <div class="form-group"><input id="searchGlj" type="text" class="form-control-sm" placeholder="查询工料机"></div>-->
+                        </div>
+                        <div class="modal-auto-height" style="overflow: hidden;height: 420px" id="gljLibSheet">
+
+                        </div>
+                    </div>
+              </div>
+              <div class="modal-footer" style="position: relative;">
+                  <a href="/complementaryGlj" target="_blank" class="btn btn-primary" style="position: absolute; left: 20px">新增人材机</a>
+                  <a href="javascript:void(0);" id="glj_selected_conf" class="btn btn-primary">确定</a>
+                  <a href="javascript:void(0);" id="replace_next_btn" class="btn btn-primary">下一步</a>
+                  <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
+              </div>
+          </div>
+      </div>
+  </div>
    
  
    
@@ -152,11 +207,18 @@
     <script type="text/javascript" src="/public/web/common_ajax.js"></script>
     <script type="text/javascript" src="/public/common_util.js"></script>
     <script src="/public/common_constants.js"></script>
+    <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
+    <script type="text/javascript" src="/public/web/ztree_common.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>
     <script type="text/javascript" src="/lib/jquery-editable-select/jquery.editable-select.min.js"></script>
     <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
     <script type="text/javascript" src="/public/web/sheet/sheet_data_helper.js"></script>
     <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
-
+    <script type="text/javascript" src="/public/web/slideResize.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view_contextMenu.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/options_view.js"></script>
+    <script type="text/javascript" src='/web/building_saas/main/js/views/project_glj_view.js'></script>
 
 
     <script type="text/javascript" src="/web/building_saas/unit_price_file/index.js"></script>

+ 332 - 23
web/building_saas/unit_price_file/index.js

@@ -1,6 +1,7 @@
 
 let unitPriceObj = {
   unitPriceMap:{},
+  selectedData : null,
   setUntiPriceMap:function(){
     for(let u of unitPriceList){
       this.unitPriceMap[gljUtil.getIndex(u)] = u;
@@ -16,10 +17,10 @@ let unitPriceObj = {
         {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
         {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//decimalField:'glj.unitPrice',
         {headerName: "预算价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
-        {headerName: "是否新增", headerWidth: 50, dataCode: "is_add", hAlign: "center", dataType: "String",cellType:'checkBox'}
+        {headerName: "是否\n新增", headerWidth: 50, dataCode: "is_add", hAlign: "center", dataType: "String",cellType:'checkBox'}
     ],
     view: {
-        lockColumns: ["code","name","specs","unit","short_name","basePrice","is_add"],
+        lockColumns: ["code","name","specs","unit","short_name","basePrice"],
         colHeaderHeight:36
     },
     getStyle:function (data,row,activeRow) {
@@ -42,7 +43,7 @@ let unitPriceObj = {
         {headerName: "消耗量", headerWidth: 80, dataCode: "consumption", hAlign: "right", dataType: "Number",validator:"number",tofix:3}
     ],
     view: {
-        lockColumns: [0,1,2,3,4,5,6,7],
+        lockColumns: [0,1,2,3,4,5,6],
         rowHeaderWidth: 25
     }
   },
@@ -55,17 +56,13 @@ let unitPriceObj = {
     this.mainSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMainSelectionChange);
     this.mainSpread.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMainRangeChange);
     this.mainSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMainValueChange);
-    // this.sheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onElectrovalenceEditStarting);
-
-    /* if(projectReadOnly){
-        disableSpread(this.spread);
-    } */
+    this.mainSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onMainEditStarting);
   },
   showMainDatas:function(){
     unitPriceList = gljUtil.sortProjectGLJ(unitPriceList);
     this.setData(unitPriceList);
     let sel = this.mainSheet.getSelections()[0];
-    let oldData = sel.row<unitPriceList.length?unitPriceList[sel.row]:"";
+    let oldData = this.selectedData;
     sheetCommonObj.showData(this.mainSheet, this.mainSetting,unitPriceList);
     this.mainSheet.setRowCount(unitPriceList.length);
     sel.row =  oldData?_.findIndex(unitPriceList,{'id':oldData.id}):sel.row ;
@@ -116,6 +113,7 @@ let unitPriceObj = {
         let tstyle = me.getSelStyle(false,{},unitPriceList[orow].bgColour);
         args.sheet.setStyle(orow, -1, tstyle);
         me.showSubDatas();
+        me.selectedData = unitPriceList[newSel.row];
       }
     }else{
       args.sheet.repaint();
@@ -124,6 +122,31 @@ let unitPriceObj = {
     args.sheet.resumePaint();
 
   },
+  onMainEditStarting:function(sender, args){
+    let me = unitPriceObj;
+    let row = args.row;
+    let col = args.col;
+    if(me.mainEditChecking(row,col)==false){
+        args.cancel = true;
+    }
+  },
+  mainEditChecking:function(row,col,isPaste=false){
+    let me = unitPriceObj;
+    if(row>=unitPriceList.length) return false;
+    let data = unitPriceList[row];
+    let setting = me.mainSetting;
+    let dataCode = setting.header[col].dataCode;
+    if(isPaste == false &&dataCode=='is_add'){//除了粘贴,拖动填充等操作,其它的都不能编辑
+      return false;
+    }
+    if(dataCode=='marketPrice'){
+      if(gljUtil.isConcreteType(data.type)) return false;//混凝土,浆砂,配合比,不能修改市场单价,定额价
+      let uindex = gljUtil.getIndex(data);
+      if(mixRatioMap[uindex] && mixRatioMap[uindex].length > 0) return false;//有组成物的不能编辑
+      if(data.calcMaterial == 1) return false //有材料计算时不能修改
+    }
+    return true;
+  },
   onMainValueChange:function(e,info){
     let me = unitPriceObj;
     let value = info.newValue;
@@ -135,14 +158,18 @@ let unitPriceObj = {
       return me.showMainDatas();
     }
     me.batchUpdateUnitPrice([{row:info.row,col:info.col,value:value}]);
-
   },
   onMainRangeChange:function(sender,info){
     let me = unitPriceObj;
     let canChange = true;
+    let changeInfo = [];
     for(let c of info.changedCells){
       let value=  info.sheet.getCell(c.row, c.col).text();
       changeInfo.push({row:c.row,col:c.col,value:value});
+      if(me.mainEditChecking(c.row,c.col,true)==false){//如果不能编辑
+        canChange = false;
+        break;
+      }
       if (!sheetCommonObj.checkData(c.col,me.mainSetting,value)) {
           alert('输入的数据类型不对,请重新输入!');
           canChange = false;
@@ -161,22 +188,42 @@ let unitPriceObj = {
       for(let ci of changeInfo){
         let dataCode = me.mainSetting.header[ci.col].dataCode;
         let recode = unitPriceList[ci.row];
+        let ndata = newValueMap[recode.id]?newValueMap[recode.id]:{unit_price:recode};
         if(dataCode=='basePrice'||dataCode=='marketPrice'){
             let editField = dataCode === 'basePrice'?"base_price":"market_price";
             let newValue = ci.value;
             if(recode && recode[editField]!=newValue){
-                newValue= scMathUtil.roundForObj(ci.value,3);
-                updateData.push({unit_price: recode, field: editField, newval: newValue});
-                newValueMap[recode.id]={field:editField,value:newValue};
-                refreshList.push(recode);
+                newValue= scMathUtil.roundForObj(ci.value,3); 
+                ndata['field'] = editField;
+                ndata['newval'] = newValue;
+                newValueMap[recode.id]=ndata;
             }
+        }else{
+          let ext = {};
+          if(dataCode === 'is_add'){
+            value = ci.value == true?1:0;
+          }
+          ext[dataCode] = value;
+          ndata['ext'] = ext;
+          newValueMap[recode.id]=ndata;
         }
       }
+      for(let key in newValueMap){
+        updateData.push(newValueMap[key]);
+        refreshList.push(newValueMap[key].unit_price)
+      }
       if(updateData.length > 0){
         $.bootstrapLoading.start();
         let result = await ajaxPost("/glj/batchUpdatePrices",updateData);
         for(let r of refreshList){
-           r[newValueMap[r.id].field] = newValueMap[r.id].value;
+          let rdata = newValueMap[r.id];
+          if(rdata.field) r[rdata.field] = rdata.newval;
+          if(rdata.ext){
+            for(let ekey in rdata.ext){
+              r[ekey] = rdata.ext[ekey];
+            }
+          }
+           
         }
         for(let r of result){
           let pdata = r.updateOne.filter;
@@ -188,10 +235,11 @@ let unitPriceObj = {
         }
       }
     } catch (error) {
+        console.log(error);
         alert(error);
     }
     $.bootstrapLoading.end();
-    me.showMainDatas();
+    me.onUnitPriceChange();
 
   },
 
@@ -201,13 +249,9 @@ let unitPriceObj = {
     sheetCommonObj.spreadDefaultStyle(this.subSpread);
     this.subSheet = this.subSpread.getSheet(0);
     sheetCommonObj.initSheet(this.subSheet, this.subSetting, 30);
-    // this.sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onElectrovalenceSelectionChange);
-    // this.sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onElectrovalenceValueChange);
-    // this.sheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onElectrovalenceEditStarting);
-
-    /* if(projectReadOnly){
-        disableSpread(this.spread);
-    } */
+    this.subSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onSubRangeChange);
+    this.subSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSubValueChange);
+    this.initSubRightClick();
   },
   showSubDatas:function(){
     let parentData = this.getSelectedUnitPrice();
@@ -220,6 +264,182 @@ let unitPriceObj = {
     this.subSheet.setRowCount(this.mixRatioList.length);
     this.subSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
   },
+  onSubValueChange:function(sender,info){
+    let me = unitPriceObj;
+    let value = info.newValue;
+    if(info.newValue === undefined){
+      return;
+    }
+    if(value && !sheetCommonObj.checkData(info.col,me.mainSetting,value)) {
+      alert('输入的数据类型不对,请重新输入!');
+      return me.showMainDatas();
+    }
+    me.batchUpdateConsumption([{row:info.row,col:info.col,value:value}]);
+    
+  },
+  onSubRangeChange:function(sender,info){
+    let me = unitPriceObj;
+    let changeInfo=[];
+    let canChange = true;
+    for(let c of info.changedCells){
+      let value = info.sheet.getCell(c.row, c.col).text();
+      if(_.isEmpty(value)) value = 0;
+      if (!sheetCommonObj.checkData(c.col,me.subSetting,value)) {
+          alert('输入的数据类型不对,请重新输入!');
+          canChange = false;
+          break;
+      }else {
+          changeInfo.push({row:c.row,col:c.col,value:value});
+      }
+    }
+    if(canChange == false) me.showSubDatas();
+    me.batchUpdateConsumption(changeInfo);
+  },
+  calcParentPrice:function(list,updateMap,deleteID){
+    let parentMarketPrice = 0;
+    for(let sub of list){
+      if(deleteID && sub.id == deleteID) continue
+      let marketPrice = scMathUtil.roundForObj(sub.marketPrice,6);
+      let basePrice = scMathUtil.roundForObj(sub.basePrice,6);
+      let consumption =  updateMap[sub.id]?updateMap[sub.id].consumption:scMathUtil.roundForObj(sub.consumption,3);
+      parentMarketPrice = scMathUtil.roundForObj(marketPrice*consumption + parentMarketPrice,6);
+     // parentBasePrice = scMathUtil.roundForObj(basePrice*consumption + parentBasePrice,getDecimal("process"));
+    }
+    parentMarketPrice = scMathUtil.roundForObj(parentMarketPrice,2);
+    return parentMarketPrice;
+  },
+
+  deleteMixRatio:async function(row){
+    let me = this, deleteRecode = me.mixRatioList[row];
+    let parentMarketPrice = me.calcParentPrice(me.mixRatioList,{},deleteRecode.id);
+    let parentData = me.getSelectedUnitPrice();
+    let updateData = {id: deleteRecode.id,connect_key:gljUtil.getIndex(parentData)};
+    let ext = {};
+    ext[parentData.id] = {marketPrice:parentMarketPrice};
+    updateData.parent = {connect_key:gljUtil.getIndex(parentData),query:{id:parentData.id},doc:{market_price: parentMarketPrice}};
+    if(com_electrovalence){ //计算综合电价
+      let elecP = me.clacNewElecPrice(ext);
+      if(elecP) updateData.unitPrice = {connect_key:elecP.connect_key,query:{id:elecP.id},doc:elecP.doc};
+    }
+    try {
+      $.bootstrapLoading.start();
+      await ajaxPost("/glj/delete-ratio",{id: updateData.id,parent:updateData.parent,unitPrice:updateData.unitPrice});
+      let mlist =  mixRatioMap[updateData.connect_key];
+      _.remove(mlist,{id:updateData.id});
+      if(updateData.parent){
+        let pglj = me.unitPriceMap[updateData.parent.connect_key];
+        if(pglj) gljUtil.setProperty(pglj,updateData.parent.doc);
+      }
+      if(updateData.unitPrice){
+        let eglj = me.unitPriceMap[updateData.unitPrice.connect_key];
+        if(eglj) gljUtil.setProperty(eglj,updateData.unitPrice.doc);
+      }
+
+    } catch (error) {
+      alert(error);
+      console.log(error);
+    }
+
+    $.bootstrapLoading.end();
+    me.onUnitPriceChange();
+  },
+  batchUpdateConsumption:async function(changeInfo){
+    let me = unitPriceObj;
+    let updateMap = {},updateData = [],parentBasePrice = 0,parentMarketPrice = 0;
+    let parentKey = '',unit_price_file_id=null;
+    for(let c of changeInfo){
+      let record = me.mixRatioList[c.row];
+      let value =  scMathUtil.roundForObj(c.value,3);
+      updateMap[record.id] = {consumption: value,record:record};
+      updateData.push({type:'mix_ratio',connect_key:record.connect_key,query:{id:record.id},doc:{consumption:scMathUtil.roundToString(value,3)}});
+      parentKey = record.connect_key;
+      unit_price_file_id = record.unit_price_file_id;
+    }
+    if(!gljUtil.isConcreteType(parseInt(parentKey.split("|-|")[4]))){//父类型不属于混凝土浆砂配合比,才要计算
+      parentMarketPrice = me.calcParentPrice(me.mixRatioList,updateMap);
+    }
+    let parentData = me.getSelectedUnitPrice();
+    if(parentData){
+      let ext = {};
+      ext[parentData.id] = {marketPrice:parentMarketPrice};
+      if(com_electrovalence){ //计算综合电价
+        let elecP = me.clacNewElecPrice(ext);
+        if(elecP){
+          updateData.push({type:'unitPrice',connect_key:elecP.connect_key,query:{id:elecP.id},doc:elecP.doc});
+        }
+      }
+      updateData.push({type:'unitPrice',connect_key:gljUtil.getIndex(parentData),query:{id:parentData.id},doc:{market_price:parentMarketPrice}});
+    }
+    if(updateData.length > 0){
+      try {
+        $.bootstrapLoading.start();
+        let result = await ajaxPost("/glj/batchUpdateConsumption",updateData);
+        for(let up of updateData){
+          if(up.type == 'unitPrice'){
+            let nu = me.unitPriceMap[up.connect_key];
+            if(nu) gljUtil.setProperty(nu,up.doc);
+          }else{
+            let nlist = mixRatioMap[up.connect_key];
+            for(let nc of nlist){
+                if(nc.id == up.query.id){
+                  gljUtil.setProperty(nc,up.doc);
+                }
+            } 
+          }
+        }
+      } catch (error) {
+        alert(error);
+        console.log(error);
+      }
+    }
+    $.bootstrapLoading.end();
+    me.onUnitPriceChange();
+  },
+  clacNewElecPrice:function(ext){
+    for(let u of unitPriceList){
+      if(u.code == gljUtil.getElecCode() && u.name == "电" && u.unit == "kW·h"){//更新电价
+        let datas  = this.getElectrovalenceDatas(ext);
+        if(datas.length > 0){
+            let marketPrice = this.calcPertElectrovalenceMarketPrice(datas,ext);
+            if(marketPrice && u.market_price != marketPrice+'') return {id:u.id,'unit_price_file_id':u.unit_price_file_id,'connect_key':gljUtil.getIndex(u),doc:{'market_price':marketPrice+''}}
+        }
+      }
+    }
+    return null;
+  },
+
+  calcPertElectrovalenceMarketPrice:function (datas,ext) {
+    let total = 0;
+    for(let d of datas){
+        if(ext && ext[d.uid] && gljUtil.isDef(ext[d.uid].marketPrice)) d.marketPrice = ext[d.uid].marketPrice;
+        if(d.name == "电网电"){
+            d.electPrice = d.marketPrice;
+        }else {
+            let w = parseInt(d.name);
+            if(!w) continue;
+            let t = scMathUtil.roundForObj(d.marketPrice/w,6);
+            d.electPrice = scMathUtil.roundForObj(t * gljUtil.getElecCoe(),2);
+        }
+        let et = scMathUtil.roundForObj(d.electPrice * d.coe,6);
+        total = scMathUtil.roundForObj(et + total,6);
+    }
+    this.total = scMathUtil.roundForObj(total,2);
+    return this.total;
+},
+  getElectrovalenceDatas:function(ext){
+    let datas = [];
+    if(com_electrovalence && com_electrovalence.gljList){
+      for(let g of com_electrovalence.gljList){
+        let u = unitPriceMap[gljUtil.getIndex(g)]
+        if(u){
+          g.uid = u.id;
+          g.basePrice = this.getPrice("base_price",u);
+          g.marketPrice = this.getPrice("market_price",u);
+          datas.push(g);
+        }
+      }
+    }
+  },
   setMixRatioData:function(mixRatioList){
     for(let m of mixRatioList){
       m.short_name = this.getShortNameByType(m.type);
@@ -270,6 +490,94 @@ let unitPriceObj = {
     style.backColor = selected ? selectedColor : recColor;
     return style;
   },
+  initSubRightClick:function(){
+    let me = this;
+    $.contextMenu({
+      selector: '#subSpread',
+      build: function ($trigger, e) {
+          me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.subSpread);
+          return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
+              me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
+      },
+      items: {
+          "deleteMixRatio": {
+              name: "删除",
+              icon: 'fa-trash-o',
+              disabled: function () {
+                  return me.rightClickTarget.row === undefined;
+              },
+              callback: function (key, opt) {
+                  let row = me.rightClickTarget.row;
+                  me.deleteMixRatio(row);
+              },
+              visible: function(key, opt){
+                  let projectGLJ = me.getSelectedUnitPrice();
+                  return  projectGLJ && !gljUtil.isConcreteType(projectGLJ.type);
+              }
+          },
+          "addMixRatio":{
+              name: '添加',
+              icon: 'fa-sign-in',
+              disabled: function () {
+                let projectGLJ = me.getSelectedUnitPrice();
+                return !_.includes(compositionTypes,projectGLJ.type);
+              },
+              callback: function (key, opt) {
+                   projectGljObject.selectedProjectGLJ = me.getSelectedUnitPrice();
+                   getGLJData('unitPriceAddMix',true,me.getGLJLibData);
+              },
+              visible: function(key, opt){
+                  let projectGLJ = me.getSelectedUnitPrice();
+                  return  projectGLJ && !gljUtil.isConcreteType(projectGLJ.type);
+              }
+          }
+      }
+     });
+  },
+  addMixRatio:async function(){
+     let me = this;
+    for(let mix of me.mixRatioList){
+      let m_key = gljUtil.getIndex(mix);
+      _.remove(gljOprObj.GLJSelection,n =>{
+        return m_key == n;
+      });   
+    }
+
+    let result = await projectGljObject.addMixRatioFromLib(gljOprObj.GLJSelection)
+    if(result.mixRatios && result.mixRatios.length > 0){
+      let mList = mixRatioMap[result.mixRatios[0].connect_key];
+      if(mList){
+        mixRatioMap[result.mixRatios[0].connect_key] = mixRatioMap[result.mixRatios[0].connect_key].concat(result.mixRatios);
+      }
+    }
+    for(let u of result.newUnitPriceList){
+      me.unitPriceMap[gljUtil.getIndex(u)] = u;
+      unitPriceList.push(u);
+    }
+    me.onUnitPriceChange();
+  },
+
+  onUnitPriceChange:function(){
+    unitPriceObj.showMainDatas();
+    unitPriceObj.showSubDatas();
+  }, 
+  getGLJLibData : function (url, cb) {
+    //let property = projectObj.project.projectInfo.property;
+    //let engineerID = property.engineering_id;
+    CommonAjax.get(url, function (data) {
+        //编办中有多单价设置
+        if(data.datas.priceProperties && data.datas.priceProperties.length > 0){
+            let tem = _.find(data.datas.priceProperties,{region:property.region,taxModel:parseInt(property.taxType)});
+            if(tem){
+                let dataCode = tem.price.dataCode;
+                for(let glj of data.datas.stdGLJ){
+                    if(glj.priceProperty && gljUtil.isDef(glj.priceProperty[dataCode])) glj.basePrice = glj.priceProperty[dataCode];
+                }
+            }
+        };
+        cb(data);
+    })
+  }
 }
 
 
@@ -285,6 +593,7 @@ function initPage(){
   unitPriceObj.initMainSpread();
   unitPriceObj.initSubSpread();
   unitPriceObj.showMainDatas();
+  unitPriceObj.showSubDatas();
 }
 
 unitPriceObj.setUntiPriceMap();

+ 3 - 0
web/over_write/js/zhejiang_2005.js

@@ -310,6 +310,9 @@ if (typeof materialCalcObj !== 'undefined') {
     materialCalcObj.getAssistProductionLabel = function () {
         return "辅助生产现场经费费率(%)";
     }
+    gljUtil.getAssUsedPrice = function(g){
+      return g.marketPrice;
+    }
 }
 
 if (typeof projectObj !== 'undefined') {