Kaynağa Gözat

组成物的“部分甲供”

chenshilong 7 yıl önce
ebeveyn
işleme
7676d357da
1 değiştirilmiş dosya ile 25 ekleme ve 23 silme
  1. 25 23
      web/building_saas/main/js/models/calc_program.js

+ 25 - 23
web/building_saas/main/js/models/calc_program.js

@@ -443,6 +443,11 @@ let calcTools = {
                 if(supply.code == composition.code && supply.name == composition.name && supply.unit == composition.unit &&
                     supply.specs == composition.specs && supply.type == composition.type ){
                     composition.basePrice = supply.unit_price.base_price;
+                    if (supply.supply == supplyType.BFJG){
+                        composition.supply = supply.supply;
+                        let Q = supply.quantity ? supply.quantity : 1;
+                        composition.supplyX = supply.supply_quantity / Q;
+                    }
                     return true;
                 }
             };
@@ -451,37 +456,34 @@ let calcTools = {
 
         let sum = 0;
         for (let glj of treeNode.data.gljList){
-            // 组成物的母体。母体如果有组成物,则母体无法作为甲供材料,无法设置,此时要看其组成物是否是甲供材料;母体如果没有组成物,则母体有可能成为甲供材料。
-            if (compT.includes(glj.type)) {
-                if (supplyGLJsIdx[glj.projectGLJID]) {  // 组成物的母体是甲供材料
-                    sum = (sum + glj.basePrice * glj.quantity).toDecimal(decimalObj.process);
+            let X = 1;    // 部分甲供系数(默认1,即完全甲供)
+            let tempSGLJ = supplyGLJsIdx[glj.projectGLJID];
+            // 当前材料是甲供材料:①普通 ②商品硂等不计组成物的母体材料
+            if (tempSGLJ) {
+                // 处理部分甲供
+                if (baseName.includes('甲供') && (tempSGLJ.supply == supplyType.BFJG)){
+                    let Q = tempSGLJ.quantity ? tempSGLJ.quantity : 1;
+                    X = tempSGLJ.supply_quantity / Q;
                 }
-                else{  // 组成物明细
+                sum = (sum + glj.basePrice * glj.quantity * X).toDecimal(decimalObj.process);
+            }
+            else{   // 当前材料不是甲供材料
+                if (compT.includes(glj.type)) {   // 混凝土等。组成物的母体,母体如果有组成物,则母体无法作为甲供材料,无法设置,此时要看其组成物是否是甲供材料;母体如果没有组成物,则母体有可能成为甲供材料。
                     let pGLJ = projectGLJ.getDataByID(glj.projectGLJID);
-                    let compositions = pGLJ.ratio_data;
+                    let compositions = pGLJ.ratio_data;    // 组成物明细
                     if (compositions.length > 0){
                         for (let c of compositions){
                             if (isSupply(c, supplyGLJs)) {
-                                sum = (sum + c.basePrice * c.consumption * glj.quantity).toDecimal(decimalObj.process);
+                                X = 1;
+                                if (baseName.includes('甲供') && (c.supply == supplyType.BFJG)){
+                                    X = c.supplyX;
+                                };
+                                sum = (sum + c.basePrice * c.consumption * glj.quantity * X).toDecimal(decimalObj.process);
                             }
-                        };
-                    }
-                }
-            }
-            else {
-                let tempSGLJ = supplyGLJsIdx[glj.projectGLJID];
-                if (tempSGLJ) {
-                    // 处理部分甲供
-                    if (baseName.includes('甲供') && (tempSGLJ.supply == supplyType.BFJG)){
-                        let Q = tempSGLJ.quantity ? tempSGLJ.quantity : 1;
-                        let X = tempSGLJ.supply_quantity / Q;
-                        sum = (sum + glj.basePrice * glj.quantity * X).toDecimal(decimalObj.process);
-                    }
-                    else
-                        sum = (sum + glj.basePrice * glj.quantity).toDecimal(decimalObj.process);
+                        }
+                    };
                 }
             };
-
         };
         sum = sum.toDecimal(decimalObj.ration.unitPrice);
         return sum;