Browse Source

feat(types): 修改项目料机类型

zhangweicheng 4 years ago
parent
commit
09dc8a07cd
2 changed files with 11 additions and 4 deletions
  1. 1 1
      types/src/interface/glj.ts
  2. 10 3
      wise-cost-util/src/material.ts

+ 1 - 1
types/src/interface/glj.ts

@@ -229,7 +229,7 @@ export interface IProjectGlj {
   infoPrice?: number | null; // 信息价
   infoPrice?: number | null; // 信息价
   purchaseFeeRate?: number; // 采保费率
   purchaseFeeRate?: number; // 采保费率
   from: FromType; // std, cpt  来自标准工料机库、补充工料机库
   from: FromType; // std, cpt  来自标准工料机库、补充工料机库
-  matchedInfoPrice?: IInfoPriceItem; // 材料检查后匹配到的信息价
+  matchedInfoPrice?: IInfoPriceItem|null; // 材料检查后匹配到的信息价
 }
 }
 
 
 export interface IProjectGljs {
 export interface IProjectGljs {

+ 10 - 3
wise-cost-util/src/material.ts

@@ -41,9 +41,16 @@ export const calcMaterialExp = (infoPrice: IInfoPriceMain, keywordItems: IKeywor
         if (group) {
         if (group) {
           // 运距=15km  这种类型的要特殊处理 暂时没有办法处理~ 没法从编号中获取具体要加减多少
           // 运距=15km  这种类型的要特殊处理 暂时没有办法处理~ 没法从编号中获取具体要加减多少
           const operator = group.coe.charAt(0); // 加 减 乘的操作
           const operator = group.coe.charAt(0); // 加 减 乘的操作
-          let coeNumber = parseFloat(group.coe.substr(1)); // 要代入计算的系数
-          if (operator === '*') coeNumber -= 1;
-          expString = replaceAll(option.charAt(0), `${coeNumber}`, expString);
+          const coeNumber = parseFloat(group.coe.substr(1)); // 要代入计算的系数
+          let replaceStr = '';
+          if (operator === '*') {
+            // 乘法时,自减1
+            replaceStr = `${coeNumber - 1}`;
+          } else {
+            // + 或者 - 操作符时,使用 (+10) 或者 (-10)来替换,
+            replaceStr = `(${group.coe})`;
+          }
+          expString = replaceAll(option.charAt(0), replaceStr, expString);
           matchKeywords.push(group);
           matchKeywords.push(group);
         }
         }
         startIndex += 3;
         startIndex += 3;