taro+vue3+nutui开发微信小程序,数据跳闪问题?

新手上路,请多包涵

现在有个问题表单的每一项通过接口返回的配置,动态渲染,而这有个方法用来计算用户输入的内容进行处理计算逻辑,用户在使用过程中会发生输入太快或者删除,会出现数据跳闪,我初步排查是用户输入的上次数据正在计算,然后用户继续输入,导致用户输入完,上次计算结果也完成了,导致数据覆盖

            <scroll-view :scroll-y="true" class="dataCardScroll">
              <nut-form v-if="continuedDataByTimeSingle.length > 0">
                <view
                  v-for="(item, index) in continuedDataByTimeSingle"
                  :key="index"
                  :class="
                    item.sampleType === null || item.sampleType === -1
                      ? 'dataCardspecial'
                      : 'dataCard'
                  "
                >
                  <nut-row style="height: 0; overflow: visible">
                    <nut-col span="12" style="height: 0; overflow: visible">
                      <div class="cardNumber">
                        {{ index + 1 }}
                      </div>
                    </nut-col>
                    <!-- <nut-col span="12" style="height:0;overflow: visible;"> 
                      <nut-button class="cardRefButton" plain size="small" type="success" @click="showRefPop">引用其他卡片</nut-button>
                    </nut-col> -->
                  </nut-row>
                  <nut-row
                    v-for="(element, indexC) in widgetControl?.continuedWidget"
                    :key="indexC"
                  >
                    <!-- <nut-col span="2" class="cardApplyButton" @click="showBigInput(element?.model,item[element?.model],element?.label,item)"> 
                      <IconFont name="share-n" size="24rpx"></IconFont>
                    </nut-col> -->
                    <nut-col span="20">
                      <GControl
                        :use-comps="comps[element?.type]"
                        :modelValue="item[element?.model]"
                        :element="element"
                        :rowIndex="index"
                        :onUpdatePopup="showPopCard"
                        :readonly="element?.model.indexOf('sampling_no') > -1"
                        @update:modelValue="
                          (v) =>
                            inputChange(v, item, element?.model, element?.label)
                        "
                        :onUpdateModelValue="
                          (v) =>
                            inputChange(v, item, element?.model, element?.label)
                        "
                      />
                    </nut-col>
                    <!-- 每个项目后面的同步图标 -->
                    <nut-col
                      span="4"
                      class="cardApplyButton"
                      @click="
                        applyToOther(
                          element?.model,
                          item[element?.model],
                          element?.label
                        )
                      "
                    >
                      <IconFont name="retweet" size="30rpx"></IconFont>
                    </nut-col>
                  </nut-row>
                </view>
              </nut-form>
            </scroll-view>
/**
 * 处理输入变化并触发更新
 *
 * @param {any} v - 输入的新值
 * @param {Object} item - 需要被修改的目标对象(会被直接修改)
 * @param {string} id - 对应对象中被修改的属性名
 * @param {string} label - 可能用于显示的标签/标识符(实际未在函数内使用)
 * @returns {void} 无返回值
 */
const inputChange = (v, item, id, label) => {
  // 将新值 v 直接赋给目标对象的指定属性(item[id] = v)
  item[id] = v;
  // 调用全局变更处理器,透传相关参数
  handleChange(v, id, item, id, label);
};
// 计算,根据字段变化
const handleChange = (
  $event: any, // 当前字段的新值
  fieldKey: string,
  item: any, // 当前卡片数据字段集合
  fiedldId: any, // 当前字段的ID
  fieldName: any // 当前字段的名称
) => {
  // 更新表格里面数据
  const dataArrays = continuedData.value;
  // item.label = fieldName;

  const record = item;
  const columnsValue = item;
  fieldKey = fiedldId;

  // columnsValue[fieldKey] = $event;
  // 获取计算规则的基础数据
  let detectionLimit = ""; // 检出限
  let keepDecimals = 0;
  let SignificantDigit: any;
  let smallTimes: any;
  const columnsValueArr = Object.entries(columnsValue);
  columnsValueArr.forEach((itemValue: any) => {
    if (
      startsWith(itemValue[0], "detection_limit") &&
      !startsWith(itemValue[0], "detection_limit_unit")
    ) {
      // eslint-disable-next-line prefer-destructuring
      detectionLimit = itemValue[1];
      const arr = detectionLimit.toString().split(".");
      keepDecimals = arr.length > 1 ? arr[1].length : 0;
    }
    if (startsWith(itemValue[0], "smallSignificantDigit")) {
      // eslint-disable-next-line prefer-destructuring
      SignificantDigit = itemValue[1];
    }
    if (startsWith(itemValue[0], "smallTimes")) {
      // eslint-disable-next-line prefer-destructuring
      smallTimes = itemValue[1];
    }
  });
  // 获取计算规则的基础数据结束
  // 更新dataMap
  // eslint-disable-next-line no-use-before-define
  // dataToMap(dataArrays);
  // 甲烷、总烃、非甲烷总烃的计算
  if (startsWith(fieldName, "仪器读数") || startsWith(fieldName, "氧峰扣除")) {
    const rowDataArr = Object.entries(columnsValue);
    let samplingNo: any;
    let detectionItemNameKey: any;
    rowDataArr.forEach((itemValue: any) => {
      if (startsWith(itemValue[0], "sampling_no")) {
        // eslint-disable-next-line prefer-destructuring
        samplingNo = itemValue[1];
      }
      if (startsWith(itemValue[0], "detection_item_name")) {
        // eslint-disable-next-line prefer-destructuring
        detectionItemNameKey = itemValue[0];
        if (itemValue[1] === "甲烷" || itemValue[1] === "总烃") {
          // console.log(dataMap.get(samplingNo));
          const valueArr = dataMap.get(samplingNo);
          let jwValue: number;
          let ztValue: number;
          let fjwztRow: any = {};
          valueArr.forEach((valueData: any) => {
            if (valueData[detectionItemNameKey] === "总烃") {
              ztValue = valueData[fieldKey];
            }
            if (valueData[detectionItemNameKey] === "甲烷") {
              jwValue = valueData[fieldKey];
            }
            if (valueData[detectionItemNameKey] === "非甲烷总烃") {
              fjwztRow = valueData;
            }
            if (jwValue && ztValue && fjwztRow) {
              let tempCalResult = (((ztValue - jwValue) * 12) / 16).toFixed(3);
              if (Number.isNaN(tempCalResult)) {
                tempCalResult = "/";
              }
              fjwztRow[fieldKey] = tempCalResult;
              // 再计算真实浓度
              const formDataMap = new Map<string, any>(
                Object.entries(fjwztRow)
              );
              const calFormDataMap = new Map<string, any>(
                Object.entries(getCalculationData())
              );
              if (!isEmpty(calFormDataMap)) {
                // eslint-disable-next-line no-restricted-syntax
                for (const [key, value] of calFormDataMap.entries()) {
                  formDataMap.set(key, value);
                }
              }

              const calValue = CalculationHandler.calc(
                needToCalCMap,
                formDataMap
              );
              const calValueArr = Object.entries(calValue);
              calValueArr.forEach((calV: any) => {
                // eslint-disable-next-line prefer-destructuring
                fjwztRow[calV[0]] = calV[1];
              });
              // 计算非甲烷浓度时,也可能存在平均值的计算
              needToCalCMap.forEach((calcValue: any) => {
                if (startsWith(calcValue.label, "浓度值")) {
                  // eslint-disable-next-line no-use-before-define
                  calcAandPc(fjwztRow, fjwztRow, fiedldId, fieldName);
                  // 计算加标测定值
                  if (
                    amountKey &&
                    spikedMeasurementValueKey &&
                    columnsValue[amountKey] &&
                    (columnsValue[calcValue.model] ||
                      columnsValue[calcValue.model] === 0) &&
                    ((record.sampleType === 1 &&
                      dataJbMap.get(record.businessId)) ||
                      record.sampleType === 2 ||
                      record.parallelType === 5)
                  ) {
                    // columnsValue[spikedMeasurementValueKey] =
                    //   Number(columnsValue[calcValue.model]) *
                    //   Number(columnsValue[amountKey]);
                    if (Number.isNaN(Number(columnsValue[calcValue.model]))) {
                      columnsValue[spikedMeasurementValueKey] = 0;
                    } else {
                      const jbValue =
                        Number(columnsValue[calcValue.model]) *
                        Number(columnsValue[amountKey]);
                      // eslint-disable-next-line no-use-before-define
                      const finalResult = calcSummation(
                        // eslint-disable-next-line no-use-before-define
                        cacheLayMap.get(spikedMeasurementValueKey.toString()),
                        jbValue,
                        detectionLimit,
                        keepDecimals,
                        SignificantDigit,
                        smallTimes
                      );
                      columnsValue[spikedMeasurementValueKey] = finalResult;
                    }
                  }
                }
              });
              // console.log('结果');
              // console.log(fjwztRow);
              // console.log(props.data);
            }
          });
        }
      }
    });
  }

  // 平行样平均值和偏差的计算
  if (startsWith(fieldName, "浓度值")) {
    // 算法公式计算
    // eslint-disable-next-line no-use-before-define
    calcAlg(columnsValue, record, fiedldId, fieldName);
    // eslint-disable-next-line no-use-before-define
    calcAandPc(columnsValue, record, fiedldId, fieldName);
    // 计算加标测定值
    if (
      amountKey &&
      spikedMeasurementValueKey &&
      columnsValue[amountKey] &&
      ($event || $event === 0) &&
      ((record.sampleType === 1 && dataJbMap.get(record.businessId)) ||
        record.sampleType === 2 ||
        record.parallelType === 5)
    ) {
      // columnsValue[spikedMeasurementValueKey] =
      //   Number($event) * Number(columnsValue[amountKey]);
      if (Number.isNaN(Number($event))) {
        columnsValue[spikedMeasurementValueKey] = 0;
      } else {
        const jbValue = Number($event) * Number(columnsValue[amountKey]);
        // eslint-disable-next-line no-use-before-define
        const finalResult = calcSummation(
          // eslint-disable-next-line no-use-before-define
          cacheLayMap.get(spikedMeasurementValueKey.toString()),
          jbValue,
          detectionLimit,
          keepDecimals,
          SignificantDigit,
          smallTimes
        );
        columnsValue[spikedMeasurementValueKey] = finalResult;
      }
    }
    // 计算中间校核点结果判定
    // eslint-disable-next-line no-use-before-define
    calcMiddlePointResultJudgmentKey(
      columnsValue,
      detectionLimit,
      keepDecimals,
      SignificantDigit,
      smallTimes
    );
  }

  if (startsWith(fieldName, "中间校核点浓度")) {
    // 计算中间校核点结果判定
    // eslint-disable-next-line no-use-before-define
    calcMiddlePointResultJudgmentKey(
      columnsValue,
      detectionLimit,
      keepDecimals,
      SignificantDigit,
      smallTimes
    );
  }

  // 质控报告-质控样检测结果模块计算
  if (startsWith(fieldName, "测定值")) {
    if (
      standardValueKey &&
      uncertaintyKey &&
      detectionResultKey &&
      columnsValue[standardValueKey] &&
      columnsValue[uncertaintyKey] &&
      $event
    ) {
      if (record.sampleType === 3) {
        let min = 0;
        let max = 0;
        if (startsWith(columnsValue[uncertaintyKey], "±")) {
          min =
            Number(columnsValue[standardValueKey]) -
            Number(columnsValue[uncertaintyKey].slice(1));
          max =
            Number(columnsValue[standardValueKey]) +
            Number(columnsValue[uncertaintyKey].slice(1));
        } else if (endsWith(columnsValue[uncertaintyKey], "%")) {
          min =
            Number(columnsValue[standardValueKey]) *
            (1 -
              Number(
                columnsValue[uncertaintyKey].slice(
                  0,
                  columnsValue[uncertaintyKey].length - 1
                )
              ) /
                100);
          max =
            Number(columnsValue[standardValueKey]) *
            (1 +
              Number(
                columnsValue[uncertaintyKey].slice(
                  0,
                  columnsValue[uncertaintyKey].length - 1
                )
              ) /
                100);
        } else {
          min =
            Number(columnsValue[standardValueKey]) -
            Number(columnsValue[uncertaintyKey]);
          max =
            Number(columnsValue[standardValueKey]) +
            Number(columnsValue[uncertaintyKey]);
        }
        if (Number($event) >= Number(min) && Number($event) <= Number(max)) {
          columnsValue[detectionResultKey] = "合格";
        } else {
          columnsValue[detectionResultKey] = "不合格";
        }
      } else if (emptyValueRule) {
        columnsValue[detectionResultKey] = emptyValueRule;
      }
    }
  }
  if (startsWith(fieldKey, "parallel_sample_bias")) {
    if (
      parallelDoubleSampleTestResultsKey &&
      relativeDeviationKey &&
      columnsValue[relativeDeviationKey] &&
      $event
    ) {
      if (startsWith($event, "≤")) {
        if (
          Math.abs(Number(columnsValue[relativeDeviationKey])) <=
          Number($event.slice(1))
        ) {
          columnsValue[parallelDoubleSampleTestResultsKey] = "合格";
        } else {
          columnsValue[parallelDoubleSampleTestResultsKey] = "不合格";
        }
      } else if (
        Math.abs(Number(columnsValue[relativeDeviationKey])) <= Number($event)
      ) {
        columnsValue[parallelDoubleSampleTestResultsKey] = "合格";
      } else {
        columnsValue[parallelDoubleSampleTestResultsKey] = "不合格";
      }
    }
  }

  // 质控报告空白试验结果模块计算
  if (startsWith(fieldName, "吸光度")) {
    if (
      blankTestJudgmentKey &&
      blankAbsorbanceLimitKey &&
      columnsValue[blankAbsorbanceLimitKey] &&
      $event &&
      (record.sampleType === 2 ||
        record.parallelType === 2 ||
        record.parallelType === 3)
    ) {
      if (Number($event) < Number(columnsValue[blankAbsorbanceLimitKey])) {
        columnsValue[blankTestJudgmentKey] = "合格";
      } else {
        columnsValue[blankTestJudgmentKey] = "不合格";
      }
    } else if (emptyValueRule && blankTestJudgmentKey) {
      columnsValue[blankTestJudgmentKey] = emptyValueRule;
    }
  }
  if (startsWith(fieldName, "空白吸光度限值")) {
    if (
      blankTestJudgmentKey &&
      Number(columnsValue[absorbanceKey]) &&
      Number($event) &&
      (record.sampleType === 2 ||
        record.parallelType === 2 ||
        record.parallelType === 3)
    ) {
      if (Number(columnsValue[absorbanceKey]) < Number($event)) {
        columnsValue[blankTestJudgmentKey] = "合格";
      } else {
        columnsValue[blankTestJudgmentKey] = "不合格";
      }
    } else if (emptyValueRule && blankTestJudgmentKey) {
      columnsValue[blankTestJudgmentKey] = emptyValueRule;
    }
  }
  if (startsWith(fieldName, "计算值X")) {
    if (
      !blankAbsorbanceLimitKey &&
      detectionLimitKey &&
      blankTestJudgmentKey &&
      ($event || $event === 0) &&
      columnsValue[detectionLimitKey] &&
      (record.sampleType === 2 ||
        record.parallelType === 2 ||
        record.parallelType === 3)
    ) {
      if (Number($event) < Number(columnsValue[detectionLimitKey])) {
        columnsValue[blankTestJudgmentKey] = "合格";
      } else {
        columnsValue[blankTestJudgmentKey] = "不合格";
      }
    } else if (emptyValueRule && blankTestJudgmentKey) {
      columnsValue[blankTestJudgmentKey] = emptyValueRule;
    }
  }

  if (startsWith(fieldName, "加标测定值") || startsWith(fieldName, "加标量")) {
    if (record.parallelType === 5 && record.sampleSamplingTaskId) {
      const yuanyangItem: any = dataItemMap.get(record.sampleSamplingTaskId);
      if (
        rateOfRecoveryKey &&
        spikedMeasurementValueKey &&
        addStandardQuantityKey &&
        (columnsValue[spikedMeasurementValueKey] ||
          columnsValue[spikedMeasurementValueKey] === 0) &&
        columnsValue[addStandardQuantityKey] &&
        (yuanyangItem[spikedMeasurementValueKey] ||
          yuanyangItem[spikedMeasurementValueKey] === 0)
      ) {
        let calcRes: any =
          ((columnsValue[spikedMeasurementValueKey] -
            yuanyangItem[spikedMeasurementValueKey]) /
            columnsValue[addStandardQuantityKey]) *
          100;
        if (Number.isNaN(calcRes)) {
          calcRes = "/";
        } else {
          calcRes = calcRes.toFixed(2);
          if (
            jbJudgmentResultsKey &&
            scopeOfJbSamplesKey &&
            columnsValue[scopeOfJbSamplesKey] &&
            calcRes
          ) {
            const arr = columnsValue[scopeOfJbSamplesKey].split("~");
            if (
              Number(calcRes) >= Number(arr[0]) &&
              Number(calcRes) <= Number(arr[1])
            ) {
              columnsValue[jbJudgmentResultsKey] = "合格";
            } else {
              columnsValue[jbJudgmentResultsKey] = "不合格";
            }
          }
          // calcRes = `${calcRes}%`;
        }
        columnsValue[rateOfRecoveryKey] = calcRes;
      }
    } else if (emptyValueRule) {
      if (rateOfRecoveryKey) {
        columnsValue[rateOfRecoveryKey] = emptyValueRule;
      }
      if (jbJudgmentResultsKey) {
        columnsValue[jbJudgmentResultsKey] = emptyValueRule;
      }
    }
  }

  // 再进行行内计算公式
  if (!startsWith(fieldKey, "calculation_formula")) {
    const formDataMap = new Map<string, any>(Object.entries(columnsValue));
    const calFormDataMap = new Map<string, any>(
      Object.entries(getCalculationData())
    );
    if (!isEmpty(calFormDataMap)) {
      // eslint-disable-next-line no-restricted-syntax
      for (const [key, value] of calFormDataMap.entries()) {
        formDataMap.set(key, value);
      }
    }
    const calValue = CalculationHandler.calc(needToCalCMap, formDataMap);
    item = {
      ...columnsValue,
      ...calValue,
    };
    dataToMap(dataArrays);
    needToCalCMap.forEach((calcMValue: any) => {
      // 此处取本行的值不能用columnsValue,需要用item,因为columnsValue里的值还是计算前的值
      if (startsWith(calcMValue.label, "浓度值")) {
        // eslint-disable-next-line no-use-before-define
        calcAlg(
          { ...item, ...calValue },
          { ...record, ...calValue },
          fiedldId,
          fieldName
        );
        // eslint-disable-next-line no-use-before-define
        calcAandPc(
          { ...item, ...calValue },
          { ...item, ...calValue },
          fiedldId,
          fieldName
        );
        // 计算加标测定值
        if (
          amountKey &&
          spikedMeasurementValueKey &&
          item[amountKey] &&
          (item[calcMValue.model] || item[calcMValue.model] === 0) &&
          ((record.sampleType === 1 && dataJbMap.get(record.businessId)) ||
            record.sampleType === 2 ||
            record.parallelType === 5)
        ) {
          // item[spikedMeasurementValueKey] =
          //   Number(item[calcMValue.model]) *
          //   Number(item[amountKey]);
          if (Number.isNaN(Number(item[calcMValue.model]))) {
            item[spikedMeasurementValueKey] = 0;
          } else {
            const jbValue =
              Number(item[calcMValue.model]) * Number(item[amountKey]);
            // eslint-disable-next-line no-use-before-define
            const finalResult = calcSummation(
              // eslint-disable-next-line no-use-before-define
              cacheLayMap.get(spikedMeasurementValueKey.toString()),
              jbValue,
              detectionLimit,
              keepDecimals,
              SignificantDigit,
              smallTimes
            );
            item[spikedMeasurementValueKey] = finalResult;
          }
          // 接着计算回收率
          if (record.parallelType === 5 && record.sampleSamplingTaskId) {
            const yuanyangItem: any = dataItemMap.get(
              record.sampleSamplingTaskId
            );
            if (
              rateOfRecoveryKey &&
              spikedMeasurementValueKey &&
              addStandardQuantityKey &&
              (item[spikedMeasurementValueKey] ||
                item[spikedMeasurementValueKey] === 0) &&
              item[addStandardQuantityKey] &&
              (yuanyangItem[spikedMeasurementValueKey] ||
                yuanyangItem[spikedMeasurementValueKey] === 0)
            ) {
              let calcRes: any =
                ((item[spikedMeasurementValueKey] -
                  yuanyangItem[spikedMeasurementValueKey]) /
                  item[addStandardQuantityKey]) *
                100;
              if (Number.isNaN(calcRes)) {
                calcRes = "/";
              } else {
                calcRes = calcRes.toFixed(2);
                if (
                  jbJudgmentResultsKey &&
                  scopeOfJbSamplesKey &&
                  item[scopeOfJbSamplesKey] &&
                  calcRes
                ) {
                  const arr = item[scopeOfJbSamplesKey].split("~");
                  if (
                    Number(calcRes) >= Number(arr[0]) &&
                    Number(calcRes) <= Number(arr[1])
                  ) {
                    item[jbJudgmentResultsKey] = "合格";
                  } else {
                    item[jbJudgmentResultsKey] = "不合格";
                  }
                }
                // calcRes = `${calcRes}%`;
              }
              item[rateOfRecoveryKey] = calcRes;
            }
          } else if (emptyValueRule) {
            if (rateOfRecoveryKey) {
              item[rateOfRecoveryKey] = emptyValueRule;
            }
            if (jbJudgmentResultsKey) {
              item[jbJudgmentResultsKey] = emptyValueRule;
            }
          }
          // 若是原样品,需要看是否有加标样,有的话要计算下面加标样的回收率
          if (record.sampleType === 1 || record.sampleType === 2) {
            const jbArr = dataJbMap.get(record.businessId);
            if (jbArr && jbArr.length > 0) {
              jbArr.forEach((jbItem: any) => {
                const yuanyangItem: any = item;
                const jbItemRowIndex = dataRowMap.get(
                  jbItem.samplingNo + jbItem.detectionItemName
                );
                if (jbItem.parallelType === 5 && jbItem.sampleSamplingTaskId) {
                  if (
                    rateOfRecoveryKey &&
                    spikedMeasurementValueKey &&
                    addStandardQuantityKey &&
                    (dataArrays[jbItemRowIndex][spikedMeasurementValueKey] ||
                      dataArrays[jbItemRowIndex][spikedMeasurementValueKey] ===
                        0) &&
                    dataArrays[jbItemRowIndex][addStandardQuantityKey] &&
                    (yuanyangItem[spikedMeasurementValueKey] ||
                      yuanyangItem[spikedMeasurementValueKey] === 0)
                  ) {
                    let calcRes: any =
                      ((dataArrays[jbItemRowIndex][spikedMeasurementValueKey] -
                        yuanyangItem[spikedMeasurementValueKey]) /
                        dataArrays[jbItemRowIndex][addStandardQuantityKey]) *
                      100;
                    if (Number.isNaN(calcRes)) {
                      calcRes = "/";
                    } else {
                      calcRes = calcRes.toFixed(2);
                      if (
                        jbJudgmentResultsKey &&
                        scopeOfJbSamplesKey &&
                        dataArrays[jbItemRowIndex][scopeOfJbSamplesKey] &&
                        calcRes
                      ) {
                        const arr =
                          dataArrays[jbItemRowIndex][scopeOfJbSamplesKey].split(
                            "~"
                          );
                        if (
                          Number(calcRes) >= Number(arr[0]) &&
                          Number(calcRes) <= Number(arr[1])
                        ) {
                          dataArrays[jbItemRowIndex][jbJudgmentResultsKey] =
                            "合格";
                        } else {
                          dataArrays[jbItemRowIndex][jbJudgmentResultsKey] =
                            "不合格";
                        }
                      }
                      // calcRes = `${calcRes}%`;
                    }
                    dataArrays[jbItemRowIndex][rateOfRecoveryKey] = calcRes;
                  }
                } else if (emptyValueRule) {
                  if (rateOfRecoveryKey) {
                    dataArrays[jbItemRowIndex][rateOfRecoveryKey] =
                      emptyValueRule;
                  }
                  if (jbJudgmentResultsKey) {
                    dataArrays[jbItemRowIndex][jbJudgmentResultsKey] =
                      emptyValueRule;
                  }
                }
              });
            }
          }
        } else if (emptyValueRule) {
          item[spikedMeasurementValueKey] = emptyValueRule;
        }
        // eslint-disable-next-line no-use-before-define
        calcMiddlePointResultJudgmentKey(
          item,
          detectionLimit,
          keepDecimals,
          SignificantDigit,
          smallTimes
        );
      }
      if (startsWith(calcMValue.label, "中间校核点浓度")) {
        // 计算中间校核点结果判定
        // eslint-disable-next-line no-use-before-define
        calcMiddlePointResultJudgmentKey(
          item,
          detectionLimit,
          keepDecimals,
          SignificantDigit,
          smallTimes
        );
      }
      // if (startsWith(calcMValue.label, '回收率')) {
      //   if (
      //     scopeOfJbSamplesKey &&
      //     item[scopeOfJbSamplesKey] &&
      //     item[calcMValue.model]
      //   ) {
      //     const arr =
      //       item[scopeOfJbSamplesKey].split('~');
      //     if (
      //       Number(item[calcMValue.model]) >=
      //         Number(arr[0]) &&
      //       Number(item[calcMValue.model]) <=
      //         Number(arr[1])
      //     ) {
      //       item[jbJudgmentResultsKey] = '合格';
      //     } else {
      //       item[jbJudgmentResultsKey] = '不合格';
      //     }
      //   }
      // }
      if (startsWith(calcMValue.label, "计算值X")) {
        if (
          !blankAbsorbanceLimitKey &&
          detectionLimitKey &&
          blankTestJudgmentKey &&
          (item[calcMValue.model] || item[calcMValue.model] === 0) &&
          item[detectionLimitKey] &&
          (record.sampleType === 2 ||
            record.parallelType === 2 ||
            record.parallelType === 3)
        ) {
          if (
            typeof item[calcMValue.model] !== "number" &&
            (item[calcMValue.model].indexOf("未检出") > -1 ||
              item[calcMValue.model].indexOf("ND") > -1 ||
              item[calcMValue.model].indexOf("L") > -1)
          ) {
            item[blankTestJudgmentKey] = "合格";
          } else if (
            Number(item[calcMValue.model]) < Number(item[detectionLimitKey])
          ) {
            item[blankTestJudgmentKey] = "合格";
          } else {
            item[blankTestJudgmentKey] = "不合格";
          }
        }
      }
      // 质控报告-质控样检测结果模块计算
      if (startsWith(calcMValue.label, "测定值")) {
        if (
          standardValueKey &&
          uncertaintyKey &&
          detectionResultKey &&
          item[standardValueKey] &&
          item[uncertaintyKey] &&
          item[calcMValue.model] &&
          record.sampleType === 3
        ) {
          let min = 0;
          let max = 0;
          if (startsWith(item[uncertaintyKey], "±")) {
            min =
              Number(item[standardValueKey]) -
              Number(item[uncertaintyKey].slice(1));
            max =
              Number(item[standardValueKey]) +
              Number(item[uncertaintyKey].slice(1));
          } else if (endsWith(item[uncertaintyKey], "%")) {
            min =
              Number(item[standardValueKey]) *
              (1 -
                Number(
                  item[uncertaintyKey].slice(0, item[uncertaintyKey].length - 1)
                ) /
                  100);
            max =
              Number(item[standardValueKey]) *
              (1 +
                Number(
                  item[uncertaintyKey].slice(0, item[uncertaintyKey].length - 1)
                ) /
                  100);
          } else {
            min = Number(item[standardValueKey]) - Number(item[uncertaintyKey]);
            max = Number(item[standardValueKey]) + Number(item[uncertaintyKey]);
          }
          if (
            Number(item[calcMValue.model]) >= Number(min) &&
            Number(item[calcMValue.model]) <= Number(max)
          ) {
            item[detectionResultKey] = "合格";
          } else {
            item[detectionResultKey] = "不合格";
          }
        }
      }
      if (startsWith(calcMValue.label, "相对误差")) {
        if (record.sampleType !== 4) {
          if (emptyValueRule) {
            item[calcMValue.model] = emptyValueRule;
          } else {
            item[calcMValue.model] = "/";
          }
        }
      }
    });
  }
  continuedData.value.forEach((data, index) => {
    if (data.businessId === item.businessId) {
      continuedData.value[index] = item;
    }
  });
  continuedDataByTimeSingle.value.forEach((data, index) => {
    if (data.businessId === item.businessId) {
      continuedDataByTimeSingle.value[index] = item;
    }
  });

  // if (startsWith(fieldKey, 'instrument_code')) {
  //   appContext.config.globalProperties.$mitt.emit(
  //     'instrumentNameBatchChangeNotice',
  //     { key: rowIndex, data: $event }
  //   );
  // }
  // appContext.config.globalProperties.$mitt.emit(
  //   'formDataChangeNotice',
  //   false
  // );
};
  1. 给每个输入操作加唯一标识(如递增的 version 或 timestamp)每次输入时,生成一个唯一的 inputVersion,在计算开始和结束时都带上它。只有当前输入的 version 和计算完成时的 version 一致,才更新数据。
  2. 输入防抖处理
    期望结果优化当数据量大加载慢、甚至崩溃;用户输入数据不在跳闪
    为什么会出现跳闪?
    ● 用户输入很快,前一次输入的计算还没完成,用户又输入了新值。
    ● 计算完成后,旧的结果覆盖了用户最新的输入,导致“跳闪”或数据回退。
阅读 110
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题