Browse Source

默认2位小数

chenshilong 7 years ago
parent
commit
c1d83dedf8
1 changed files with 12 additions and 6 deletions
  1. 12 6
      web/building_saas/pm/js/pm_main.js

+ 12 - 6
web/building_saas/pm/js/pm_main.js

@@ -1661,17 +1661,23 @@ function setDataToSideBar() {
         // CSL, 2018-01-11 汇总单项工程、建设项目。
         function calcNode(node){
             if (node.data.projType == projectType.project || node.data.projType == projectType.engineering){
-                node.data.summaryFees = {totalFee: 0, estimateFee: 0, safetyFee: 0, chargeFee: 0};
+                node.data.summaryFees = {totalFee: 0.00, estimateFee: 0.00, safetyFee: 0.00, chargeFee: 0.00};
                 for (let child of node.children){
                     calcNode(child);
-                    node.data.summaryFees.totalFee = parseFloat(node.data.summaryFees.totalFee) + parseFloat(child.data.summaryFees.totalFee);
-                    node.data.summaryFees.estimateFee = parseFloat(node.data.summaryFees.estimateFee) + parseFloat(child.data.summaryFees.estimateFee);
-                    node.data.summaryFees.safetyFee = parseFloat(node.data.summaryFees.safetyFee) + parseFloat(child.data.summaryFees.safetyFee);
-                    node.data.summaryFees.chargeFee = parseFloat(node.data.summaryFees.chargeFee) + parseFloat(child.data.summaryFees.chargeFee);
+                    node.data.summaryFees.totalFee = (parseFloat(node.data.summaryFees.totalFee) + parseFloat(child.data.summaryFees.totalFee)).toFixed(2);
+                    node.data.summaryFees.estimateFee = (parseFloat(node.data.summaryFees.estimateFee) + parseFloat(child.data.summaryFees.estimateFee)).toFixed(2);
+                    node.data.summaryFees.safetyFee = (parseFloat(node.data.summaryFees.safetyFee) + parseFloat(child.data.summaryFees.safetyFee)).toFixed(2);
+                    node.data.summaryFees.chargeFee = (parseFloat(node.data.summaryFees.chargeFee) + parseFloat(child.data.summaryFees.chargeFee)).toFixed(2);
                 };
             }else{
                 if (!node.data.summaryFees)
-                    node.data.summaryFees = {totalFee: 0, estimateFee: 0, safetyFee: 0, chargeFee: 0};
+                    node.data.summaryFees = {totalFee: 0.00, estimateFee: 0.00, safetyFee: 0.00, chargeFee: 0.00}
+                else{
+                    node.data.summaryFees.totalFee = parseFloat(node.data.summaryFees.totalFee).toFixed(2);
+                    node.data.summaryFees.estimateFee = parseFloat(node.data.summaryFees.estimateFee).toFixed(2);
+                    node.data.summaryFees.safetyFee = parseFloat(node.data.summaryFees.safetyFee).toFixed(2);
+                    node.data.summaryFees.chargeFee = parseFloat(node.data.summaryFees.chargeFee).toFixed(2);
+                }
             };
         };