Sfoglia il codice sorgente

混凝土右键处理

zhangweicheng 6 anni fa
parent
commit
d3bb943592

+ 1 - 0
modules/all_models/project_glj.js

@@ -102,6 +102,7 @@ let modelSchema = {
         type: Number,
         default: 1
     },
+    from:{type: String,default:'std'},//std, cpt  来自标准工料机库、补充工料机库
     //以下仅普通材料可用
     grossWeightCoe: Number, //毛重系数
     purchaseStorageRate: Number, //采购保管费率

+ 1 - 1
modules/all_models/ration.js

@@ -72,7 +72,7 @@ let rationSchema = new Schema({
 
     //工料机特有属性
     projectGLJID:Number,  //项目工料机ID
-    GLJID:Number,//工料机库ID
+    GLJID:Number,//工料机库对应的ID
     original_code:String, //原始编码
     specs:String,//规格型号
     shortName:String,//缩写

+ 1 - 0
modules/common/std/std_glj_lib_glj_list_model.js

@@ -84,6 +84,7 @@ class STDGLJLibGLJListModel extends BaseModel {
         for(let gljData of componentGljData) {
             gljData.connectCode = libGljData.code;
             gljData.consumption = componentConsume[gljData.ID];
+            gljData.from='std';
             componentData.push(gljData);
         }
 

+ 3 - 4
modules/glj/models/glj_list_model.js

@@ -606,7 +606,8 @@ class GLJListModel extends BaseModel {
                     grossWeightCoe:tmp.grossWeightCoe,
                     purchaseStorageRate:tmp.purchaseStorageRate,
                     offSiteTransportLossRate:tmp.offSiteTransportLossRate,
-                    handlingLossRate:tmp.handlingLossRate
+                    handlingLossRate:tmp.handlingLossRate,
+                    from:tmp.from
                 };
                 gljInsertData.push(gljData);
             }
@@ -771,7 +772,7 @@ class GLJListModel extends BaseModel {
             mixRatioData[m_index]=tmp;
         }
         // 查找对应的项目工料机数据
-        let gcondition = {project_id: glj.project_id,code: {"$in": codeList}, name: {"$in": nameList},specs:{"$in": specsList},type:{"$in": typeList},unit:{"$in": unitList} };
+        let gcondition = {project_id: glj.project_id?glj.project_id:glj.projectID,code: {"$in": codeList}, name: {"$in": nameList},specs:{"$in": specsList},type:{"$in": typeList},unit:{"$in": unitList} };
         let gljData = await this.findDataByCondition(gcondition, {_id: 0}, false);
 
         // 查找对应的单价数据
@@ -791,8 +792,6 @@ class GLJListModel extends BaseModel {
             let g_index =  this.getIndex(g,['code','name','specs','unit','type']);
             if(mixRatioData[g_index]) c_gljData.push(g);
         }
-
-
         return [c_gljData,mixRatioData,unitPriceData];
 
     }

+ 19 - 1
modules/ration_glj/controllers/ration_glj_controller.js

@@ -15,7 +15,8 @@ module.exports={
     replaceGLJ:replaceGLJ,
     mReplaceGLJ:mReplaceGLJ,
     updateRationGLJByEdit:updateRationGLJByEdit,
-    getGLJClass:getGLJClass
+    getGLJClass:getGLJClass,
+    deleteRationGLJ:deleteRationGLJ
 }
 function createRationGLJ() {
     let gls = mongoose.model('ration_glj');
@@ -99,6 +100,23 @@ async function addGLJ(req, res){
     res.json(result);
 }
 
+async function deleteRationGLJ (req,res) {
+    let result={
+        error:0
+    }
+    try {
+        let data = req.body.data;
+        data = JSON.parse(data);
+        let datas= await ration_glj_facade.deleteRationGLJ(data);
+        result.data=datas;
+    }catch (err){
+        logger.err(err);
+        result.error=1;
+        result.message = err.message;
+    }
+    res.json(result);
+}
+
 async function replaceGLJ(req, res){
     let result={
         error:0

+ 1 - 1
modules/ration_glj/facade/glj_calculate_facade.js

@@ -42,7 +42,7 @@ let coeTypeMap = {
 };
 
 
-async function calculateQuantity(query,noNeedCal,refreshRationName = false){
+async function calculateQuantity(query,noNeedCal=null,refreshRationName = false){
     try {
          let  result ={
              glj_result:[],

+ 160 - 13
modules/ration_glj/facade/ration_glj_facade.js

@@ -28,6 +28,9 @@ const stdGljModel = mongoose.model('std_glj_lib_gljList');
 const gljClassModel = mongoose.model('std_glj_lib_gljClass');
 const projectDao = require('../../pm/models/project_model').project;
 const compleClassModel = mongoose.model('complementary_glj_section');
+let gljUtil = require('../../../public/gljUtil');
+
+
 
 module.exports = {
     save: save,
@@ -38,6 +41,7 @@ module.exports = {
     getGLJData: getGLJData,
     getGLJDataByCodes:getGLJDataByCodes,
     addGLJ: addGLJ,
+    deleteRationGLJ:deleteRationGLJ,
     deleteGLJ:deleteGLJ,
     insertAddTypeGLJ:insertAddTypeGLJ,
     replaceGLJ: replaceGLJ,
@@ -636,8 +640,9 @@ async function addGLJ(rgList,compilation) {
 }
 
 async function insertAddTypeGLJ(rgList,compilation) {
-    let newRecodes = [];
+    let newRecodes = [],GLJMap=null;
     let [unitFileId,ext] = await  prepareExtData(rgList[0].projectID,compilation);
+
     for (let g of rgList) {
         let projectGljModel = new GLJListModel();
         let result = await projectGljModel.addList(getGLJSearchInfo(g),unitFileId,ext);
@@ -653,6 +658,14 @@ async function insertAddTypeGLJ(rgList,compilation) {
         g.ID = uuidV1();
         if (result.hasOwnProperty('subList') && result.subList.length > 0) {
             g.subList = getMixRatioShowDatas(result.subList);
+            //对于混凝土,砂浆,配合比,组成物还要插入定额工料机
+            if(gljUtil.isConcreteType(g.type)){
+                if(GLJMap == null){
+                    let oldGLJList = await ration_glj.find({'rationID':g.rationID});
+                    GLJMap = _.indexBy(oldGLJList,"projectGLJID");
+                }
+                addMixRatioToRationGLJ(g,result.subList,newRecodes,GLJMap);
+            }
         }
         newRecodes.push(createNewRecord(g));
     }
@@ -660,6 +673,80 @@ async function insertAddTypeGLJ(rgList,compilation) {
     return newRecodes;
 }
 
+async function deleteRationGLJ(data){
+    let deleteIDs = [data.ID];
+    if(gljUtil.isConcreteType(data.type)){//如果是混凝土、砂浆、配合比,还要删除没有被引用的组成物工料机
+        let projectGljModel = new GLJListModel();
+        let rationGLJList = await ration_glj.find({'rationID':data.rationID});
+        let unitFileId  = await projectDao.getUnitPriceFileId(data.projectID);
+        let projectGLJMap = {},referenceMap={};
+        let deleteMix = [];
+        for(let r of rationGLJList){
+            projectGLJMap[r.projectGLJID] = r;
+            if(gljUtil.isConcreteType(r.type)){
+                if(r.ID == data.ID){//是要删除的工料机
+                    deleteMix = await projectGljModel.getCompositionGLJByData(r,unitFileId);
+                }else {
+                    let comList = await projectGljModel.getCompositionGLJByData(r,unitFileId);
+                    for(let c of comList){
+                        referenceMap[c.id] = c;
+                    }
+                }
+            }
+        }
+        for(let d of deleteMix){
+            //删除不属于其它的组成物并且定额消耗为0
+            if(referenceMap[d.id]) continue;
+            if(projectGLJMap[d.id]&&(projectGLJMap[d.id].rationItemQuantity == '0'||projectGLJMap[d.id].rationItemQuantity == 0)){
+                deleteIDs.push(projectGLJMap[d.id].ID);
+            }
+        }
+        await ration_glj.deleteMany({'ID': {"$in": deleteIDs}});
+    } else{
+        await ration_glj.deleteOne({ID:data.ID});
+    }
+    let calcResult = await glj_calculate_facade.calculateQuantity({
+        projectID: data.projectID,
+        rationID: data.rationID
+    });
+    calcResult.deleteList = deleteIDs;
+    return calcResult;
+}
+
+
+function addMixRatioToRationGLJ(g,subList,newRecodes,GLJMap){
+    let newMap = {};
+    for(let mr of subList ){
+        //先查找该定额下是否已经有了工料机了,有就不用再插入了
+        newMap[mr.id] = mr;//新增的定额工料机映射表
+        if(GLJMap[mr.id]||_.find(newRecodes,{'projectGLJID':mr.id})) continue;
+        //没有的情况下,生成一条定额工料机计录
+        let newMr = {
+            projectID:g.projectID,
+            GLJID:mr.glj_id,
+            rationID:g.rationID,
+            rationItemQuantity:0,
+            quantity:0,
+            name:mr.name,
+            code:mr.code,
+            original_code:mr.original_code,
+            unit:mr.unit,
+            specs:mr.specs,
+            from:mr.from,
+            createType:g.createType,
+            shortName:mr.unit_price.short_name,
+            billsItemID:g.billsItemID,
+            type:mr.type,
+            model:mr.model,
+            repositoryId:g.repositoryId,
+            projectGLJID:mr.id,
+            adjCoe:mr.adjCoe
+        };
+        newMr.ID = uuidV1();
+        newRecodes.push(newMr);
+    }
+    return newMap;
+}
 
 async  function replaceGLJByData(data,compilation) {
     let projectGljModel = new GLJListModel();
@@ -667,7 +754,8 @@ async  function replaceGLJByData(data,compilation) {
     let result = await projectGljModel.addList(getGLJSearchInfo(data),unitFileId,ext);
     let typeString = result.type+'';
     data.projectGLJID = result.id;
-
+    //  CompositionGLJ=await this.getCompositionGLJByData(data,unitPriceFileId);
+    let [newRecodes,deleteList] = await replaceMixRatio(data,result,unitFileId);
     let updateResult = await ration_glj.findOneAndUpdate({ID: data.ID, projectID: data.projectID}, data);//更新定额工料机
     //组装回传数据
     data.marketPrice = result.unit_price.market_price;
@@ -680,24 +768,75 @@ async  function replaceGLJByData(data,compilation) {
     if (result.hasOwnProperty('subList') && result.subList.length > 0) {
         data.subList = getMixRatioShowDatas(result.subList);
     }
-    return data;
+    return {data:data,newRecodes:newRecodes,deleteList:deleteList};
 }
 
+async function replaceMixRatio(g,result,unitFileId){
+    let newRecodes=[],deleteList = [];
+    if(gljUtil.isConcreteType(g.type)){//相同类型的才能替换,所以判断一个就好了
+        let IDMap = {}, projectGLJMap = {},referenceMap={},concreteList=[],newMap={};
+        let projectGljModel = new GLJListModel();
+        let rationGLJList = await ration_glj.find({'rationID':g.rationID});
+        for(let r of rationGLJList){
+            IDMap[r.ID] = r;
+            projectGLJMap[r.projectGLJID] = r;
+            if(gljUtil.isConcreteType(r.type)&&r.ID!=g.ID) concreteList.push(r) //除了本身,记录一下其它混凝土类型
+        }
+        if (result.hasOwnProperty('subList') && result.subList.length > 0){
+            newMap =  addMixRatioToRationGLJ(g,result.subList,newRecodes,projectGLJMap);//先生成要添加的工料机
+        }
+        let oldMixList = await projectGljModel.getCompositionGLJByData(IDMap[g.ID],unitFileId);
+        for(let c of concreteList){//找出要删除的子定额工料机(没人引用,并且定额消耗量为0)
+            let temList = await projectGljModel.getCompositionGLJByData(c,unitFileId);
+            for(let t of temList){
+                referenceMap[t.id] = t;
+            }
+        }
+        for(let o of oldMixList){
+            if(newMap[o.id]||referenceMap[o.id]) continue;//如果两个地方有一个存在,那么就不用删除
+            //没有被其它地方引用并且定额消耗量为0,就删除对应的定额工料机
+            if(projectGLJMap[o.id] && (projectGLJMap[o.id].rationItemQuantity == '0'||projectGLJMap[o.id].rationItemQuantity == 0)) deleteList.push(projectGLJMap[o.id].ID)
+        }
+    }
+
+    if(deleteList.length > 0) await ration_glj.deleteMany({'ID': {"$in": deleteList}});//删除定额工料机
+    if(newRecodes.length > 0)  await ration_glj.insertMany(newRecodes);
+    return [newRecodes,deleteList]
+}
 
 async function replaceGLJ(data,compilation) {
     let rdata = {};
-    data = await  replaceGLJByData(data,compilation);
+    let r_result =await replaceGLJByData(data,compilation);
+    data = r_result.data;
     let stateResult = await glj_calculate_facade.calculateQuantity({
         projectID: data.projectID,
         rationID: data.rationID
-    }, true,true);
+    }, null,true);
     rdata.data = data;
     rdata.adjustState = stateResult.adjustState;
     rdata.name = stateResult.rationName;
+    rdata.newRecodes = r_result.newRecodes;
+    rdata.deleteList = r_result.deleteList;
+    rdata.glj_result = stateResult.glj_result;
     return rdata;
 }
+
+async function replaceMixRatioForMReplace(tasks,result,unitFileId) {
+    let allNewRecodes = [],allDeleteList=[];
+    for(let t of tasks){
+        let tem = _.cloneDeep(t.updateOne.update);
+        tem.ID = t.updateOne.filter.ID;
+        tem.rationID = t.updateOne.filter.rationID;
+        delete t.updateOne.filter.rationID;
+        let [newRecodes,deleteList] = await replaceMixRatio(tem,result,unitFileId);
+        allNewRecodes = allNewRecodes.concat(newRecodes);
+        allDeleteList = allDeleteList.concat(deleteList);
+    }
+    return {newRecodes:allNewRecodes,deleteList:allDeleteList}
+}
+
 async function mReplaceGLJ(data,compilation) {
-    let mresult = {};
+    let mresult = {},mixResult = null,noNeedCal=true;
     let projectGljModel = new GLJListModel();
     let [unitFileId,ext] = await prepareExtData(data.doc.projectID,compilation);
     //
@@ -705,12 +844,16 @@ async function mReplaceGLJ(data,compilation) {
     let typeString = result.type+'';
     let newDoc = {};
     newDoc.projectGLJID = result.id;
-    let rationList = await ration_glj.distinct('rationID', data.query);
+    let rationList = [];//await ration_glj.distinct('rationID', data.query);
     for(let t of data.tasks){
+        rationList.push(t.updateOne.filter.rationID);
         t.updateOne.update.projectGLJID = result.id;//更新项目工料机ID
     }
+    if(gljUtil.isConcreteType(result.unit_price.type)) {
+        mixResult = await replaceMixRatioForMReplace(data.tasks,result,unitFileId);
+        noNeedCal = null;
+    }
     await ration_glj.bulkWrite(data.tasks);
-    //let updateResult = await ration_glj.update(data.query, data.doc, {multi: true});
 
     newDoc.marketPrice = result.unit_price.market_price;
     newDoc.adjustPrice = result.unit_price.base_price;
@@ -722,10 +865,13 @@ async function mReplaceGLJ(data,compilation) {
     if (result.hasOwnProperty('subList') && result.subList.length > 0) {
         newDoc.subList = getMixRatioShowDatas(result.subList);
     }
-    let stateList = await changAdjustState(data, rationList);
+    let [stateList,glj_result] = await changAdjustState(data, rationList,noNeedCal);
     data.doc = newDoc;
     mresult.data = data;
     mresult.stateList = stateList;
+    mresult.newRecodes = mixResult?mixResult.newRecodes:[];
+    mresult.deleteList = mixResult?mixResult.deleteList:[];
+    mresult.glj_result = glj_result;
     return mresult
 }
 
@@ -850,18 +996,19 @@ async function  getRationTypeGLJQuantity(projectID) {
     return rations;
 }
 
-async function changAdjustState(data, rationList) {
-    let stateList = [];
+async function changAdjustState(data, rationList,noNeedCal) {
+    let stateList = [],glj_result=[];
     for (let r of rationList) {
         let stateResult = await glj_calculate_facade.calculateQuantity({
             projectID: data.query.projectID,
             rationID: r
-        }, true,true);
+        }, noNeedCal,true);
         if(stateResult){
             stateList.push({rationID: r, adjustState: stateResult.adjustState,name:stateResult.rationName});
+            glj_result = glj_result.concat(stateResult.glj_result)
         }
     }
-    return stateList;
+    return [stateList,glj_result];
 }
 
 async function getGLJDataByCodes(data,compilation) {

+ 2 - 0
modules/ration_glj/routes/ration_glj_route.js

@@ -15,6 +15,8 @@ module.exports = function (app) {
     rgRouter.post('/mReplaceGLJ',rgController.mReplaceGLJ);
     rgRouter.post('/updateRationGLJByEdit',rgController.updateRationGLJByEdit);
     rgRouter.post('/getGLJClass/:engineerID', rgController.getGLJClass);
+    rgRouter.post('/deleteRationGLJ', rgController.deleteRationGLJ);
+
     app.use('/rationGlj',rgRouter);
 }
 

+ 64 - 9
web/building_saas/main/js/models/ration_glj.js

@@ -416,16 +416,52 @@ let ration_glj = {
         ration_glj.prototype.updataOrdelete = function (row) {
             let updateData = null;
             if (row.rationItemQuantity == 0) {
-                updateData = this.getUpdateData('ut_delete', {
+               /* updateData = this.getUpdateData('ut_delete', {
                     'ID': row.ID,
                     'projectID': row.projectID
                 }, {rationID: row.rationID});
-                project.pushNow('updateRationGLJ', [this.getSourceType()], updateData)
+                project.pushNow('updateRationGLJ', [this.getSourceType()], updateData)*/
+                this.deleteRationGLJ({ID:row.ID,rationID:row.rationID, projectID: row.projectID,type:row.type});
             } else {
                 this.updateRationGLJByEdit(row, 'customQuantity', 0);
                 //('ut_update',{'ID': row.ID, 'projectID': row.projectID},{'quantity':0,'customQuantity':0});
             }
         };
+
+        ration_glj.prototype.deleteRationGLJ = async function(data){
+            try {
+                let result = await ajaxPost('/rationGlj/deleteRationGLJ',data);
+                console.log(result);
+                let oldData = this.addAndDeleteDatas([],result.deleteList);
+                this.refreshQuantityAfterCalResult(result.glj_result);
+                let rationNode = null;
+                let next = null;
+                let selected = projectObj.project.mainTree.findNode(result.rationID);
+                if (selected.sourceType == ModuleNames.ration) { //如果选中的是定额,说明是右键删除工料机操作,如果选中的是定额工料机,则说明是在造价书主界面中点击了删除按钮
+                    rationNode = selected;
+                } else if (selected.sourceType == ModuleNames.ration_glj) {
+                    rationNode = selected.parent;
+                    next = true;
+                }
+                rationNode.data.adjustState = result.adjustState;
+                projectObj.mainController.refreshTreeNode([rationNode]);
+                gljOprObj.refreshView();
+                for (let o of oldData) {
+                    if (this.needShowToTree(o)) {
+                        let node = me.findGLJNodeByID(o.ID);  //找到对应的树节点
+                        projectObj.mainController.deleteNode(node, next);
+                    }
+                }
+                project.calcProgram.calcAndSave(rationNode,function () {
+                    installationFeeObj.calcInstallationFee();
+                });
+                projectObj.project.projectGLJ.loadData();
+            }catch (e){
+                console.log(e)
+            }
+
+        };
+
         ration_glj.prototype.getUpdateData = function (type, query, doc, callfunction) {
             let updateData = [];
             let newobj = {
@@ -494,12 +530,16 @@ let ration_glj = {
             });
         };
         ration_glj.prototype.refreshAfterQuantityUpdate = function (data, node) {
+            this.refreshQuantityAfterCalResult(data.glj_result);
+            this.refreshRationAfterEdit(data, data.rationID, node);
+        };
+        ration_glj.prototype.refreshQuantityAfterCalResult = function (glj_result) {//后端计算后,前端刷新结果
             let me = this;
-            data.glj_result.forEach(function (item) {
+            glj_result.forEach(function (item) {
                 me.refreshEachItme(item.doc, item.query);
             });
-            me.refreshRationAfterEdit(data, data.rationID, node);
         };
+
         ration_glj.prototype.refreshRationAfterEdit= function(data,rationID,rnode){
             let nodes = [];
             let node = this.refreshRationNode(data.name,data.adjustState,rationID);
@@ -728,13 +768,10 @@ let ration_glj = {
             $.bootstrapLoading.start();
             CommonAjax.post("/rationGlj/replaceGLJ", recode, function (result) {
                 if (result) {
-                    //result.adjustState;
-                    let glj_list = me.datas;
+                    me.setDatasAfterReplace(result);
                     let data = result.data;
-                    let list_index = _.findIndex(glj_list, {'ID': data.ID});
                     let rationNode = projectObj.project.mainTree.findNode(data.rationID);
                     let nodes =  [rationNode];
-                    glj_list[list_index] = data;
                     project.projectGLJ.loadData(function () {//加载完项目工料机再计算
                         gljOprObj.refreshView();
                         if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
@@ -758,6 +795,24 @@ let ration_glj = {
             });
         };
 
+        ration_glj.prototype.setDatasAfterReplace = function(result){
+            let me = this;
+            me.addAndDeleteDatas(result.newRecodes,result.deleteList);
+            let list_index = _.findIndex(me.datas, {'ID': result.data.ID});
+            me.datas[list_index] = result.data;
+            me.refreshQuantityAfterCalResult(result.glj_result);
+        };
+
+        ration_glj.prototype.addAndDeleteDatas = function (newRecodes,deleteList) {
+            let oldData = [];
+          if(newRecodes.length > 0 ) this.datas = this.datas.concat(newRecodes);
+          if(deleteList.length > 0) {
+              oldData =  _.remove(this.datas,function (item) {
+                  return  deleteList.indexOf(item.ID)!=-1;
+              });
+          }
+          return oldData;
+        };
         ration_glj.prototype.getReplaceDataByStd = function (oldData,glj) {
             if (oldData.createType===undefined || oldData.createType == 'normal') {// createTypel 默认是normal 只有是定额下带的工料机才需把类型改成替换,其它的保持不变
                 oldData.rcode = oldData.code;
@@ -873,7 +928,7 @@ let ration_glj = {
                     }
                     let task = {
                         updateOne:{
-                            filter : {ID:d.ID},
+                            filter : {ID:d.ID,rationID:d.rationID},
                             update : tem_doc
                         }
                     };

+ 17 - 12
web/building_saas/main/js/views/glj_view.js

@@ -1138,12 +1138,12 @@ var gljOprObj = {
             project.ration_glj.addGLJByLib(gljOprObj.GLJSelection, selected.data, function (result) {
                 if (result) {
                     selected.data.adjustState = result.adjustState;
-                    //project.ration_glj.datas = project.ration_glj.datas.concat(result.newRecodes);//显示和缓存统一,这样的话就不用更新两个位置了
-                    project.ration_glj.datas = project.ration_glj.datas.concat(result.showData);
-                    gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData);
+                    project.ration_glj.datas = project.ration_glj.datas.concat(result.newRecodes);//显示和缓存统一,这样的话就不用更新两个位置了
+                    //project.ration_glj.datas = project.ration_glj.datas.concat(result.showData);
+                    //gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData);
                     project.projectGLJ.loadData(function () {
-                        project.ration_glj.addToMainTree(result.showData);
-                        gljOprObj.showRationGLJSheetData();
+                        project.ration_glj.addToMainTree(result.showData);//组成物不会显示到造价书页面
+                        gljOprObj.refreshView();
                         project.calcProgram.calcAndSave(selected);
                         projectObj.mainController.refreshTreeNode([selected]);
                         $.bootstrapLoading.end();
@@ -1164,15 +1164,11 @@ var gljOprObj = {
         project.ration_glj.replaceGLJ(selectCode, oldData, function (result) {
             if (result) {
                 //result.adjustState;
-                let glj_list = projectObj.project.ration_glj.datas;
+                project.ration_glj.setDatasAfterReplace(result);
                 let data = result.data;
-                let index = _.findIndex(gljOprObj.sheetData, {'ID': data.ID});
-                let list_index = _.findIndex(glj_list, {'ID': data.ID});
                 let nodes = [selected];
-                gljOprObj.sheetData[index] = data;
-                glj_list[list_index] = data;
                 project.projectGLJ.loadData(function () {//加载完项目工料机再计算
-                    gljOprObj.showRationGLJSheetData();
+                    gljOprObj.refreshView();
                     let node = project.ration_glj.updateGLJNodeAfterReplace(data);
                     if(node) nodes.push(node);
                     /*if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
@@ -1208,6 +1204,12 @@ var gljOprObj = {
             let stateList = result.stateList;
             //let n_index = me.getIndex(data.query, gljKeyArray);
             let nodes = [];
+            let quantityMap = {};
+            for(let gr of result.glj_result){
+                quantityMap[gr.query.ID] = gr.doc;
+            }
+            //添加\删除混凝土组成物定额工料机
+            project.ration_glj.addAndDeleteDatas(result.newRecodes,result.deleteList);
             _.forEach(project.ration_glj.datas, function (t) {
                 //     let t_index = me.getIndex(t, gljKeyArray);
                 if (updateMap[t.ID]) {
@@ -1219,9 +1221,12 @@ var gljOprObj = {
                         node ? nodes.push(node):'';
                     }
                 }
+                if(quantityMap[t.ID]){//更新消耗量
+                    me.updateProperty(t,quantityMap[t.ID]);
+                }
             })
             project.projectGLJ.loadData(function () {
-                me.showRationGLJSheetData();
+                me.refreshView();
                 var rationNodes = me.refreshStateAfterMreplace(stateList, nodes);
                 project.calcProgram.calcNodesAndSave(rationNodes);
                 $.bootstrapLoading.end();