瀏覽代碼

update ration installation

zhangweicheng 7 年之前
父節點
當前提交
f3ee497fe7

+ 2 - 1
modules/main/controllers/bills_controller.js

@@ -10,7 +10,7 @@ let quantity_detail = require("../facade/quantity_detail_facade");
 let bill_detail = require("../facade/bill_facade");
 let ration_glj = mongoose.model('ration_glj');
 let ration_coe = mongoose.model('ration_coe');
-
+import rationInstallationModel from "../models/ration_installation";
 //统一回调函数
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
@@ -197,6 +197,7 @@ async function doBillsOrRationsDelete(data) {
     if(sub_query!=null){
         await ration_coe.deleteMany(sub_query);//删除附注条件
         await ration_glj.deleteMany(sub_query);//删除定额工料机
+        await rationInstallationModel.deleteMany(sub_query);//删除安装增加费
     }
     if(rationTask.length>0){
         await  ration_model.model.bulkWrite(rationTask);//删除定额

+ 23 - 2
modules/main/controllers/installation_controller.js

@@ -1,11 +1,32 @@
 /**
  * Created by zhang on 2018/2/5.
  */
-var installation_facade = require('../facade/installation_facade');
+let installation_facade = require('../facade/installation_facade');
+let ration_installation_facade = require('../facade/ration_installation_facade');
+
 let logger = require("../../../logs/log_helper").logger;
 module.exports={
-    updateInstallationFee:updateInstallationFee
+    updateInstallationFee:updateInstallationFee,
+    updateRationInstallation:updateRationInstallation
 }
+
+async function updateRationInstallation(req, res) {
+    let result={
+        error:0
+    }
+    try {
+        let data = req.body.data;
+        data = JSON.parse(data);
+        let datas= await ration_installation_facade.updateRationInstallation(data);
+        result.data=datas;
+    }catch (err){
+        logger.err(err);
+        result.error=1;
+        result.message = err.message;
+    }
+    res.json(result);
+}
+
 async function  updateInstallationFee(req, res) {
     let result={
         error:0

+ 4 - 5
modules/main/facade/ration_facade.js

@@ -114,7 +114,6 @@ async function replaceRation(nodeInfo,stdRation,projectID,calQuantity) {
 async function addRationSubList(stdRation,newRation) {
     let ration_gljs = await addRationGLJ(stdRation,newRation);
     let ration_coes = await addRationCoe(stdRation,newRation);
-    //todo  添加增加安装费
     let ration_installs =  await addRationInstallFee(stdRation,newRation);
     return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installs:ration_installs};
 }
@@ -136,9 +135,10 @@ async function addRationInstallFee(std,newRation) {
                     itemName:feeItem.feeItem,
                     feeType:feeItem.feeType,
                     sectionName:section.name,
-                    unifiedSetting:1
+                    unifiedSetting:1,
+                    ruleId:''
                 };
-                if(section.feeRuleId&&section.feeRuleId!=''){
+                if(feeItem.isCal==1&&section.feeRuleId&&section.feeRuleId!=''){//勾选记取时并且有规则ID时才读取
                     let feeRule = _.find(installFee.feeRule,{'ID':section.feeRuleId});
                     if(feeRule){
                         tem_r_i.ruleId = feeRule.ID;
@@ -260,8 +260,7 @@ async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下
     await quantity_detail.deleteByQuery(delete_query) ;
     await ration_coe.deleteMany(delete_query);//删除附注条件
     await ration_glj.deleteMany(delete_query);//删除定额工料机
-    //todo 删除安装
-
+    await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
 }
 
 async function  updateRation(std,rationID,billsItemID,projectID,calQuantity) {

+ 10 - 0
modules/main/facade/ration_installation_facade.js

@@ -7,9 +7,19 @@ let consts = require('../models/project_consts');
 let projectConsts = consts.projectConst;
 
 module.exports={
+    updateRationInstallation:updateRationInstallation,
     getData:getData
 };
 
+async function updateRationInstallation(data){
+    if(data.projectID&&data.ID){
+        let result = await rationInstallationModel.findOneAndUpdate({'projectID':data.projectID,'ID':data.ID},data);
+        return result
+    }else {
+        throw  new Error('项目ID或者ID为空,更新失败!');
+    }
+}
+
 function getData(projectID, callback) {
     rationInstallationModel.find({'projectID': projectID}, (err, datas) => {
         if (err) {

+ 1 - 1
modules/main/routes/installation_route.js

@@ -9,7 +9,7 @@ module.exports = function (app) {
     let installationRouter = express.Router();
 
     installationRouter.post('/updateInstallationFee', installationController.updateInstallationFee);
-
+    installationRouter.post('/updateRationInstallation', installationController.updateRationInstallation);
 
     app.use('/installation',installationRouter);
 };

+ 1 - 0
web/building_saas/main/html/main.html

@@ -998,6 +998,7 @@
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close" id="more_feeRule_close">
                         <span aria-hidden="true">&times;</span>
                     </button>
+                    <input type="hidden" id="more_from">
                 </div>
                 <div class="modal-body">
                     <div class="modal-fixed-height" id="moreFeeRuleSpread"><!--sjs ID设置此div--->

+ 5 - 2
web/building_saas/main/js/models/bills.js

@@ -642,6 +642,7 @@ var Bills = {
                 let ration_datas = project.Ration.datas;
                 let ration_glj_datas = project.ration_glj.datas;
                 let ration_coe_datas = project.ration_coe.datas;
+                let ration_install_datas = project.ration_installation.datas;
                 let nodes = controller.tree.nodes;
                 let prefix = controller.tree.prefix;
                 //更新缓存
@@ -663,13 +664,15 @@ var Bills = {
                         _.remove(quantity_detail_datas,{'rationID':r_key});
                         _.remove(ration_glj_datas,{'rationID':r_key});
                         _.remove(ration_coe_datas,{'rationID':r_key});
+                        _.remove(ration_install_datas,{'rationID':r_key});
                     }
                 }
                 controller.m_delete(mainNodes);//删除树节点
                 me.tree.m_delete(idTreeNodes);
                 //重新计算
-                project.calcProgram.calcBillsAndSave(parentNodes);
-                $.bootstrapLoading.end();
+                project.calcProgram.calcBillsAndSave(parentNodes,function () {
+                    project.projectGLJ.loadData();
+                });
             }, function () {
                 $.bootstrapLoading.end();
             });

+ 2 - 2
web/building_saas/main/js/models/calc_program.js

@@ -1454,14 +1454,14 @@ class CalcProgram {
     };
 
     // 计算多条零散的清单,并计算他们的父清单、引用清单,然后打包存储。如:花选删除树结点(如花选清单、定额等,不区分树结点类型)。
-    calcBillsAndSave(billNodes){
+    calcBillsAndSave(billNodes,callback){
         let me = this, allChangedNodes = [];
         for (let node of billNodes) {
             let curChangeds = me.calculate(node, true, false);
             mergeArr(allChangedNodes, curChangeds);
         };
         me.calcFormulaNodes(allChangedNodes);
-        me.saveNodes(allChangedNodes);
+        me.saveNodes(allChangedNodes,callback);
     };
 
     // 计算并保存指定的一个树节点。修改一个树节点,实际上要计算和保存的是一批树结点:层层父结点、被其它结点(的公式)引用的公式结点。

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

@@ -452,7 +452,7 @@ var Ration = {
                     me.datas.push(data.ration);
                     project.ration_glj.addDatasToList(data.ration_gljs);
                     project.ration_coe.addDatasToList(data.ration_coes);
-                    //to do 添加增加安装费
+                    project.ration_installation.addDatasToList(data.ration_installs);
 
                     //插入树节点
                     newSource = data.ration;

+ 34 - 0
web/building_saas/main/js/models/ration_installation.js

@@ -22,6 +22,40 @@ let ration_installation = {
         ration_installation.prototype.loadData = function (datas) {
             this.datas = datas;
         };
+        ration_installation.prototype.addDatasToList = function (datas) {
+            let  me = this;
+            if(datas&&datas.length>0){
+                if (me.datas && Array.isArray(me.datas)) {
+                    me.datas = me.datas.concat(datas);
+                } else {
+                    me.datas = datas;
+                }
+            }
+        };
+        ration_installation.prototype.getByID = function (ID) {
+            let  me = this;
+            let ri = _.find(me.datas,{'ID':ID})
+            return ri;
+        };
+        ration_installation.prototype.update = function (updateData,callback) {
+            let  me = this;
+            $.bootstrapLoading.start();
+            CommonAjax.post('/installation/updateRationInstallation',updateData,function (data) {
+                //更新缓存
+                let ri = _.find(me.datas,{'ID':updateData.ID});
+                if(ri){
+                    for(let key in updateData){
+                        ri[key] = updateData[key];
+                    }
+                }
+                if(callback){
+                    callback();
+                }
+                $.bootstrapLoading.end();
+            },function () {
+                $.bootstrapLoading.end();
+            })
+        };
 
         return new ration_installation(project);
     }

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

@@ -301,7 +301,7 @@ var gljOprObj = {
         me.bindSheetEvent(sheet);
         sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
              let selected = projectObj.project.mainTree.selected;
-            if(selected&&selected.sourceType == ModuleNames.ration_glj){
+            if(selected&&selected.sourceType == ModuleNames.ration_glj){//是主材或者是设备时只读
                 args.cancel = true;
             }else {
                 if(args.sheet.getValue(args.row,args.col)==null){//这里是为了解决当单元格里的值是null的时候,在单元格里输入数据,按键盘箭头移动光标的时候,会直接结束编辑,跳到另外的单元格。
@@ -406,7 +406,11 @@ var gljOprObj = {
         var sheet = args.sheet, row = args.row, col = args.col;
         var cellType = sheet.getCellType(row, col);
         if (cellType instanceof GC.Spread.Sheets.CellTypes.Button) {
-            me.onCusButtonClick(sender, args);
+            if(args.sheetName == 'ration_coe'){
+                me.onCusButtonClick(sender, args);
+            }else if(args.sheetName == 'rationInstallSheet'){
+                installationFeeObj.onPositionButtonClick(sender,args);
+            }
         } else {
             me.onCheckBoxClick(sender, args)
         }
@@ -436,6 +440,9 @@ var gljOprObj = {
             projectObj.project.quantity_detail.isSummationUpdate(args, gljOprObj.detailData, newval);
         } else if (args.sheetName == 'glj_lib') {
             gljOprObj.setGLJSelection(args, newval);
+        }else if(args.sheetName == 'rationInstallSheet'){
+            args.newValue = newval;
+            installationFeeObj.onRationInstallValueChange(sender,args);
         }
     },
     onCusButtonClick: function (sender, args) {
@@ -1046,6 +1053,7 @@ var gljOprObj = {
         sheetCommonObj.showData(this.sheet, this.setting, []);
         sheetCommonObj.showData(this.coeSheet, this.coeSetting, []);
         sheetCommonObj.showData(this.assSheet, this.assSetting, []);
+        installationFeeObj.rationInstallSheet.setRowCount(0);//清除combobox cell
         sheetCommonObj.showData(installationFeeObj.rationInstallSheet, installationFeeObj.rationInstallSetting, []);
         //  sheetCommonObj.showData(this.detailSheet,this.detailSetting,[]);
         this.sheetData = [];

+ 213 - 56
web/building_saas/main/js/views/installation_fee_view.js

@@ -8,7 +8,7 @@ let installationFeeObj={
         header: [
             {headerName: "按统一设置", headerWidth: 80, dataCode: "unifiedSetting", dataType: "String",cellType: "checkBox"},
             {headerName: "费用项", headerWidth: 160, dataCode: "itemName", dataType: "String"},
-            {headerName: "费用规则", headerWidth: 300, dataCode: "rule", hAlign: "left", dataType: "String"/*,getText:'forRule'*/},
+            {headerName: "费用规则", headerWidth: 300, dataCode: "ruleId", hAlign: "left", dataType: "String",getText:'forRule'},
             {headerName: "编码", headerWidth: 70, dataCode: "code", hAlign: "left", dataType: "String"},
             {headerName: "基数", headerWidth: 150, dataCode: "base", hAlign: "left", dataType: "String",cellType:'comboBox',options:installSectionBase},
             {headerName: "费率(%)", headerWidth: 80, dataCode: "feeRate", hAlign: "right", dataType: "String"},
@@ -16,10 +16,22 @@ let installationFeeObj={
             {headerName: "其中材料(%)", headerWidth: 100, dataCode: "material", hAlign: "right", dataType: "String"},
             {headerName: "其中机械(%)", headerWidth: 100, dataCode: "machine", hAlign: "right", dataType: "String"},
             {headerName: "费用类型", headerWidth: 100, dataCode: "feeType", hAlign: "center", dataType: "String",cellType:'comboBox',options:installFeeType},
-            {headerName: "记取位置", headerWidth: 100, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton'}
+            {headerName: "记取位置", headerWidth: 200, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton',getText:'forPosition'}
         ],
         view: {
-            lockColumns: [0, 2]
+            lockColumns: [0,1,3,4,5,6,7,8,9]
+        },
+        getText:{
+            forPosition:function (item,val) {//记取位置转换
+               return installationFeeObj.getDisplayText(item);
+            },
+            forRule:function (item,val) {//
+                let feeRule = projectObj.project.installation_fee.getFeeRuleByID(item.libID,val);
+                if(feeRule){
+                    return feeRule.rule;
+                }
+                return val;
+            }
         }
     },
     feeItemSpread:null,
@@ -308,7 +320,7 @@ let installationFeeObj={
             let feeItem = this.feeItemData[this.feeItemSheet.getSelections()[0].row];
             for(let i =0;i<this.feeDetailData.length;i++){
                 this.feeDetailSheet.autoFitRow(i);
-                this.setDetailRuleCell(i,this.feeDetailData[i]);//设置费用规则下拉选项
+                this.setComboRuleCell(i,1,this.feeDetailData[i],this.feeDetailSheet);//设置费用规则下拉选项
                 this.lockDetailSheet(i,this.feeDetailData[i],feeItem);
             }
             this.feeDetailSheet.resumeEvent();
@@ -330,7 +342,23 @@ let installationFeeObj={
             installationList = _.filter(ration_installation.datas, {'projectID': ration.projectID, 'rationID': ration.ID})
         }
         this.rationInstallData = installationList;
+        this.rationInstallSheet.setRowCount(0);
         sheetCommonObj.showData(this.rationInstallSheet, this.rationInstallSetting,this.rationInstallData);
+        if(this.rationInstallData.length>0){
+            this.rationInstallSheet.suspendPaint();
+            this.rationInstallSheet.suspendEvent();
+            for(let i = 0;i< this.rationInstallData.length;i++){
+                let impactRules = projectObj.project.installation_fee.getFeeRuleBySection({libID:this.rationInstallData[i].libID,ID:this.rationInstallData[i].sectionId});
+                this.setComboRuleCell(i,2,{impactRules:impactRules},this.rationInstallSheet);//设置费用规则下拉选项
+            }
+            this.rationInstallSheet.resumeEvent();
+            this.rationInstallSheet.resumePaint();
+        }
+    },
+    refreshRationInstallationRow:function (row) {
+        let ri = this.rationInstallData[row];
+        this.rationInstallData[row] = projectObj.project.ration_installation.getByID(ri.ID);
+        sheetCommonObj.showRowData(this.rationInstallSheet, this.rationInstallSetting,row,this.rationInstallData);
     },
     refreshFeeDetailRow:function (row) {
         let detail = this.feeDetailData[row];
@@ -356,7 +384,7 @@ let installationFeeObj={
             this.feeDetailSheet.getRange(row, 3, 1, this.feeDetailSetting.header.length-3, GC.Spread.Sheets.SheetArea.viewport).locked(true);
         }
     },
-    setDetailRuleCell:function(row,detail){
+    setComboRuleCell:function(row,col,detail,sheet){
         let options=[{text:"无",value:""}];
         for(let ir of detail.impactRules){
             options.push({text:ir.rule,value:ir.ID});
@@ -365,7 +393,7 @@ let installationFeeObj={
         let dynamicCombo = sheetCommonObj.getDynamicCombo();//new GC.Spread.Sheets.CellTypes.ComboBox();
         dynamicCombo.items(options);
         dynamicCombo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
-        this.feeDetailSheet.setCellType(row, 1, dynamicCombo, GC.Spread.Sheets.SheetArea.viewport);
+        sheet.setCellType(row, col, dynamicCombo, GC.Spread.Sheets.SheetArea.viewport);
     },
     getFeeItemData:function (datas) {
         let feeItemShowArray = [];
@@ -389,7 +417,7 @@ let installationFeeObj={
         return feeItemShowArray;
     },
     getDisplayText:function (item) {
-        if(item.billID){
+        if(item.billID&&item.billID!=''){
             let node = projectObj.project.mainTree.getNodeByID(item.billID);
             if(node){
                 return node.data.code +" "+node.data.name;
@@ -409,8 +437,16 @@ let installationFeeObj={
     },
     getMoreFeeRuleData:function () {
         let me = installationFeeObj;
-        let fee_select = me.feeItemSheet.getSelections()[0];
-        let feeItem = me.feeItemData[fee_select.row];
+        let feeItem = null;
+        let from = $("#more_from").val();
+        if(from =='feeDetail'){//在计取安装费那里点击更多
+            let fee_select = me.feeItemSheet.getSelections()[0];
+            feeItem = me.feeItemData[fee_select.row];
+        }else if(from == 'rationInstallation'){//在定额安装增加费那里点击更多
+            let ri_select = me.rationInstallSheet.getSelections()[0];
+            let ri = me.rationInstallData[ri_select.row];
+            feeItem = {ID:ri.feeItemId,libID:ri.libID};
+        }
         let feeRules =  projectObj.project.installation_fee.getFeeRuleByFeeItem(feeItem);
         return feeRules;
     },
@@ -464,10 +500,33 @@ let installationFeeObj={
         this.moreFeeRuleSheet.name('moreFeeRuleSheet');
     },
     initRationInstallSheet:function (sheet) {
+        let me = this;
         this.rationInstallSheet = sheet;
         this.initSheet( this.rationInstallSheet,this.rationInstallSetting);
+        sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onRationSheetSelectionChange);
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+           if(args.row>=me.rationInstallData.length){
+               args.cancel = true;
+           }
+        });
         this.rationInstallSheet.name("rationInstallSheet");
     },
+    onRationSheetSelectionChange: function (sender, args) {
+        let me = installationFeeObj;
+        let row = args.newSelections[0].row;
+        let col = args.newSelections[0].col;
+        let dataCode = me.rationInstallSetting.header[col].dataCode;
+        if(row<me.rationInstallData.length&&dataCode=='position'){
+            let locked = false;
+            if(me.rationInstallData[row].feeType=='子目费用'){
+                locked = true;
+            }else if(me.rationInstallData[row].unifiedSetting==1){
+                locked = true;
+            }
+            installationFeeObj.rationInstallSheet.getCell(row,col).locked(locked);
+        }
+        me.rationInstallSheet.repaint();
+    },
     onFeeRuleDoubleClick:function (e,info) {
         if(info.row!=undefined||info!=null){
             installationFeeObj.updateFeeRuleToSection(info.row);
@@ -550,28 +609,29 @@ let installationFeeObj={
             }
         }
     },
-    getBillDataForSelect:function () {
+    getBillDataForSelect:function () {//这里有三个地方共用
         let controller = projectObj.mainController, project = projectObj.project;
-        let selection = this.feeItemSheet.getSelections()[0];
         let from = $('#calc_position_from').val();
-        let feeItem = this.feeItemData[selection.row];
-        let rootNode = null;
-        let allNodes = [];
-        let datas = [];
-        let billID = null;
-        if(from =="feeItemSheet"){
-            if(feeItem.billID){
-                billID = feeItem.billID;
-            }
-        }
-        if(from =="feeDetailSheet") {
-            let detailSelection = this.feeDetailSheet.getSelections()[0];
-            let detail = this.feeDetailData[detailSelection.row];
-            if(detail.billID){
-                billID = detail.billID;
+        let rootNode = null,allNodes = [],datas = [],billID = null,feeItem=null;
+        if(from=="rationInstallSheet"){
+            let riSelection = this.rationInstallSheet.getSelections()[0];
+            feeItem = this.rationInstallData[riSelection.row];
+            billID = feeItem.billID;
+        }else {
+            let selection = this.feeItemSheet.getSelections()[0];
+            feeItem = this.feeItemData[selection.row];
+            if(from =="feeItemSheet"){
+                if(feeItem.billID){
+                    billID = feeItem.billID;
+                }
+            }else if(from =="feeDetailSheet") {
+                let detailSelection = this.feeDetailSheet.getSelections()[0];
+                let detail = this.feeDetailData[detailSelection.row];
+                if(detail.billID){
+                    billID = detail.billID;
+                }
             }
         }
-
         if(feeItem.feeType=='措施费用'){
             rootNode = project.Bills.getMeasureNode(controller);
         }else if(feeItem.feeType=='分项费用'){
@@ -616,10 +676,30 @@ let installationFeeObj={
                 this.updateFeeItemPosition(pobj.recode);
             }else if(from=='feeDetailSheet'){
                 this.updateFeeRulePosition(pobj.recode);
+            }else if(from=='rationInstallSheet'){
+                this.updateRationInstallPosition(pobj.recode);
             }
         }
         $("#calc_position").modal('hide');
     },
+    updateRationInstallPosition:function(recode){
+        let me = this;
+        let riselection = me.rationInstallSheet.getSelections()[0];
+        let rationInstall = me.rationInstallData[riselection.row];
+        if(rationInstall.billID == recode.ID){//和原来的位置没变
+            return
+        }
+        let updateData = {
+            projectID:rationInstall.projectID,
+            ID:rationInstall.ID,
+            position:recode.code,
+            billID:recode.ID
+        };
+        projectObj.project.ration_installation.update(updateData,function (data) {
+            me.refreshRationInstallationRow(riselection.row);
+        });
+
+    },
     updateFeeRulePosition:function (recode) {
         let me = this;
         let itemSelection  = this.feeItemSheet.getSelections()[0];
@@ -667,6 +747,20 @@ let installationFeeObj={
             $.bootstrapLoading.end();
         });
     },
+    updateFeeRuleToRInstall:function (row) {
+        let me = this;
+        let feeRule = me.moreFeeRuleData[row];
+        let ri_row = me.rationInstallSheet.getSelections()[0].row;
+        let raInstallation = me.rationInstallData[ri_row];
+        if(feeRule.ID ==raInstallation.ruleId ){
+            me.refreshRationInstallationRow(ri_row);
+            return;
+        }
+        let updateData = me.getRIRuleUpdateData(feeRule.ID,raInstallation);
+        projectObj.project.ration_installation.update(updateData,function (data) {
+            me.refreshRationInstallationRow(ri_row);
+        });
+    },
     updateFeeItemPosition:function(recode){
         let me = this;
         let selection = this.feeItemSheet.getSelections()[0];
@@ -713,6 +807,9 @@ let installationFeeObj={
         if(info.sheetName == 'feeDetailSheet'){
             installationFeeObj.onFeeDetailValueChange(e,info);
         }
+        if(info.sheetName == 'rationInstallSheet'){
+            installationFeeObj.onRationInstallValueChange(e,info);
+        }
     },
     onFeeItemValueChange:function (e,info) {
         let me = installationFeeObj;
@@ -729,6 +826,38 @@ let installationFeeObj={
             $.bootstrapLoading.end();
         });
     },
+    onRationInstallValueChange:function (e,info) {
+        let me = installationFeeObj;
+        if(info.newValue==info.oldValue){
+            return;
+        }
+        let updateData = null;
+        let raInstallation = me.rationInstallData[info.row];
+        let fieldID =  me.rationInstallSetting.header[info.col].dataCode;
+        if(fieldID=='ruleId'){//选择新的规则项
+            if(info.newValue=="more"){//选择的是更多
+                $("#more_from").val("rationInstallation");
+                $("#more_feeRule").modal({show:true});
+                return;
+            }
+            if(info.newValue == null){
+                me.refreshRationInstallationRow(info.row);
+            }else if(info.newValue == raInstallation.rule){
+                return;
+            }else {
+                updateData = me.getRIRuleUpdateData(info.newValue,raInstallation);
+            }
+        }else {
+            updateData = {
+                projectID:raInstallation.projectID,
+                ID:  raInstallation.ID
+            };
+            updateData[fieldID] = info.newValue;
+        }
+        projectObj.project.ration_installation.update(updateData,function (data) {
+            me.refreshRationInstallationRow(info.row);
+        });
+    },
     onFeeDetailValueChange:function (e,info) {
         if(info.newValue==info.oldValue){
             return;
@@ -740,6 +869,7 @@ let installationFeeObj={
         let updateData = null;
         if(fieldID == 'rule'){//选择新的规则项
             if(info.newValue=="more"){//选择的是更多
+                $("#more_from").val("feeDetail");
                 $("#more_feeRule").modal({show:true});
                 return;
             }
@@ -833,6 +963,38 @@ let installationFeeObj={
         }
         return canChange;
     },
+    getRIRuleUpdateData:function (newRuleID,rationInstallation) {
+        let data={
+            ID:rationInstallation.ID,
+            projectID:rationInstallation.projectID,
+            ruleId:newRuleID,
+            unifiedSetting:0
+        };
+        if(newRuleID==''){//选择的是无
+            data.code = '';
+            data.rule = '';
+            data.base = '';
+            data.feeRate = '';
+            data.labour = '';
+            data.material = '';
+            data.machine = '';
+            data.position = '';
+            data.billID = '';
+        }
+        let feeRule = projectObj.project.installation_fee.getFeeRuleByID(rationInstallation.libID,newRuleID);
+        if(feeRule){
+            data.code = feeRule.code;
+            data.rule = feeRule.rule;
+            data.base = feeRule.base;
+            data.feeRate = feeRule.feeRate;
+            data.labour = feeRule.labour;
+            data.material = feeRule.material;
+            data.machine = feeRule.machine;
+            data.position = feeRule.position;
+            data.billID = feeRule.billID;
+        }
+        return data;
+    },
     getDetailUpdateData : function (detail,doc,type) {//type:installSection/feeRule
         let installationFee = projectObj.project.installation_fee.getInstallationFeeByLibID(detail.libID);
         let updateData = {
@@ -932,45 +1094,40 @@ $(function () {
     $('#more_feeRule_confirm').click(function (){
         let me = installationFeeObj;
         let selections = me.moreFeeRuleSheet.getSelections();
+        let from = $("#more_from").val();
         $('#more_feeRule').modal('hide');
         if(selections.length>0){
-            me.updateFeeRuleToSection(selections[0].row);
+            if(from =='feeDetail'){
+                me.updateFeeRuleToSection(selections[0].row);
+            }else if(from == 'rationInstallation'){//在定额安装增加费那里点击更多
+                me.updateFeeRuleToRInstall(selections[0].row);
+            }
         }else {
-            me.refreshFeeDetailRow(me.feeDetailSheet.getSelections()[0].row);
+            if(from =='feeDetail') {//在计取安装费那里点击更多
+                me.refreshFeeDetailRow(me.feeDetailSheet.getSelections()[0].row);
+            }else if(from == 'rationInstallation'){//在定额安装增加费那里点击更多
+                me.refreshRationInstallationRow(me.rationInstallSheet.getSelections()[0].row);
+            }
         }
     });
     $('#more_feeRule_concel').click(function () {
         let me = installationFeeObj;
-        me.refreshFeeDetailRow(me.feeDetailSheet.getSelections()[0].row);
+        let from = $("#more_from").val();
+        if(from =='feeDetail'){//在计取安装费那里点击更多
+            me.refreshFeeDetailRow(me.feeDetailSheet.getSelections()[0].row);
+        }else if(from == 'rationInstallation'){//在定额安装增加费那里点击更多
+            me.refreshRationInstallationRow(me.rationInstallSheet.getSelections()[0].row);
+        }
     });
 
     $('#more_feeRule_close').click(function () {
         let me = installationFeeObj;
-        me.refreshFeeDetailRow(me.feeDetailSheet.getSelections()[0].row);
-    });
-/*    $('#testUpdate').click(function () {
-        let datas = [
-            {
-                type:'ration',
-                data:{
-                    projectID:1605,
-                    ID:"7b962fb0-1131-11e8-b3da-af725dadd7ae",
-                    name:'testRation000'
-                }
-            },
-            {
-                type:'bills',
-                data:{
-                    projectID:1605,
-                    ID:"af9f0081-1127-11e8-99a8-2fc02230b6e7",
-                    name:'安全文明施工专项费用'
-                }
-            }
-        ];
-        projectObj.project.updateNodes(datas,function (data) {
-            console.log(data);
-        });
-    });*/
-
+        let from = $("#more_from").val();
+        if(from =='feeDetail') {//在计取安装费那里点击更多
+            me.refreshFeeDetailRow(me.feeDetailSheet.getSelections()[0].row);
+        }else if(from == 'rationInstallation'){//在定额安装增加费那里点击更多
+            me.refreshRationInstallationRow(me.rationInstallSheet.getSelections()[0].row);
+        }
 
+    });
 });