zhongzewei před 7 roky
rodič
revize
81a73b5f58

+ 12 - 10
modules/ration_repository/models/ration_item.js

@@ -288,6 +288,7 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, callback) {
                     }
                 }
                 gljDao.getStdCompleGljItems(compleGljIds, stdGljIds, function (err, allGljs) {
+                    const processDecimal = -6;
                     if(err){
                         cb(err);
                     }
@@ -349,21 +350,21 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, callback) {
                             if(labourPrc.length > 0){
                                 let sumLaP = 0;
                                 for(let i=0; i<labourPrc.length; i++){
-                                    sumLaP += labourPrc[i];
+                                    sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], processDecimal);
                                 }
                                 updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
                             }
                             if(materialPrc.length > 0){
                                 let sumMtP = 0;
                                 for(let i= 0; i<materialPrc.length; i++){
-                                    sumMtP += materialPrc[i];
+                                    sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], processDecimal);
                                 }
                                 updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
                             }
                             if(machinePrc.length > 0){
                                 let sumMaP = 0;
                                 for(let i =0; i< machinePrc.length; i++){
-                                    sumMaP += machinePrc[i];
+                                    sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], processDecimal);
                                 }
                                 updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
                             }
@@ -518,6 +519,7 @@ rationItemDAO.prototype.updateAnnotation = function (lastOpr, repId, updateArr,
 
 //计算导入数据的价格
 rationItemDAO.prototype.calcForRation = function (stdGljList, ration) {
+    const processDecimal = -6;
     //根据工料机类型划分价格
     const labour = [1],  material = [201, 202, 203, 204, 205, 206], machine = [301, 302, 303];
     let labourPrc = [], materialPrc = [], machinePrc = [], singlePrc, updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, basePrice: 0};
@@ -542,25 +544,25 @@ rationItemDAO.prototype.calcForRation = function (stdGljList, ration) {
     if(labourPrc.length > 0){
         let sumLaP = 0;
         for(let i = 0, len  = labourPrc.length; i < len; i++){
-            sumLaP += labourPrc[i];
+            sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], processDecimal);
         }
         updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
     }
     //材料费
     if(materialPrc.length > 0){
-        let sumLaP = 0;
+        let sumMtP = 0;
         for(let i = 0, len  = materialPrc.length; i < len; i++){
-            sumLaP += materialPrc[i];
+            sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], processDecimal);
         }
-        updatePrc.materialPrice = scMathUtil.roundTo(sumLaP, -2);
+        updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
     }
     //机械费
     if(machinePrc.length > 0){
-        let sumLaP = 0;
+        let sumMaP = 0;
         for(let i = 0, len  = machinePrc.length; i < len; i++){
-            sumLaP += machinePrc[i];
+            sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], processDecimal);
         }
-        updatePrc.machinePrice = scMathUtil.roundTo(sumLaP, -2);
+        updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
     }
     //基价
     updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.materialPrice + updatePrc.machinePrice, -2);

+ 4 - 3
web/maintain/ration_repository/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,
@@ -443,7 +444,7 @@ 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;
@@ -452,7 +453,7 @@ var rationGLJOprObj = {
             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;
@@ -461,7 +462,7 @@ var rationGLJOprObj = {
             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;