浏览代码

projSetting, zanguCalcMode

MaiXinRong 7 年之前
父节点
当前提交
42ad20967d

+ 6 - 3
modules/main/models/proj_setting_model.js

@@ -3,7 +3,7 @@
  */
 
 let baseModel = require('./base_model');
-import {default as projSettingSchema, collectionName as collectionName, billsCalcModeConst as billsCalcModeConst} from "./schemas/proj_setting";
+import {default as projSettingSchema, collectionName as collectionName, settingConst as settingConst} from "./schemas/proj_setting";
 
 class projSettingModel extends baseModel {
 
@@ -17,9 +17,12 @@ class projSettingModel extends baseModel {
             if (!err) {
                 let data = JSON.parse(JSON.stringify(result));
                 if (!data.billsCalcMode) {
-                    data.billsCalcMode = billsCalcModeConst.rationContent;
+                    data.billsCalcMode = settingConst.billsCalcMode.rationContent;
                 }
-                data.billsCalcModeConst = billsCalcModeConst;
+                if (!data.zanguCalcMode) {
+                    data.zanguCalcMode = settingConst.zanguCalcMode.common;
+                }
+                data.settingConst = settingConst;
                 callback(0, collectionName, data);
             } else {
                 callback(1, '查询数据失败。', null);

+ 15 - 3
modules/main/models/schemas/proj_setting.js

@@ -5,8 +5,16 @@
 let mongoose = require("mongoose");
 let Schema = mongoose.Schema;
 let collectionName = 'proj_setting';
+let settingConst = {
+    billsCalcMode: {
+        rationContent: 0, rationPrice: 1, rationPriceConverse: 2, billsPrice: 3
+    },
+    zanguCalcMode: {
+        common: 0, gatherMaterial: 1
+    }
+}
 let billsCalcModeConst = {
-    rationContent: 0, rationPrice: 1, rationPriceConverse: 2, billsPrice: 3
+    
 };
 let projSettingSchema = {
     projectID: Number,
@@ -17,9 +25,13 @@ let projSettingSchema = {
     },
     billsCalcMode: {
         type: Number,
-        default: billsCalcModeConst.rationContent
+        default: settingConst.billsCalcMode.rationContent
         // rationContent = 0, rationPrice = 1, rationPriceConverse = 2, billsPrice = 3
+    },
+    zanguCalcMode: {
+        type: Number,
+        default: settingConst.zanguCalcMode.common
     }
 };
 let model = mongoose.model(collectionName, new Schema(projSettingSchema, {versionKey: false, collection: collectionName}));
-export {model as default, collectionName as collectionName, billsCalcModeConst as billsCalcModeConst};
+export {model as default, collectionName as collectionName, settingConst as settingConst};

+ 18 - 2
web/building_saas/main/html/main.html

@@ -413,7 +413,7 @@
                                 <li class="nav-item"><a class="nav-link active" data-toggle="pill" href="#poj-settings-1" role="tab">基本信息</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-2" role="tab">工程特征</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-3" role="tab">指标信息</a></li>
-                                <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-4" role="tab">取费方式</a></li>
+                                <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-4" role="tab">关于计算</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-5" role="tab">清单工程精度</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-6" role="tab" id="tab_poj-settings-6">人工单价调整</a></li>
                             </ul>
@@ -438,10 +438,11 @@
                                         指标信息
                                     </div>
                                 </div>
-                                <!--取费方式-->
+                                <!--关于计算-->
                                 <div class="tab-pane fade" id="poj-settings-4" role="tabpanel">
                                     <div class="modal-auto-height">
                                         <fieldset class="form-group">
+                                            <h5>取费方式</h5>
                                             <div class="form-check">
                                                 <label class="form-check-label">
                                                     <input class="form-check-input" name="calcFlag" id="rationContent" value="0" type="radio">
@@ -467,6 +468,21 @@
                                                 </label>
                                             </div>
                                         </fieldset>
+                                        <fieldset class="form-group">
+                                            <h5>暂估合价计算方式</h5>
+                                            <div class="form-check">
+                                                <label class="form-check-label">
+                                                    <input class="form-check-input" name="zangu" id="zangu_common" value="0" type="radio">
+                                                    暂估合价=暂估单价×定额工程量
+                                                </label>
+                                            </div>
+                                            <div class="form-check">
+                                                <label class="form-check-label">
+                                                    <input class="form-check-input" name="zangu" id="zangu_gatherMaterial" value="1" type="radio">
+                                                    暂估合价=∑暂估材料数量×暂估材料单价
+                                                </label>
+                                            </div>
+                                        </fieldset>
                                     </div>
                                 </div>
                                 <!--清单工程精度-->

+ 26 - 9
web/building_saas/main/js/calc/bills_calc.js

@@ -4,8 +4,13 @@
 
 const rationContent = 0, rationPrice = 1, rationPriceConverse = 2, billsPrice = 3;
 
+// sumTotalFeeFlag: sum(child.totalFee), totalFeeFlag: bills.quantity × bills.unitFee
 const sumTotalFeeFlag = 0, totalFeeFlag = 1;
-const rationContentUnitFeeFlag = 0, averageQtyUnitFeeFlag = 1, billsPriceUnitFeeFlag = 2;
+// rationContentUnitFeeFlag: sum(child.unitFee * child.quantity / bills.quantity)
+// averageQtyUnitFeeFlag: sum(child.totalFee/bills.quantity)
+// billsPriceUnitFeeFlag: 根据定额计算程序
+// converseUnitFeeFalg: bills.totalFee / bills.quantity
+const rationContentUnitFeeFlag = 0, averageQtyUnitFeeFlag = 1, billsPriceUnitFeeFlag = 2, converseUnitFeeFlag = 3;
 
 let rationContentCalcFields = [
     {'type': 'common', 'unitFeeFlag': rationContentUnitFeeFlag, 'totalFeeFlag': totalFeeFlag},
@@ -83,6 +88,15 @@ let nodeCalcObj = {
             result += (childUnitFee * childQuantity / qty).toDecimal(this.digit);
         }
         return result;
+    },
+    converseUnitFee: function (digit) {
+        let totalFee = this.sumTotalFee().toDecimal(digit);
+        let qty = this.getFee(this.node.data, 'quantity');
+        if (qty !== 0){
+            return totalFee / qty;
+        } else {
+            return 0;
+        }
     }
 };
 
@@ -251,7 +265,7 @@ class BillsCalcHelper {
         nodeCalcObj.node = node;
         nodeCalcObj.digit = this.project.Decimal.unitFee;
         calcFees.checkFields(node.data, fields);
-        let nodeCalc = nodeCalcObj, virData= null;
+        let nodeCalc = nodeCalcObj, virData= null, decimal = this.project.Decimal;
 
         // 清单单价:套用定额计算程序
         if (this.project.calcFlag === billsPrice) {
@@ -265,24 +279,27 @@ class BillsCalcHelper {
             nodeCalcObj.field = field;
             switch (field.unitFeeFlag) {
                 case rationContentUnitFeeFlag:
-                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.rationContentUnitFee().toDecimal(this.project.Decimal.common.unitFee);
+                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.rationContentUnitFee().toDecimal(decimal.common.unitFee);
                     break;
                 case averageQtyUnitFeeFlag:
-                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.averageQty().toDecimal(this.project.Decimal.common.unitFee);
+                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.averageQty().toDecimal(decimal.common.unitFee);
+                    break;
+                case billsPriceUnitFeeFlag:
+                    node.data.feesIndex[field.type].unitFee = virData[field.type];
+                    break;
+                case converseUnitFeeFlag:
+                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.converseUnitFee(decimal.common.totalFee).toDecimal(decimal.common.unitFee);
                     break;
-                 case billsPriceUnitFeeFlag:
-                     node.data.feesIndex[field.type].unitFee = virData[field.type];
-                     break;
                 default:
                     node.data.feesIndex[field.type].unitFee = 0;
             }
             let value = 0;
             switch (field.totalFeeFlag) {
                 case sumTotalFeeFlag:
-                    value = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
+                    value = nodeCalcObj.sumTotalFee().toDecimal(decimal.common.totalFee);
                     break;
                 case totalFeeFlag:
-                    value = nodeCalcObj.totalFee().toDecimal(this.project.Decimal.common.totalFee);
+                    value = nodeCalcObj.totalFee().toDecimal(decimal.common.totalFee);
                     break;
                 default:
                     value = 0;

+ 1 - 0
web/building_saas/main/js/calc/calc_fees.js

@@ -27,6 +27,7 @@ let feeType = [
     {type: 'common', name: '工程造价'},
     {type: 'adjustLabour', name: '调整人工费'},
     {type: 'adjustMachineLabour', name: '调整机上人工费'},
+    {type: 'zangu', name: '暂估'},
     // 模拟用户新增
     {type: 'fee1', name: '甲供材料费'}
 ];

+ 12 - 7
web/building_saas/main/js/models/project.js

@@ -295,19 +295,24 @@ var PROJECT = {
         };
 
         project.prototype.initCalcFields = function () {
+            let settingConst = this.projSetting.settingConst;
             if (this.calcFields) {
                 for (let field of this.calcFields) {
                     // unitFeeCalcFlag
-                    if (this.projSetting.billsCalcMode === this.projSetting.billsCalcModeConst.rationContent) {
-                        field.unitFeeFlag = rationContentUnitFeeFlag;
-                    } else if ( this.projSetting.billsCalcMode === this.projSetting.billsCalcModeConst.billsPrice) {
-                        field.unitFeeFlag = billsPriceUnitFeeFlag;
-                    } else {
-                        field.unitFeeFlag = averageQtyUnitFeeFlag;
+                    if (field.type === 'zangu') {
+                        field.unitFeeFlag = converseUnitFeeFlag;
+                    } else {   
+                        if (this.projSetting.billsCalcMode === settingConst.billsCalcMode.rationContent) {
+                            field.unitFeeFlag = rationContentUnitFeeFlag;
+                        } else if ( this.projSetting.billsCalcMode === settingConst.billsCalcMode.billsPrice) {
+                            field.unitFeeFlag = billsPriceUnitFeeFlag;
+                        } else {
+                            field.unitFeeFlag = averageQtyUnitFeeFlag;
+                        }
                     }
                     // totalFeeCalcFlag
                     if (field.type === 'common') {
-                        if (this.projSetting.billsCalcMode === this.projSetting.billsCalcModeConst.rationPriceConverse) {
+                        if (this.projSetting.billsCalcMode === settingConst.billsCalcMode.rationPriceConverse) {
                             field.totalFeeFlag = sumTotalFeeFlag;
                         } else {
                             field.totalFeeFlag = totalFeeFlag;

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

@@ -548,16 +548,30 @@ $('#poj-set').on('show.bs.modal', function () {
     }
     if (projectObj.project) {
         let mode = projectObj.project.projSetting.billsCalcMode;
-        setCalcFlag($('#rationContent'), projectObj.project.projSetting.billsCalcModeConst.rationContent, mode);
-        setCalcFlag($('#rationPrice'), projectObj.project.projSetting.billsCalcModeConst.rationPrice, mode);
-        setCalcFlag($('#rationPriceConverse'), projectObj.project.projSetting.billsCalcModeConst.rationPriceConverse, mode);
-        setCalcFlag($('#billsPrice'), projectObj.project.projSetting.billsCalcModeConst.billsPrice, mode);
+        let settingConst = projectObj.project.projSetting.settingConst;
+        setCalcFlag($('#rationContent'), settingConst.billsCalcMode.rationContent, mode);
+        setCalcFlag($('#rationPrice'), settingConst.billsCalcMode.rationPrice, mode);
+        setCalcFlag($('#rationPriceConverse'), settingConst.billsCalcMode.rationPriceConverse, mode);
+        setCalcFlag($('#billsPrice'), settingConst.billsCalcMode.billsPrice, mode);
+
+        mode = projectObj.project.projSetting.zanguCalcMode;
+        setCalcFlag($('#zangu_common'), settingConst.zanguCalcMode.common, mode);
+        setCalcFlag($('#zangu_gatherMatherial'), settingConst.zanguCalcMode.gatherMaterial, mode);
     }
 });
 $('#property_ok').click(function () {
-    let project = projectObj.project, mode = parseInt($("input[name='calcFlag']:checked").val());
+    let project = projectObj.project, reCalc= false;
+    let mode = parseInt($("input[name='calcFlag']:checked").val());
+    let zanguMode = parseInt($("input[name='zangu']:checked").val());
     if (mode !== project.projSetting.billsCalcMode) {
         project.setBillsCalcMode(mode);
+        reCalc = true;
+    }
+    if (zanguMode !== project.projSetting.zanguCalcMode) {
+        project.projSetting.zanguCalcMode = zanguMode;
+        reCalc = true;
+    }
+    if (reCalc) {
         projectObj.calculateAll();
         project.pushNow('editBillsCalcMode',
             [project.projSetting.moduleName, project.Bills.getSourceType()],