瀏覽代碼

process decimal

zhongzewei 7 年之前
父節點
當前提交
72fe91e700

+ 3 - 1
web/building_saas/complementary_glj_lib/js/gljComponent.js

@@ -4,6 +4,7 @@
 
 let gljComponentOprObj = {
     workBook: null,
+    processDecimal: -6,
     setting: {
         owner: "gljComponent",
         header:[
@@ -498,7 +499,8 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj, gljBasePrc = 0;
         for(let i = 0; i < component.length; i++){
             let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
-            gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2) + gljBasePrc, -2);
+            let roundConsumeAmt = scMathUtil.roundTo(parseFloat(component[i].consumeAmt), -3);
+            gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljBasePrc, me.processDecimal);
         }
         return gljBasePrc;
     }

+ 7 - 6
web/building_saas/complementary_ration_lib/js/ration_glj.js

@@ -2,6 +2,7 @@
  * Created by Tony on 2017/4/28.
  */
 var rationGLJOprObj = {
+    processDecimal: -6,
     sheet: null,
     currentRationItem: null,
     distTypeTree: null,
@@ -436,29 +437,29 @@ var rationGLJOprObj = {
             if(price.gljType1.length > 0){
                 let labourPrice = 0;
                 price.gljType1.forEach(function (singlePrc) {
-                    labourPrice += singlePrc;
+                    labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, me.processDecimal);
                 });
                 let roundPrice = scMathUtil.roundTo(labourPrice, -2);
                 rst.labourPrice = roundPrice;
-                rationBasePrc += roundPrice;
+                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
             }
             if(price.gljType2.length > 0){
                 let materialPrice = 0;
                 price.gljType2.forEach(function (singlePrc) {
-                    materialPrice += singlePrc;
+                    materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, me.processDecimal);
                 });
                 let roundPrice = scMathUtil.roundTo(materialPrice, -2);
                 rst.materialPrice = roundPrice;
-                rationBasePrc += roundPrice;
+                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
             }
             if(price.gljType3.length > 0){
                 let machinePrice = 0;
                 price.gljType3.forEach(function (singlePrc) {
-                    machinePrice += singlePrc;
+                    machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, me.processDecimal);
                 });
                 let roundPrice = scMathUtil.roundTo(machinePrice, -2);
                 rst.machinePrice = roundPrice;
-                rationBasePrc += roundPrice;
+                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
             }
             rst.rationBasePrc = rationBasePrc;
         }