Explorar o código

量价类代码优化

chenshilong %!s(int64=5) %!d(string=hai) anos
pai
achega
c99e9837a9
Modificáronse 1 ficheiros con 13 adicións e 9 borrados
  1. 13 9
      web/building_saas/main/js/models/calc_program.js

+ 13 - 9
web/building_saas/main/js/models/calc_program.js

@@ -156,6 +156,10 @@ let calcTools = {
     isGljRation: function (treeNode) {
         return this.isRationCategory(treeNode) && treeNode.data.type === rationType.gljRation;
     },
+    isVP_or_GLJR: function (treeNode) {       // 是量价或工料机类型的定额
+        return this.isRationCategory(treeNode) &&
+            (treeNode.data.type == rationType.volumePrice || treeNode.data.type == rationType.gljRation);
+    },
     isSameTypeNode: function (node1, node2) {
         if (node1.parent && node2.parent && (node1.parent === node2.parent) && (node1.sourceType === node1.sourceType)
             && (node1.data && node2.data && node1.data.type === node2.data.type)){
@@ -203,7 +207,7 @@ let calcTools = {
     getGLJList: function (treeNode, needOneBill) {
         delete treeNode.data.gljList;
         if (this.isRationCategory(treeNode)) {
-            if (treeNode.data.type != rationType.volumePrice) {
+            if (!calcTools.isVP_or_GLJR(treeNode)){
                 treeNode.data.gljList = projectObj.project.calcProgram.getGljArrByRation(treeNode.data);
             }
         }
@@ -211,7 +215,7 @@ let calcTools = {
             let nodeQ = this.uiNodeQty(treeNode);
             let q = nodeQ ? nodeQ : 1;
             let allNodes = projectObj.project.Ration.getRationNodes(treeNode);
-            let rNodes = allNodes.filter(function (node) {return node.data.type != rationType.volumePrice});
+            let rNodes = allNodes.filter(function (node) {return calcTools.isRationItem(node)});
             let rations = rNodes.map(function (node) {return node.data});
             treeNode.data.gljList = projectObj.project.ration_glj.getGatherGljArrByRations(rations, needOneBill, q);
         };
@@ -662,7 +666,7 @@ let calcTools = {
             'tenderUnitFee': sumTU, 'tenderTotalFee': sumTT});
     },
     marketPriceToBase: function (treeNode, baseName, isTender) {
-        if (treeNode.data.type != rationType.volumePrice && treeNode.data.type != rationType.gljRation) return;
+        if (!calcTools.isVP_or_GLJR(treeNode)) return;
         let result = 0, me = this;
 
         function isRCJZC(treeNode, baseName) {         // 基数名称中是否包含人材机主设,且树结点类型要匹配一致
@@ -701,7 +705,7 @@ let calcTools = {
         }
         else {
             if (isRCJZC(treeNode, baseName)) {
-                if (treeNode.data.type == rationType.volumePrice){
+                if (calcTools.isVolumePrice(treeNode)){
                     if (isTender){
                         let coe = this.tenderCoe_GLJPrice();
                         if (treeNode.data.marketUnitFee)
@@ -712,7 +716,7 @@ let calcTools = {
                     else
                         result = treeNode.data.marketUnitFee ? parseFloat(treeNode.data.marketUnitFee).toDecimal(decimalObj.ration.unitPrice) : 0
                 }
-                else if (treeNode.data.type == rationType.gljRation)
+                else if (calcTools.isGljRation(treeNode))
                 // result = treeNode.data.basePrice ? parseFloat(treeNode.data.basePrice).toDecimal(decimalObj.ration.unitPrice) : 0;
                 // 这里因为是算基数所以要取基价,但不能直接取basePrice,受限于项目属性的三个选项。
                     result = gljOprObj.getBasePrice(treeNode);
@@ -954,7 +958,7 @@ let calcTools = {
             2020-04-05 注: 以上是老黄历。新思路是量价只作为定额调整,不作为工料机调整。两种反调模式下,统一都只调子目消耗量系数。
             为避免歧义,量价的工料机调整系数不允许输入。
             */
-            // if (treeNode.data.type == rationType.volumePrice || treeNode.data.type == rationType.gljRation){
+            // if (calcTools.isVP_or_GLJR(treeNode)){
             //     if (treeNode.data.rationQuantityCoe)
             //         qCoe = treeNode.data.rationQuantityCoe
             //     else if (treeNode.data.quantityCoe && treeNode.data.quantityCoe.labour)
@@ -1566,7 +1570,7 @@ let executeObj = {
         let me = executeObj;
 
         // 量价、工料机形式的定额, 要把自己的市场单价用于计算程序中的基数。
-        if (calcTools.isVolumePrice(me.treeNode) || calcTools.isGljRation(me.treeNode))
+        if (calcTools.isVP_or_GLJR(me.treeNode))
             return calcTools.marketPriceToBase(me.treeNode, baseName, isTender)
         else{
             if (!rationCalcBases[baseName]){
@@ -2000,7 +2004,7 @@ class CalcProgram {
 
             if (treeNode.calcType == treeNodeCalcType.ctRationCalcProgram) {
                 // 量价、工料机类型的定额要求市场合价
-                if (treeNode.data.type == rationType.volumePrice || treeNode.data.type == rationType.gljRation){
+                if (calcTools.isVP_or_GLJR(treeNode)){
                     let muf = treeNode.data.marketUnitFee ? treeNode.data.marketUnitFee : 0;
                     let mtf = (muf * nQ).toDecimal(decimalObj.ration.totalPrice);
                     if (treeNode.data.marketTotalFee != mtf){
@@ -2335,7 +2339,7 @@ class CalcProgram {
             coe = (treeNode.data.targetUnitFee / treeNode.data.feesIndex.common.unitFee).toDecimal(decimalObj.process);
 
         // 调价情况之————量价反调工料机(量价无工料机可调,还是按定额来调,即直接调树结点的消耗量)
-        let isVP_RevGLJ =(tender == tenderTypes.ttReverseGLJ) && (treeNode.data.type == rationType.volumePrice || treeNode.data.type == rationType.gljRation);
+        let isVP_RevGLJ =(tender == tenderTypes.ttReverseGLJ) && calcTools.isVP_or_GLJR(treeNode);
 
         if ((tender == tenderTypes.ttReverseRation) || isVP_RevGLJ){
             treeNode.data.tenderQuantity = (treeNode.data.quantity * coe).toDecimal(decimalObj.decimal("quantity", treeNode));