浏览代码

采用清单单价取费时,清单下与定额同级的量价,需要虚拟成工料机参与计算。

chenshilong 7 年之前
父节点
当前提交
e74519396c
共有 1 个文件被更改,包括 27 次插入11 次删除
  1. 27 11
      web/building_saas/main/js/models/ration_glj.js

+ 27 - 11
web/building_saas/main/js/models/ration_glj.js

@@ -67,15 +67,20 @@ var ration_glj = {
                 return null;
             }
             for (let ration of rations) {
-                let rationGljs = this.getGljArrByRation(ration.ID);
-                for (let glj of rationGljs) {
-                    let sameGlj = findGlj(glj, result);
-                    if (!sameGlj) {
-                        sameGlj = clone(glj);
-                        sameGlj.quantity = (sameGlj.quantity * ration.quantity).toDecimal(4);
-                        result.push(sameGlj);
-                    } else {
-                        sameGlj.quantity = sameGlj.quantity + (glj.quantity * ration.quantity).toDecimal(4);
+                if (ration.type == rationType.volumePrice || ration.type == rationType.gljRation){
+                    result.push(ration);
+                }
+                else{
+                    let rationGljs = this.getGljArrByRation(ration.ID);
+                    for (let glj of rationGljs) {
+                        let sameGlj = findGlj(glj, result);
+                        if (!sameGlj) {
+                            sameGlj = clone(glj);
+                            sameGlj.quantity = (sameGlj.quantity * ration.quantity).toDecimal(4);
+                            result.push(sameGlj);
+                        } else {
+                            sameGlj.quantity = sameGlj.quantity + (glj.quantity * ration.quantity).toDecimal(4);
+                        }
                     }
                 }
             }
@@ -83,9 +88,20 @@ var ration_glj = {
             result = gljOprObj.combineWithProjectGlj(result);
 
             // 上面取的是清单下所有工料机的总量,我要算清单单价,所以要取单位清单的工料机数量,所以下面要除以清单数量。
-            let oneBill = Array.from(result);
+            let oneBill = JSON.parse(JSON.stringify(result));
+
             for (let glj of oneBill){
-                  glj.quantity = (glj.quantity / billQuantity).toDecimal(decimalObj.glj.quantity);
+                if (glj.type == rationType.volumePrice){  // 量价、工料机形式的定额要进行数据变换才能参与基数计算。
+                    glj.type = glj.subType;
+                    glj.basePrice = glj.marketUnitFee;
+                    glj.marketPrice = glj.marketUnitFee;
+                    glj.adjustPrice = glj.marketUnitFee;
+                }
+                else if (glj.type == rationType.gljRation){
+                    glj.type = glj.subType;
+                };
+
+                glj.quantity = (glj.quantity / billQuantity).toDecimal(decimalObj.glj.quantity);
             };
             return oneBill;
         }