Преглед изворни кода

bugs + 综合电价相关功能

zhangweicheng пре 6 година
родитељ
комит
cbbca6f7f1

+ 26 - 0
modules/glj/controllers/glj_controller.js

@@ -431,6 +431,32 @@ class GLJController extends BaseController {
        response.json(result);
    }
 
+    async insertElectrovalence(request, response){
+        let result={error:0};
+        try {
+            let data = JSON.parse(request.body.data);
+            result.data = await glj_facade.insertElectrovalence(data,request.session.sessionCompilation._id);
+        }catch (err){
+            logger.err(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+
+    async updateElectrovalence(request, response){
+        let result={error:0};
+        try {
+            let data = JSON.parse(request.body.data);
+            result.data = await glj_facade.updateElectrovalence(data);
+        }catch (err){
+            logger.err(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+
     async updateUserFreight(request, response){
         let result={error:0};
         try {

+ 1 - 22
modules/glj/models/unit_price_file_model.js

@@ -40,26 +40,6 @@ class UnitPriceFileModel extends BaseModel {
     }
 
     /**
-     * 新增单价文件
-     *
-     * @param {object} data
-     * @return {Promise}
-     */
-    async add(data) {
-        let result = false;
-        try {
-            if (Object.keys(data).length <= 0) {
-                throw '数据为空';
-            }
-            result = await this.db.create(data);
-        } catch (error) {
-            result = false;
-        }
-
-        return result;
-    }
-
-    /**
      * 根据项目id获取单价文件数据
      *
      * @param {Number} projectId
@@ -102,7 +82,7 @@ class UnitPriceFileModel extends BaseModel {
     }
 
     /**
-     * 新增单条工料机数据
+     * 新增单价文件
      *
      * @param {object} data
      * @return {Promise}
@@ -115,7 +95,6 @@ class UnitPriceFileModel extends BaseModel {
         let counterModel = new CounterModel();
         data.id = await counterModel.getId(collectionName);
 
-        this.setScene('add');
         let result = await this.db.create(data);
         return result;
     }

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

@@ -416,13 +416,10 @@ class UnitPriceModel extends BaseModel {
     async copyNotExist(currentUnitPriceId, changeUnitPriceId,projectId) {
         let result = false;
         // 首先查找原单价文件id下的数据
-        let currentUnitList = await this.findDataByCondition({unit_price_file_id: currentUnitPriceId}, null, false);
+        let currentUnitList = await this.model.find({unit_price_file_id: currentUnitPriceId}).lean();
         if (currentUnitList === null) {
             return result;
         }
-        // 过滤mongoose格式
-        currentUnitList = JSON.stringify(currentUnitList);
-        currentUnitList = JSON.parse(currentUnitList);
 
         let gljList = await gljListModel.find({'project_id':projectId});
         let gljMap = {};//用来记录glj的映射表,本项目有使用的工料机才需要copy过去

+ 2 - 0
modules/glj/routes/glj_router.js

@@ -33,6 +33,8 @@ router.post('/changeVvTaxFile',gljController.init, gljController.changeVvTaxFile
 router.post('/changeAssistProductionFeeRate',gljController.init, gljController.changeAssistProductionFeeRate);
 router.post('/updateMaterialCalc',gljController.init, gljController.updateMaterialCalc);
 router.post('/updateMaterialCalcTasks',gljController.init, gljController.updateMaterialCalcTasks);
+router.post('/insertElectrovalence',gljController.init, gljController.insertElectrovalence);
+router.post('/updateElectrovalence',gljController.init, gljController.updateElectrovalence);
 router.post('/updateUserFreight',gljController.init, gljController.updateUserFreight);
 
 router.get('/getVvTaxList', gljController.init, gljController.getVvTaxList);

+ 42 - 3
public/web/gljUtil.js

@@ -5,11 +5,11 @@
 
 let gljUtil = {
     calcProjectGLJQuantity:function (projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal,_,scMathUtil,isTender) {
-        let project_gljs = projectGLJDatas.gljList;
-        let mixRatioMap = projectGLJDatas.mixRatioMap;
+        let project_gljs = projectGLJDatas.gljList, mixRatioMap = projectGLJDatas.mixRatioMap, com_electrovalence = projectGLJDatas.com_electrovalence;
         let rations = rationDatas;
         let rationMap = _.indexBy(rations,'ID');
         let quantityMap={};
+        let quanitytIDMap={};//以项目工料机的ID为Map;(给综合电价计算使用)
         let rationGljGroup = _.groupBy(rationGLJDatas,'projectGLJID');
         let IDarray =  this.getSubdivisionAndTechBillsLeavesID(billsDatas);//分别取分部分项和技术措施项目的所有叶子清单ID
         let billIDs = IDarray[0],tech_billIDS = IDarray[1];
@@ -19,6 +19,9 @@ let gljUtil = {
         let qField = isTender==true?"tenderQuantity":"quantity";
         let mField = "materialQuantity"; //材料计算的工料机消耗量
 
+        let elecIndex = "";//记住电的标识
+
+
         for(let pglj of project_gljs ){
             let pg_index = this.getIndex(pglj,this.gljKeyArray);
             pglj[qField] = 0;
@@ -27,6 +30,8 @@ let gljUtil = {
             let result = this.getQuantityPerGLJ(gljGroup,rations,rationMap,pglj,billIDs,tech_billIDS,q_decimal,_,scMathUtil,isTender);
             pglj[qField] = result.quantity;
             quantityMap[pg_index] = pglj;
+            if(pglj.code == '3005002' && pglj.name == '电' && pglj.unit == "kW·h") elecIndex = pg_index;
+            if(com_electrovalence) quanitytIDMap[pglj.id] = pglj;
         }
         //计算做为组成物的消耗量
         for(let pkey in mixRatioMap){
@@ -61,6 +66,39 @@ let gljUtil = {
             }
         }
 
+        //计算综合电价中,电网电和机械台班的消耗量 - 电有可能做为组成物存在,计算综合电价的各消耗量时,要以电的总消耗量为基础,所以这步要放在最后,即电都计算完成以后
+        if(com_electrovalence && com_electrovalence.gljList && quantityMap[elecIndex]){
+            for(let cg of com_electrovalence.gljList){
+                //网电的消耗量=电的总消耗量×加权系数
+                let eq = scMathUtil.roundForObj(quantityMap[elecIndex][qField] * parseFloat(cg.coe),q_decimal);
+                if(cg.name == '电网电'){
+                    quanitytIDMap[cg.projectGLJID][qField] = eq;
+                }else {
+                    let tquantity = 0;
+                    let w = parseInt(cg.name);
+                    if(w) tquantity = scMathUtil.roundForObj(eq/w,6);
+                    tquantity = scMathUtil.roundForObj(tquantity * gljUtil.k,q_decimal);
+                    quanitytIDMap[cg.projectGLJID][qField] = tquantity;
+                    //计算机械台班下的组成物的消耗量
+                    let ckey = gljUtil.getIndex(quanitytIDMap[cg.projectGLJID]);
+                    if(mixRatioMap[ckey]){
+                        for(let m of mixRatioMap[ckey]){
+                            let cmkey = gljUtil.getIndex(m);
+                            if(quantityMap[cmkey] && tquantity > 0){//混凝土、砂浆、配合比组成物的消耗量在定额下已经有体现了,不用再计算进去
+                                let c_m_quantity = scMathUtil.roundForObj(tquantity * parseFloat(m.consumption),6);
+                                quantityMap[cmkey][qField] =  scMathUtil.roundForObj(parseFloat(quantityMap[cmkey][qField])+c_m_quantity,q_decimal);
+                            }
+                        }
+                    }
+                }
+            }
+
+
+
+        }
+
+
+
         //计算经过场外运输损耗后的总消耗量
         for(let pglj of project_gljs ){
             let offSiteTransportLossRate = this.getOffSiteTransportLossRate(pglj);
@@ -514,5 +552,6 @@ let gljUtil = {
     },
     hasCompMaterial:[202, 203, 204],//有组成物的材料
     hasCompMachine:[301],//有组成物的机械
-    machineComposition:[302,303]//可以做为机械组成物的类型
+    machineComposition:[302,303],//可以做为机械组成物的类型
+    k:0.15//电计算公式中的系数
 }

+ 2 - 2
web/building_saas/glj/html/project_glj.html

@@ -286,9 +286,9 @@
             <div class="modal-footer">
                 <div style="width: 70%">
                     <button type="button" class="btn btn-danger" id="removeElectrovalencec">删除</button>
-                    <label >综合电价:</label>
+                    <label id="electrovalenceLabel">综合电价:</label>
                 </div>
-                <button type="button" class="btn btn-primary" id="electrovalencecConfirm">确定</button>
+                <button type="button" class="btn btn-primary" data-dismiss="modal" id="electrovalencecConfirm">确定</button>
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
             </div>
         </div>

+ 60 - 4
web/building_saas/main/js/models/project_glj.js

@@ -706,6 +706,26 @@ ProjectGLJ.prototype.getUserFreights = async function () {//初始化车船税
     }
 };
 
+ProjectGLJ.prototype.refreshEctrovalenceCache = function (updateMap) {
+    let elec = updateMap["electrovalence"];
+    if(elec){
+        let actionType = elec.actionType;
+        if(actionType == "add"){
+            projectObj.project.projectGLJ.datas.com_electrovalence = elec.doc;
+        }else if(actionType == "update"){
+            projectObj.project.projectGLJ.datas.com_electrovalence.gljList = elec.doc.gljList;
+        }
+    }
+
+    if(updateMap["unitPrice"]) {
+        if(Array.isArray(updateMap["unitPrice"])){
+            this.m_updateUnitPrice(updateMap["unitPrice"]);
+        }else {
+            this.m_updateUnitPrice([updateMap["unitPrice"]]);
+        }
+    }
+};
+
 
 ProjectGLJ.prototype.refreshMaterialCalcCache = function (updateMap){
    if(updateMap["freight"]) updateList(this.datas.freightList,updateMap["freight"]);
@@ -866,11 +886,15 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
         for(let pg of this.datas.gljList){
             pgljMap[gljUtil.getIndex(pg)] = pg
         }
-        for(let g of temp.ration_gljs){
-            gljMap[g.rationID]?gljMap[g.rationID].push(g):gljMap[g.rationID]=[g];
+        if(temp.ration_gljs){
+            for(let g of temp.ration_gljs){
+                gljMap[g.rationID]?gljMap[g.rationID].push(g):gljMap[g.rationID]=[g];
+            }
         }
-        for(let r of temp.rations){
-            sum = scMathUtil.roundForObj(sum + calcRation(r,gljMap[r.ID],pgljMap,priceMap),6);
+        if(temp.rations) {
+            for(let r of temp.rations){
+                sum = scMathUtil.roundForObj(sum + calcRation(r,gljMap[r.ID],pgljMap,priceMap),6);
+            }
         }
         sum = scMathUtil.roundForObj(sum,decimal)+"";
         if(type == "freight" && temp.unitFreight!= sum) return {ID:temp.ID,doc:{unitFreight:sum}};
@@ -1649,4 +1673,36 @@ ProjectGLJ.prototype.calcTenderQuantity  = function (){
     let rationDatas = projectObj.project.Ration.datas;
     let billsDatas = projectObj.project.Bills.datas;
     gljUtil.calcProjectGLJQuantity(this.datas,rationGLJDatas,rationDatas,billsDatas,getDecimal("glj.quantity"),_,scMathUtil,true);
+};
+
+ProjectGLJ.prototype.loadNewProjectGLJToCaches = function (datas) {
+    for (let d of datas){
+        this.loadNewProjectGLJToCache(d);
+    }
+};
+
+ProjectGLJ.prototype.loadNewProjectGLJToCache = function (data) {//把新插入的项目工料机数据增加至缓存中
+    let project_gljs = this.datas.gljList;
+    let unitPriceMap = this.datas.unitPriceMap;
+    let mixRatioMap = this.datas.mixRatioMap;
+    let mixRatioConnectData = this.datas.mixRatioConnectData;
+    let tem =  _.find(project_gljs,{'id':data.id});
+    if(tem) return; //判断该工料机是否已经存在,是的话不用再次添加
+    //查看是否有组成物,有组成物的话先添加组成物信息
+    data.ratio_data=[];
+    if(data.subList && data.subList.length){
+        for(let s of data.subList){
+            let ratio = s.ratio_data;
+            data.ratio_data.push(ratio);
+            mixRatioMap[ratio.connect_key]?mixRatioMap[ratio.connect_key].push(ratio):mixRatioMap[ratio.connect_key] = [ratio];
+            let rIndex = gljUtil.getIndex(ratio);
+            mixRatioConnectData[rIndex]?mixRatioConnectData[rIndex].push(ratio.connect_key):mixRatioConnectData[rIndex] = [ratio.connect_key];
+            this.loadNewProjectGLJToCache(s);
+        }
+        delete data.subList;
+    }
+    //添加unitPriceMap
+    let uIndex = gljUtil.getIndex(data.unit_price);
+    if(!unitPriceMap[uIndex])  unitPriceMap[uIndex] = data.unit_price;
+    this.datas.gljList.push(data);
 };

+ 240 - 7
web/building_saas/main/js/views/electrovalence_view.js

@@ -6,9 +6,9 @@ let electrovalenceObj = {
         header:[
             {headerName: "代号", headerWidth: 70, dataCode: "code", dataType: "String"},
             {headerName: "名称", headerWidth: 150, dataCode: "name",dataType: "String"},
-            {headerName: "规格", headerWidth: 60, dataCode: "specs", dataType: "Number",validator:"number"},
-            {headerName: "预算价", headerWidth: 75, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},
-            {headerName: "加权系数", headerWidth: 60, dataCode: "coe", hAlign: "right", dataType: "Number",validator:"number"}
+            {headerName: "规格", headerWidth: 70, dataCode: "specs", dataType: "Number",validator:"number"},
+            {headerName: "预算价", headerWidth: 75, dataCode: "electPrice", hAlign: "right", dataType: "Number",validator:"number"},
+            {headerName: "加权系数", headerWidth: 80, dataCode: "coe", hAlign: "right", dataType: "Number",validator:"number"}
         ],
         view: {
             lockColumns: ["code","specs"],
@@ -19,25 +19,258 @@ let electrovalenceObj = {
     spread:null,
     sheet:null,
     datas:[],
+    total:0,
+    options:[
+        {code:"3005003",name:"电网电",specs:"",unit:"kW·h",type:"201"},
+        {code:"8017001",name:"5kW以内柴油发电机组",specs:"5GF1",unit:"台班",type:"301"},
+        {code:"8017002",name:"15kW以内柴油发电机组",specs:"12GF1",unit:"台班",type:"301"},
+        {code:"8017003",name:"30kW以内柴油发电机组",specs:"30GFY-2",unit:"台班",type:"301"},
+        {code:"8017004",name:"50kW以内柴油发电机组",specs:"50GFY-2",unit:"台班",type:"301"},
+        {code:"8017005",name:"75kW以内柴油发电机组",specs:"75GFY-4",unit:"台班",type:"301"},
+        {code:"8017006",name:"100kW以内柴油发电机组",specs:"90GFZ",unit:"台班",type:"301"},
+        {code:"8017007",name:"120kW以内柴油发电机组",specs:"120GFY-4",unit:"台班",type:"301"},
+        {code:"8017008",name:"160kW以内柴油发电机组",specs:"160GF",unit:"台班",type:"301"},
+        {code:"8017009",name:"200kW以内柴油发电机组",specs:"200GF",unit:"台班",type:"301"},
+        {code:"8017010",name:"250kW以内柴油发电机组",specs:"250GF4-4",unit:"台班",type:"301"},
+        {code:"8017011",name:"320kW以内柴油发电机组",specs:"320GF-2",unit:"台班",type:"301"}
+    ],
     initSpread:function () {
-        if(this.spread) return;
+        if(this.spread) return this.spread.refresh();
         this.spread = SheetDataHelper.createNewSpread($("#electrovalence_sheet")[0]);
         sheetCommonObj.spreadDefaultStyle(this.spread);
         this.sheet = this.spread.getSheet(0);
         sheetCommonObj.initSheet(this.sheet, this.setting, 30);
-    /*    this.materialSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMaterialValueChange);
-        this.materialSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMaterialSelectionChange);
-        this.materialSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onMaterialEditStarting);*/
+        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);
+    /*
+        ;*/
         this.sheet.name('electrovalence_sheet');
         if(projectReadOnly){
             disableSpread(this.spread);
         }
+    },
+    showDatas:function (datas) {
+        let sel = this.sheet.getSelections()[0];
+        let oldData = sel.row<this.datas.length?this.datas[sel.row]:"";
+        this.sheet.setRowCount(0);
+        this.datas = datas?datas:this.getElectrovalenceDatas();
+        this.calcPertElectrovalenceMarketPrice(this.datas);
+        sheetCommonObj.showData(this.sheet, this.setting,this.datas);
+        this.sheet.setRowCount(this.datas.length+1);
+        let nameCol = _.findIndex(this.setting.header,{'dataCode':'name'});
+        let nameOptions = this.getElectrovalenceOptions();
+        sheetCommonObj.setComboBox(-1,nameCol,this.sheet,nameOptions,false,false,5);
+        sel.row =  oldData?_.findIndex(this.datas,{'ID':oldData.ID}):sel.row ;
+        this.sheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
+    },
+    getElectrovalenceDatas:function () {
+        let datas = [];
+        let com_electrovalence = projectObj.project.projectGLJ.datas.com_electrovalence;
+        if(com_electrovalence && com_electrovalence.gljList){
+            for (let g of com_electrovalence.gljList){
+                let t = this.createNewElectrovalenceData(g);
+                gljOprObj.setGLJPrice(t);
+                datas.push(t);
+            }
+        }
+        return datas;
+    },
+    createNewElectrovalenceData:function (g) {//只是拷贝一份
+        let t = {
+            ID:g.ID,
+            GLJID:g.GLJID,
+            projectGLJID:g.projectGLJID,
+            name:g.name,
+            code:g.code,
+            specs:g.specs,
+            unit:g.unit,
+            type:g.type,
+            coe: g.coe,
+            from:g.from
+        };
+        return t;
+    },
+
+    calcPertElectrovalenceMarketPrice:function (datas) {
+        let total = 0;
+        for(let d of datas){
+            if(d.name == "电网电"){
+                d.electPrice = d.marketPrice;
+            }else {
+                let w = parseInt(d.name);
+                if(!w) continue;
+                let t = scMathUtil.roundForObj(d.marketPrice/w,getDecimal("process"));
+                d.electPrice = scMathUtil.roundForObj(t * gljUtil.k,getDecimal("glj.unitPriceHasMix"));
+            }
+            let et = scMathUtil.roundForObj(d.electPrice * d.coe,getDecimal("process"));
+            total = scMathUtil.roundForObj(et + total,getDecimal("process"));
+        }
+        this.total = scMathUtil.roundForObj(total,getDecimal("glj.unitPrice"));
+        $("#electrovalenceLabel").text(`综合电价:${this.total}`);
+    },
+    getElectrovalenceOptions:function () {
+        return _.map(this.options,"name")
+    },
+    onElectrovalenceSelectionChange:function (sender,args) {
+        args.sheet.repaint();
+    },
+    onElectrovalenceEditStarting:function (sender,args) {
+        let me = electrovalenceObj;
+        let dataCode = me.setting.header[args.col].dataCode;
+        if(dataCode == "electPrice" ){//除电网电外,不可修改
+            let cancel = true;
+            if(me.datas[args.row] && me.datas[args.row].name == "电网电") cancel  = false;
+            args.cancel = cancel;
+        }
+    },
+
+
+    onElectrovalenceValueChange:function (sender,args) {
+        let me = electrovalenceObj;
+        let dataCode = me.setting.header[args.col].dataCode;
+        let value = args.newValue;
+        if(dataCode == "name" && args.row >= me.datas.length) {//新增
+             me.addElectrovalence(value);
+        }else { //修改
+            let tem = me.datas[args.row];
+            if (value&&!sheetCommonObj.checkData(args.col,me.setting,value)) {
+                alert('输入的数据类型不对,请重新输入!');
+                return  me.showDatas(me.datas);
+            }
+            if(dataCode == 'coe' || dataCode == 'electPrice'){
+                let dec = dataCode == 'coe' ?getDecimal("process"):getDecimal("glj.unitPrice");
+                if(value){
+                    value = scMathUtil.roundForObj(value,dec);
+                }
+                tem[dataCode] = value;
+                if(dataCode == 'electPrice') tem.marketPrice = value;
+            }else if(dataCode == 'name'){//下拉替换
+                me.editElectrovalence(value,args.row,"replace");
+            }
+            me.showDatas(me.datas);
+        }
+    },
+    addElectrovalence:async function (name) {
+        this.editElectrovalence(name);
+    },
+    editElectrovalence:async function (name,row,type="add") {
+        //新建项目的时候,电已经默认生成了,所以不用考考虑电没有的情况
+        try {
+            let glj = _.find(this.options,{name:name});
+            if(glj){
+                let tem = {name:glj.name,code:glj.code,specs:glj.specs,unit:glj.unit,type:glj.type,projectID : projectObj.project.ID()};
+                tem.ID = uuid.v1();
+                $.bootstrapLoading.start();
+                let result =  await ajaxPost('/glj/insertElectrovalence',tem);
+                console.log(result);
+                //插入项目工料机列表
+                projectObj.project.projectGLJ.loadNewProjectGLJToCache(result.projetcGLJData);
+                //加入综合电价显示列表缓存
+                tem.GLJID = result.projetcGLJData.glj_id;
+                tem.projectGLJID = result.projetcGLJData.id;
+                tem.coe = 0;
+                tem.from = "std";
+                gljOprObj.setGLJPrice(tem);
+
+                if(type == "add"){
+                    this.datas.push(tem);
+                }else { //除了添加的就是替换
+                    if(this.datas[row])this.datas[row]=tem;
+                }
+                this.showDatas(this.datas);
+            }
+        }catch (e){
+            console.log(e)
+        }finally {
+            //materialCalcObj.showDatas();
+            $.bootstrapLoading.end();
+        }
+    },
+    getGljListFromDatas:function (datas) {
+        let gljList = [];
+        for(let d of datas){
+            gljList.push(this.createNewElectrovalenceData(d));
+        }
+        return gljList;
+    },
+    updateElectrovalence:function () {
+        let updateMap = {};
+        let dwd = null;//电网电
+        let com_electrovalence = projectObj.project.projectGLJ.datas.com_electrovalence;
+        if(com_electrovalence){//存在则是更新
+            updateMap['electrovalence'] = {
+                actionType:'update',
+                ID:com_electrovalence.ID,
+                doc:{gljList:this.getGljListFromDatas(this.datas)}
+            };
+        }else { //不存在则是新增
+            updateMap['electrovalence'] = {
+                actionType:'add',
+                doc:{
+                    unit_price_file_id:projectObj.project.property.unitPriceFile.id,
+                    gljList:this.getGljListFromDatas(this.datas)
+                }
+            };
+            updateMap['electrovalence']['doc'].ID = uuid.v1();
+        }
+        for(let t of this.datas){
+            if(t.name == '电网电'){
+                dwd = t;
+            }
+        }
+        let unitPrices = [];
+        for(let g of projectObj.project.projectGLJ.datas.gljList){
+            if(dwd && g.id == dwd.projectGLJID){
+                if(g.unit_price.market_price != dwd.electPrice+''){
+                  let  t_unitPrice = {projectGLJID:g.id,id:g.unit_price.id,'unit_price_file_id':g.unit_price.unit_price_file_id,doc:{'market_price':dwd.electPrice+""}};
+                    unitPrices.push(t_unitPrice);
+                }
+            }
+            if(g.code == "3005002" && g.name == "电" && g.unit == "kW·h"){//更新电价
+                if(g.unit_price.market_price != this.total+''){
+                    let  d_unitPrice = {projectGLJID:g.id,id:g.unit_price.id,'unit_price_file_id':g.unit_price.unit_price_file_id,doc:{'market_price':this.total+''}};
+                    unitPrices.push(d_unitPrice);
+                }
+            }
+        }
+        if(unitPrices.length > 0)updateMap["unitPrice"] =  unitPrices;
+        this.submitElectrovalenceChange(updateMap)
+    },
+    submitElectrovalenceChange:async function (updateMap) {
+        try {
+            if(!_.isEmpty(updateMap)){
+                $.bootstrapLoading.start();
+                let result =  await ajaxPost('/glj/updateElectrovalence',updateMap);
+                projectObj.project.projectGLJ.refreshEctrovalenceCache(updateMap);
+            }
+        }catch (e){
+            console.log(e)
+        }finally {
+            $.bootstrapLoading.end();
+        }
+
     }
+
+
 };
 
 $(function () {
 
     $("#electrovalenceDiv").on('shown.bs.modal', function () {
         electrovalenceObj.initSpread();
+        electrovalenceObj.showDatas();
     });
+
+    $("#removeElectrovalencec").click(function(){
+        let record = sheetCommonObj.getSelectedRecode(electrovalenceObj.sheet,electrovalenceObj.datas);
+        if(record){
+            _.remove(electrovalenceObj.datas,{'ID':record.ID});
+            electrovalenceObj.showDatas(electrovalenceObj.datas);
+        }
+    });
+
+    $("#electrovalencecConfirm").click(function () {
+        electrovalenceObj.updateElectrovalence();
+    })
 });

+ 2 - 1
web/building_saas/main/js/views/glj_view.js

@@ -726,7 +726,8 @@ var gljOprObj = {
                     }
                     if(ration) gljOprObj.getTotalQuantity(ration_gljs[i], ration);
                 }else {
-                    console.log("没有找到工料机:"+ration_gljs[i].name)
+                    //计算程序中量价也会放到这里进来,量价是没有对应的项目工料机的
+                    if(ration_gljs[i].type != rationType.volumePrice) console.log("没有找到工料机:"+ration_gljs[i].name)
                 }
             }
         }

+ 1 - 0
web/building_saas/main/js/views/material_calc_view.js

@@ -382,6 +382,7 @@ materialCalcObj = {
         let me = materialCalcObj;
         let dataCode = me.rationSetting.header[args.col].dataCode;
         let datas = type == "freight"?me.freightRations:me.priceRations;
+        if(type ==  'price' && !gljUtil.isDef(me.getSelectedPrice()))   args.cancel = true;//没有选中原价,不可编辑
         if(args.row > datas.length){
             args.cancel = true;
         }else if(args.row == datas.length && dataCode != "code"){