gaoluyang
2 天以前 05c6ee06af8164aea9346368875c539f253a89b9
src/workers/InspectionWorker.worker.js
@@ -227,8 +227,6 @@
      break;
    }
  }
  let isToExponential = ""; //是否为科学计数法
  let list2 = []; //一个数组,里面保存有当前检验项的所有参数值
  let isPoint = ""; //是否为小数点
  let inputType = null;
  let currentInsItemId = "";
@@ -262,7 +260,6 @@
                    break;
                  }
                }
                list2.push(c.v.v);
                // 组装参数的对象集合并赋值,列如{A3:12,B4:15}
                if (
                  (getInspectionValueType(item.i) == 1 ||
@@ -341,22 +338,7 @@
            }
            // 根据输入的数值,进行计算
            comResult = compute(item.v.f.replace(/=/g, " "), comValue, isPoint);
            // 检验项为密度时,根据要求值的小数位改变最终值的小数位
            if (inspectionItem == "密度") {
              const str = "" + tell;
              const indexOfDecimal = str.indexOf(".");
              if (indexOfDecimal > -1) {
                const length = str.length - indexOfDecimal - 1;
                comResult = comResult.toFixed(length);
              }
            } else if (
              inspectionItemClass == "外护套机械物理性能" &&
              inspectionItem == "在IRM 902矿物油中浸泡后" &&
              (inspectionItemSubclass == "断裂伸长率变化率" ||
                inspectionItemSubclass == "抗张强度变化率")
            ) {
              comResult = Math.round(comResult).toFixed(0);
            } else if (
            if (
              typeof comResult == "string" &&
              (comResult.includes("断裂") || comResult.includes("脆化"))
            ) {
@@ -384,15 +366,6 @@
            }
            if (isHaveSymbol) {
              comResult = symbol + comResult;
            }
            let list3 = list2.map((item) => item + "");
            // 判断填的检验值是否为科学计数法,如果为科学计数法,则进行转化
            isToExponential = list3.some(
              (val) => val.includes("e+") || val.includes("e-")
            );
            if (isToExponential) {
              let num2 = new Big(comResult);
              comResult = num2.toExponential(1);
            }
          } else {
            // 如果检验值类型是文本输入框、下拉框
@@ -432,45 +405,7 @@
              // 判断当前行是否为当前检验项所在行,如果为当前行,则给表格数据赋值
              for (var b in a) {
                if (a[b].c == item.c) {
                  try {
                    if (comResult == 0) {
                      // 判断计算结果是否为0,如果为0,则给表格数据赋值为0
                      a[b].v.v = 0;
                    } else if (
                      a[b].v.ct &&
                      a[b].v.ct.fa &&
                      typeof a[b].v.ct.fa == "string" &&
                      a[b].v.ct.fa.includes(".")
                    ) {
                      // 判断当前单元格是否保留小数点,如果为保留小数点,则给表格数据赋值为保留小数点,这个是根据模板配置小数点来的
                      let num = 0;
                      let str = a[b].v.ct.fa.split(".")[1];
                      num = str.length;
                      a[b].v.v = comResult
                        ? Number(comResult).toFixed(num)
                        : comResult;
                    } else if (
                      typeof comResult == "string" &&
                      (comResult.includes("e+") || comResult.includes("e-"))
                    ) {
                      // 判断计算结果是否为科学计数法,如果为科学计数法,则给表格数据赋值为科学计数法
                      a[b].v.v = comResult;
                    } else {
                      const inspectionItem = findInsItem(item.i).inspectionItem;
                      // 判断计算结果是否为数字,如果为数字,则给表格数据赋值为数字
                      if (inspectionItem == "铜线电阻率ρ20最大值") {
                        let val = parseFloat(Number(comResult).toFixed(5));
                        a[b].v.v = isNaN(val) ? comResult : val;
                      } else {
                        let val = parseFloat(Number(comResult).toFixed(3));
                        a[b].v.v = isNaN(val) ? comResult : val;
                      }
                    }
                  } catch (error) {
                    // 如果以上判断都不支持,则直接赋值
                    a[b].v.v = comResult;
                    console.log("error---", error);
                  }
                  a[b].v.v = comResult;
                  hasComputedWrite = true;
                  break;
                }