Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

zhangweicheng 7 years ago
parent
commit
c48733a872

+ 1 - 1
modules/users/routes/boot_route.js

@@ -13,6 +13,6 @@ module.exports=function (app){
     let bootController = new BootController();
 
 // 引导页面
-    router.get('/:compilation', bootController.boot);
+    router.get('/:compilation', bootController.init, bootController.boot);
     app.use('/boot', router);
 };

+ 44 - 18
web/building_saas/main/js/calc/bills_calc.js

@@ -40,7 +40,11 @@ let nodeCalcObj = {
     sumTotalFee: function() {
         let result = 0, child;
         for (child of this.node.children) {
-            result += this.getFee(child.data, this.field.totalFee);
+            let value = this.getFee(child.data, this.field.totalFee);
+            if (Object.prototype.toString.apply(value) === "[object String]") {
+                value = parseFloat(value);
+            }
+            result += value;
         }
         return result;
     },
@@ -48,6 +52,9 @@ let nodeCalcObj = {
         let result = 0, child, qty;
         result = this.sumTotalFee(this.field);
         qty = this.getFee(this.node.data, 'quantity');
+        if (Object.prototype.toString.apply(qty) === "[object String]") {
+            qty = parseFloat(qty);
+        }
         if (qty !== 0) {
             result = result / qty;
         }
@@ -58,11 +65,22 @@ let nodeCalcObj = {
     },
     rationContentUnitFee: function () {
         let result = 0, child, qty = this.getFee(this.node.data, 'quantity');
+        if (Object.prototype.toString.apply(qty) === "[object String]") {
+            qty = parseFloat(qty);
+        }
         if (qty === 0) {
             qty = 1;
         }
         for (child of this.node.children) {
-            result += (this.getFee(child.data, this.field.unitFee) * this.getFee(child.data, 'quantity') / qty).toDecimal(this.digit);
+            let childUnitFee = this.getFee(child.data, this.field.unitFee);
+            if (Object.prototype.toString.apply(childUnitFee) === "[object String]") {
+                childUnitFee = parseFloat(childUnitFee);
+            }
+            let childQuantity = this.getFee(child.data, 'quantity');
+            if (Object.prototype.toString.apply(childQuantity) === "[object String]") {
+                childQuantity = parseFloat(childQuantity);
+            }
+            result += (childUnitFee * childQuantity / qty).toDecimal(this.digit);
         }
         return result;
     }
@@ -220,21 +238,26 @@ class BillsCalcHelper {
     constructor (project, CalcFlag) {
         this.project = project;
         this.CalcFlag = CalcFlag;
-        switch (this.CalcFlag) {
-            case rationContent:
-                this.calcField = rationContentCalcFields;
-                break;
-            case rationPrice:
-                this.calcField = rationPriceCalcFields;
-                break;
-            case rationPriceConverse:
-                this.calcField = rationPriceConverseCalcFields;
-                break;
-            case billsPrice:
-                this.calcField = billsPriceCalcFields;
-                break;
-            default:
-                this.calcField = [];
+        this.calcField = JSON.parse(JSON.stringify(feeType));
+        for (let field of this.calcField) {
+            // unitFeeCalcFlag
+            if (this.calcFlag === rationContent) {
+                field.unitFeeFlag = rationContentUnitFeeFlag;
+            } else if ( this.calcFlag === billsPrice) {
+                field.unitFeeFlag = billsPriceUnitFeeFlag;
+            } else {
+                field.unitFeeFlag = averageQtyUnitFeeFlag;
+            }
+            // totalFeeCalcFlag
+            if (field.type === 'common') {
+                if (this.CalcFlag === rationPriceConverse) {
+                    field.totalFeeFlag = sumTotalFeeFlag;
+                } else {
+                    field.totalFeeFlag = totalFeeFlag;
+                }
+            } else {
+                field.totalFeeFlag = sumTotalFeeFlag;
+            }
         }
         this.InitFields(this.calcField);
     };
@@ -289,7 +312,10 @@ class BillsCalcHelper {
         }
     };
     calcVolumePriceLeaf (node, fields) {
-
+        let total = 0;
+        for (let child of this.node.children) {
+            total += this.getFee(child.data, 'feesIndex.common.totalFee');
+        }
     };
     calcParent (node, fields) {
         nodeCalcObj.node = node;

+ 2 - 10
web/building_saas/main/js/controllers/project_controller.js

@@ -104,18 +104,10 @@ ProjectController = {
         }
     },
     calculateAll: function (project, sheetController, CalcType) {
-        let date0 = new Date();
-        let ration_calc = new RationCalcHelper(project);
-        ration_calc.calculateAll();
-        let date1 = new Date();
-        console.log(date1 - date0);
         let calc = new BillsCalcHelper(project, CalcType);
         calc.calcAll();
-        calc = null;
-        let date2 = new Date();
-        console.log(date2 - date1);
         sheetController.showTreeData();
-        let date3 = new Date();
-        console.log(date3 - date1);
+        project.Bills.updateAll();
+        calc = null;
     }
 }

+ 23 - 0
web/building_saas/main/js/models/bills.js

@@ -74,6 +74,10 @@ var Bills = {
                 data.feesIndex = {};
                 if (data.fees) {
                     data.fees.forEach(function (fee) {
+                        fee.unitFee = parseFloat(fee.unitFee);
+                        fee.totalFee = parseFloat(fee.totalFee);
+                        fee.tenderUnitFee = parseFloat(fee.tenderUnitFee);
+                        fee.tenderTotalFee = parseFloat(fee.tenderTotalFee);
                         data.feesIndex[fee.fieldName] = fee;
                     });
                 }
@@ -236,6 +240,25 @@ var Bills = {
             this.project.pushNow('updateBills', this.getSourceType(), updateData);
         };
 
+        bills.prototype.updateAll = function () {
+            let updateData = [];
+            for (let data of this.datas) {
+                let uData = JSON.parse(JSON.stringify(data));
+                delete uData.feesIndex;
+                delete uData.flagsIndex;
+                if (uData.fees) {
+                    for (let fee of uData.fees) {
+                        fee.unitFee = fee.unitFee.toFixed(2);
+                        fee.totalFee = fee.totalFee.toFixed(2);
+                        fee.tenderUnitFee = fee.tenderUnitFee.toFixed(2);
+                        fee.tenderTotalFee = fee.tenderTotalFee.toFixed(2);
+                    }
+                }
+                updateData.push({'updateType': 'ut_update', 'updateData': data});
+            }
+            this.project.pushNow('updateAllBills', this.getSourceType(), updateData);
+        }
+
         return new bills(project);
     }
 };

+ 1 - 1
web/building_saas/main/js/views/main_tree_col.js

@@ -139,4 +139,4 @@ $('#column').on('hide.bs.modal', function () {
     }
     SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
     projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
-})
+});

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

@@ -133,7 +133,6 @@ let subViewObj = {
             if (node.sourceType === projectObj.project.Bills.getSourceType()) {
                 $('#comments>textarea').val(node.data.comments)
             } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
-                console.log(node.data);
                 $('#comments>textarea').val(node.data.content);
             }
         }

+ 0 - 1
web/users/html/login-infoinput.html

@@ -61,7 +61,6 @@
                         </div>
                     </div>
                     <div class="form-group">
-                        <input type="hidden" name="version" value="<%= version %>"/>
                         <button class="btn btn-primary btn-block" type="submit">下一步</button>
                     </div>
                 </div>