Browse Source

工料机汇总中的计算系数,新增“机械不变费用系数”。 在清单和定额行,新增右键“按清单名称插入材料”,在“插入工料机”之后。

zhangweicheng 5 years ago
parent
commit
de9a5adae1

+ 1 - 0
modules/all_models/unit_price_file.js

@@ -28,6 +28,7 @@ let modelSchema = {
     root_project_id: Number,
     vvTaxFileID:String,//车船税文件ID
     assistProductionFeeRate:String,//辅助生产间接费费率
+    machineConstCoe:String,//机械不变费用系数
     deleteInfo: deleteSchema
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

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

@@ -945,7 +945,8 @@ async function getGLJListByProjectID(projectId){
             usedUnitPriceInfo: usedUnitPriceInfo,
             gljTypeMap:gljTypeMap,
             vvTaxFileID:unitFileInfo.vvTaxFileID,
-            assistProductionFeeRate:unitFileInfo.assistProductionFeeRate?unitFileInfo.assistProductionFeeRate:3
+            assistProductionFeeRate:unitFileInfo.assistProductionFeeRate?unitFileInfo.assistProductionFeeRate:3,
+            machineConstCoe:unitFileInfo.machineConstCoe?unitFileInfo.machineConstCoe:1
         };
     } catch (error) {
         console.log(error);

+ 2 - 2
modules/glj/facade/glj_facade.js

@@ -126,9 +126,9 @@ async function changeVvTaxFile(data){//对于车船税,现在只是在组成
 }
 
 async function changeAssistProductionFeeRate(data){
-    let unitFileID = data.unitFileID,assistProductionFeeRate = data.assistProductionFeeRate;
+    let unitFileID = data.unitFileID;//assistProductionFeeRate = data.assistProductionFeeRate;
     let unitPriceFileModel = new UnitPriceFileModel();
-    await unitPriceFileModel.model.update({id:unitFileID},{assistProductionFeeRate:assistProductionFeeRate});
+    await unitPriceFileModel.model.update({id:unitFileID},data.updateData);
 }
 
 async function handleVvTaxForChang(unitFileID,newVvTaxFileID) {//切换车船税,选择共用的单价文件时调用

+ 13 - 4
public/web/gljUtil.js

@@ -314,11 +314,17 @@ let gljUtil = {
     let price_hasM_decimal = decimalObj.glj.unitPriceHasMix ? decimalObj.glj.unitPriceHasMix : decimalObj.glj.unitPrice;
     let quantity_decimal = decimalObj.glj.quantity;
     let process_decimal = this.isDef(decimalObj.marketPriceProcess) ? decimalObj.marketPriceProcess : decimalObj.process; //20200722  旧的项目还是默认6位,新的用两位
+    let feeRate_decimal = decimalObj.feeRate;
     let priceCoe = this.isDef(tenderCoe) ? tenderCoe : 1;
     if (priceCoe == '0' || priceCoe == 0) priceCoe = 1; // 这里加个保护
     if (['GLF', 'LR', 'FXF'].includes(glj.code)) priceCoe = 1; // 类型是“企业管理费”、“利润”、“一般风险费”的,不应调整单价。
     if (!this.isConcreteType(glj.unit_price.type) && this.notEditType.indexOf(glj.unit_price.type) != -1 && glj.ratio_data.length > 0) { //对于机械台班等有组成物的材料,价格需根据组成物计算得出(排除混凝土、配合比、砂浆这几个类型直接为0)。
       let p = 0;
+      let consSum = 0; //不变费用总和
+      let temSum = 0;//可变费用总和
+      //不变费用组成物包括:折旧费、检修费、维护费、安拆辅助费,这几个材料只能通过名称判断了,类型没有细分。
+      let constNames = ['折旧费','检修费','维护费','安拆辅助费'];
+      let constCoe = scMathUtil.roundForObj(projectGLJDatas.constData.machineConstCoe,feeRate_decimal);
       for (let ratio of glj.ratio_data) {
         let rIndex = gljUtil.getIndex(ratio);
         let tem = _.find(projectGLJDatas.gljList, function (item) {
@@ -329,15 +335,18 @@ let gljUtil = {
           if (ext && ext[tem.id] && this.isDef(ext[tem.id].marketPrice)) { //在修改组成物的价格或消耗量时,影响了父工料机的价格,这时以父工料机的价格应当用组成物的新值来记算
             tem_marketPrice = ext[tem.id].marketPrice;
           };
-
-
           let temP = scMathUtil.roundForObj(tem_marketPrice * priceCoe, price_decimal) * scMathUtil.roundForObj(ratio.consumption, quantity_decimal);
           if(decimalObj.temProcess) temP = scMathUtil.roundForObj(temP, decimalObj.temProcess);//取两次防止中间过程使用两位导致 4舍5入后少0.01的情况
           temP = scMathUtil.roundForObj(temP,process_decimal);
-          p = scMathUtil.roundForObj(temP + p, process_decimal);
+          if(constNames.includes(tem.name) && constCoe !== 1){//不等于1的时候才要另外计算
+            temP = scMathUtil.roundForObj(temP*constCoe,process_decimal);
+            consSum = scMathUtil.roundForObj(temP + consSum,process_decimal);
+          }else {
+            temSum = scMathUtil.roundForObj(temP + temSum, process_decimal);
+          }
         }
       }
-      return scMathUtil.roundForObj(p, price_hasM_decimal);
+      return scMathUtil.roundForObj(temSum + consSum, price_hasM_decimal);
     } else {
       let tem_decimal = price_decimal; //isRadio==true?process_decimal:price_decimal;
       let tem_price = scMathUtil.roundForObj(glj.unit_price.market_price, price_decimal);

+ 4 - 0
web/building_saas/glj/html/project_glj.html

@@ -252,6 +252,10 @@
             </div>
             <div class="modal-body">
                 <div class="form-group">
+                    <label id = "machineConstCoeLabel">机械不变费用系数</label>
+                    <input class="form-control" id="machineConstCoe" value="">
+                </div>
+                <div class="form-group">
                     <label id = "assistProductionLabel">辅助生产间接费费率(%)</label>
                     <input class="form-control" id="assistProductionFeeRate" value="">
                 </div>

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

@@ -1,3 +1,4 @@
+
 /**
  * 工料机汇总相关数据
  *
@@ -831,11 +832,11 @@ ProjectGLJ.prototype.addMaterialRation = async function (code,type,parentID,conn
         await this.updateMaterialRation(datas);
 };
 
-ProjectGLJ.prototype.changeAssistProductionFeeRate = async function (newFeeRate) {
+ProjectGLJ.prototype.changeAssistProductionFeeRate = async function (updateData) {//newFeeRate  机械不变费用系数 和 辅助生产间接费费率(%) 计算放一起
     $.bootstrapLoading.start();
     try {
-        await ajaxPost("/glj/changeAssistProductionFeeRate",{unitFileID:projectObj.project.property.unitPriceFile.id,assistProductionFeeRate:newFeeRate});
-        this.datas.constData.assistProductionFeeRate = newFeeRate;
+        await ajaxPost("/glj/changeAssistProductionFeeRate",{unitFileID:projectObj.project.property.unitPriceFile.id,updateData:updateData});
+        gljUtil.setProperty(this.datas.constData,updateData) //this.datas.constData.assistProductionFeeRate = newFeeRate;
         //todo  调用材料计算方法,所有材料重算一遍
         let [unitPrices,sumMap] = this.calcAllMaterial([],true);
         sumMap["unitPrice"] = unitPrices;

+ 4 - 3
web/building_saas/main/js/models/ration.js

@@ -532,14 +532,14 @@ var Ration = {
                 }
             }
         };
-        ration.prototype.insertVolumePrice = function(type){
+        ration.prototype.insertVolumePrice = function(type,ext){
             this.addNewRation(null,rationType.volumePrice,function (newNode) {//插入人工不需要自动定位到编号列
                 projectObj.selectColAndFocus(newNode,null);
-            },true,type);
+            },true,type,true,ext);
         };
 
 
-        ration.prototype.addNewRation = function (itemQuery,rationType,callback=null,isEmpty=false,priceType,needCalcAndSave=true) {//priceType 是量价类型
+        ration.prototype.addNewRation = function (itemQuery,rationType,callback=null,isEmpty=false,priceType,needCalcAndSave=true,ext) {//priceType 是量价类型
             let me = this;
             let project = projectObj.project, sheetController = projectObj.mainController;
             let engineering = projectObj.project.projectInfo.property.engineering;
@@ -586,6 +586,7 @@ var Ration = {
                     let billsNode = project.mainTree.getNodeByID(billItemID);
                     needInstall = project.Bills.isFBFX(billsNode);//在分部分项插入的定额才需要定额安装增加费
                 }
+                if(ext) gljUtil.setProperty(newData,ext);
               $.bootstrapLoading.start();
                 let tdata = {
                   projectID: me.project.ID(),

+ 17 - 3
web/building_saas/main/js/views/material_calc_view.js

@@ -1055,16 +1055,30 @@ $(function () {
     $('#calcCoeDiv').on('show.bs.modal', function () {
         if(materialCalcObj.getAssistProductionLabel) $("#assistProductionLabel").text(materialCalcObj.getAssistProductionLabel);
         $("#assistProductionFeeRate").val(scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.assistProductionFeeRate,getDecimal("feeRate")));
+        $("#machineConstCoe").val(scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.machineConstCoe,getDecimal("feeRate")));
+        
     })
     $("#calcCoeConfirm").click(function () {
         let feeRate =  $("#assistProductionFeeRate").val();
-        if(!number_util.isNum(feeRate)){
+        let constCoe = $("#machineConstCoe").val();
+        let rawFeeRate = scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.assistProductionFeeRate,getDecimal("feeRate"));
+        let rawConstCoe = scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.machineConstCoe,getDecimal("feeRate"));
+        if(!number_util.isNum(rawFeeRate)){
             alert("输入的数据类型不对,请重新输入!");
-           return $("#assistProductionFeeRate").val(scMathUtil.roundForObj(projectObj.project.projectGLJ.datas.constData.assistProductionFeeRate,getDecimal("feeRate")));
+           return $("#assistProductionFeeRate").val(rawFeeRate);
         }
+        if(!number_util.isNum(constCoe)){
+           alert("输入的数据类型不对,请重新输入!");
+           return $("#machineConstCoe").val(rawConstCoe);
+        }
+        let updateData = {};
         feeRate = scMathUtil.roundForObj(feeRate,getDecimal("feeRate"));
+        constCoe = scMathUtil.roundForObj(constCoe,getDecimal("feeRate"));
+        if(feeRate != rawFeeRate) updateData.assistProductionFeeRate = feeRate;
+        if(constCoe != rawConstCoe) updateData.machineConstCoe = constCoe;
+
         $("#calcCoeDiv").modal("hide");
-        projectObj.project.projectGLJ.changeAssistProductionFeeRate(feeRate);
+        if(!_.isEmpty(updateData))projectObj.project.projectGLJ.changeAssistProductionFeeRate(updateData);
     });
 
     $("#insertFreightconfirm").click(function () {

+ 19 - 0
web/building_saas/main/js/views/project_view.js

@@ -1384,6 +1384,25 @@ var projectObj = {
                         return false
                     }
                 },
+                "insertMaterial": {
+                    name: "按清单名称插入材料",//插入量价不需要自动定位到编号列
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
+                        return !project.Ration.canAdd(project.mainTree.selected);
+                    },
+                    callback: function (key, opt) {
+                        //名称取清单名称,单位取清单单位
+                        let selected = project.mainTree.selected;
+                        let billNode = selected;
+                        if(selected.sourceType==project.Ration.getSourceType()) billNode = selected.parent;
+                        let ext = {name:billNode.data.name,unit:billNode.data.unit};
+                        project.Ration.insertVolumePrice(gljType.GENERAL_MATERIAL,ext);
+                    },
+                },
+
                 "insertLJ": {
                     name: "插入量价",//插入量价不需要自动定位到编号列
                     icon: 'fa-sign-in',