Просмотр исходного кода

工料机形式定额,也要算三个价差费。

chenshilong 7 лет назад
Родитель
Сommit
0c283a9aaf
1 измененных файлов с 38 добавлено и 27 удалено
  1. 38 27
      web/building_saas/main/js/models/calc_program.js

+ 38 - 27
web/building_saas/main/js/models/calc_program.js

@@ -391,6 +391,43 @@ let assistCalcer = {
             return sumU
         else
             nodeTools.checkFeeField(treeNode, {'fieldName': 'estimate', 'unitFee': sumU, 'totalFee': sumT});
+    },
+    marketPriceToBase: function (treeNode, baseName) {
+        if (treeNode.data.type != rationType.volumePrice && treeNode.data.type != rationType.gljRation) return;
+        let result = 0, me = this;
+        if (
+            (treeNode.data.subType === gljType.LABOUR && baseName === '定额基价人工费') ||
+            (baseMaterialTypes.includes(treeNode.data.subType) && baseName === '定额基价材料费') ||
+            (treeNode.data.subType === gljType.GENERAL_MACHINE && baseName === '定额基价机械费') ||
+            (treeNode.data.subType === gljType.MAIN_MATERIAL && baseName === '主材费') ||
+            (treeNode.data.subType === gljType.EQUIPMENT && baseName === '设备费')) {
+            if (treeNode.data.type == rationType.volumePrice)
+                result = treeNode.data.marketUnitFee ? parseFloat(treeNode.data.marketUnitFee).toDecimal(decimalObj.ration.unitPrice) : 0
+            else if (treeNode.data.type == rationType.gljRation)
+                result = treeNode.data.basePrice ? parseFloat(treeNode.data.basePrice).toDecimal(decimalObj.ration.unitPrice) : 0;
+        }
+        else if (treeNode.data.subType === gljType.GENERAL_MACHINE && baseName === '定额基价机上人工费') {
+            let glj = {
+                'code': treeNode.data.code,
+                'name': treeNode.data.name,
+                'specs': treeNode.data.specs,
+                'unit': treeNode.data.unit,
+                'quantity': 1,
+                'type': treeNode.data.subType      // 注意:这里要取subType
+            };
+            result = assistCalcer.machineLabourFee([glj]);
+        }
+        else if (
+            (treeNode.data.type == rationType.gljRation) &&
+            ((treeNode.data.subType === gljType.LABOUR && baseName === '人工费价差') ||
+            (baseMaterialTypes.includes(treeNode.data.subType) && baseName === '材料费价差') ||
+            (treeNode.data.subType === gljType.GENERAL_MACHINE && baseName === '机械费价差'))
+        ) {
+            let aprice = me.uiGLJPrice(treeNode.data.adjustPrice);
+            let mprice = me.uiGLJPrice(treeNode.data.marketUnitFee);
+            result = (mprice - aprice).toDecimal(decimalObj.ration.unitPrice);
+        }
+        return result;
     }
 };
 
@@ -624,36 +661,10 @@ let executeObj = {
     },
     base: function(baseName) {
         let me = executeObj;
-        function marketPriceToBase(baseName, type) {
-            let result = 0;
-            if (
-                (me.treeNode.data.subType === gljType.LABOUR && baseName === '定额基价人工费') ||
-                (baseMaterialTypes.includes(me.treeNode.data.subType) && baseName === '定额基价材料费') ||
-                (me.treeNode.data.subType === gljType.GENERAL_MACHINE && baseName === '定额基价机械费') ||
-                (me.treeNode.data.subType === gljType.MAIN_MATERIAL && baseName === '主材费') ||
-                (me.treeNode.data.subType === gljType.EQUIPMENT && baseName === '设备费')) {
-                if (type == rationType.volumePrice)
-                    result = me.treeNode.data.marketUnitFee ? parseFloat(me.treeNode.data.marketUnitFee).toDecimal(decimalObj.ration.unitPrice) : 0
-                else if (type == rationType.gljRation)
-                    result = me.treeNode.data.basePrice ? parseFloat(me.treeNode.data.basePrice).toDecimal(decimalObj.ration.unitPrice) : 0;
-            }
-            else if (me.treeNode.data.subType === gljType.GENERAL_MACHINE && baseName === '定额基价机上人工费'){
-                let glj = {
-                    'code': me.treeNode.data.code,
-                    'name': me.treeNode.data.name,
-                    'specs': me.treeNode.data.specs,
-                    'unit': me.treeNode.data.unit,
-                    'quantity': 1,
-                    'type': me.treeNode.data.subType      // 注意:这里要取subType
-                };
-                result = assistCalcer.machineLabourFee([glj]);
-            }
-            return result;
-        };
 
         // 量价、工料机形式的定额, 要把自己的市场单价用于计算程序中的基数。
         if (me.treeNode.data.type == rationType.volumePrice || me.treeNode.data.type == rationType.gljRation)
-            return marketPriceToBase(baseName, me.treeNode.data.type)
+            return assistCalcer.marketPriceToBase(me.treeNode, baseName)
         else{
             if (!rationCalcBaser[baseName]){
                 alert('定额基数“' + baseName + '”末定义,计算错误。 (模板 ' + me.template.ID + ',规则 ' + me.tempCalcItem.ID +')');