liding
5 天以前 9278cad97f96a9e1eb634c45b90dc14511d24a2c
refactor(inspection): 统一检验值批注识别与格式化逻辑
已修改5个文件
67 ■■■■■ 文件已修改
src/utils/inspectionValueFormat.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionTask/components/InspectionWord.vue 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionTask/inspection.vue 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionView/index.vue 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/workers/InspectionWorker.worker.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/inspectionValueFormat.js
@@ -74,3 +74,9 @@
  const config = parseInspectionValueAnnotation(annotation);
  return config && config.error ? config.error : null;
}
/** 统一识别带小数位等格式参数的数值批注。 */
export function isInspectionValueAnnotation(annotation, target) {
  const config = parseInspectionValueAnnotation(annotation);
  return !!config && !config.error && (!target || config.target === target);
}
src/views/business/inspectionTask/components/InspectionWord.vue
@@ -111,9 +111,9 @@
                        </el-option>
                      </el-select>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '计算值' && state == 1"><span
                    <template v-else-if="n.v.ps != undefined && isInspectionValueAnnotation(n.v.ps.value, '计算值') && state == 1"><span
                        :style="`font-family:${n.v.ff} !important;`">{{ n.v.v }}</span></template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '最终值' && state == 1">
                    <template v-else-if="n.v.ps != undefined && isInspectionValueAnnotation(n.v.ps.value, '最终值') && state == 1">
                      <span :style="`font-family:${n.v.ff} !important;`">{{ n.v.v }}</span>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '样品编号'">
@@ -251,6 +251,7 @@
</template>
<script>
import { parseInspectionValueAnnotation, formatInspectionValue, isInspectionValueAnnotation } from "@/utils/inspectionValueFormat";
// Vue3 没有 this.$createElement(下面用 h 造 VNode 当 $msgbox 的 message)
import { h } from 'vue'
import { readDetectionTimeRange, isCompleteDetectionTimeRange, toDetectionTimePayload } from '@/utils/detectionTimeRange'
@@ -599,6 +600,7 @@
    this.stopWorker();
  },
  methods: {
    isInspectionValueAnnotation,
    closeAddVerifyDia() {
      this.addCheck = false
      this.checkUser = ''
@@ -1089,8 +1091,8 @@
            b.v.ps != undefined &&
            typeof b.v.ps.value === 'string' &&
            (b.v.ps.value.includes('检验值') ||
              b.v.ps.value === '计算值' ||
              b.v.ps.value === '最终值' ||
              isInspectionValueAnnotation(b.v.ps.value, '计算值') ||
              isInspectionValueAnnotation(b.v.ps.value, '最终值') ||
              b.v.ps.value === '设备名称')
          ) {
            b.v['v'] = ''
@@ -1151,12 +1153,12 @@
          if (value === undefined || value === null) {
            return
          }
          cell.v.v = value
          cell.v.v = formatInspectionValue(value, parseInspectionValueAnnotation(cell.v.ps && cell.v.ps.value))
          if (typeof item === 'object' && item.u) {
            cell.u = item.u
          }
          this.param[a.templateId][key] = {
            v: value,
            v: cell.v.v,
            u: typeof item === 'object' ? item.u : cell.u
          }
        })
@@ -1553,8 +1555,8 @@
            cell.v.ps != undefined &&
            typeof cell.v.ps.value === 'string' &&
            (cell.v.ps.value.includes('检验值') ||
              cell.v.ps.value === '计算值' ||
              cell.v.ps.value === '最终值' ||
              isInspectionValueAnnotation(cell.v.ps.value, '计算值') ||
              isInspectionValueAnnotation(cell.v.ps.value, '最终值') ||
              cell.v.ps.value === '设备名称')
          if (!isEditable) {
            return
src/views/business/inspectionTask/inspection.vue
@@ -280,14 +280,14 @@
                    </template>
                    <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '计算值' &&
                      isInspectionValueAnnotation(n.v.ps.value, '计算值') &&
                      state == 1
                    "><span :style="`font-family:${n.v.ff} !important;`">{{
                      n.v.v
                    }}</span></template>
                    <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '最终值' &&
                      isInspectionValueAnnotation(n.v.ps.value, '最终值') &&
                      state == 1
                    ">
                      <span :style="`font-family:${n.v.ff} !important;`">{{
@@ -523,7 +523,7 @@
import { mapGetters } from "@/utils/store-compat";
import viewManHourDia from "@/views/business/inspectionTask/components/viewManHourDia.vue";
import {getDicts} from "@/api/system/dict/data";
import { parseInspectionValueAnnotation, formatInspectionValue } from "@/utils/inspectionValueFormat";
import { parseInspectionValueAnnotation, formatInspectionValue, isInspectionValueAnnotation } from "@/utils/inspectionValueFormat";
export default {
  name: 'Inspection',
  components: {
@@ -838,6 +838,7 @@
    this.stopWorker();
  },
  methods: {
    isInspectionValueAnnotation,
    syncRouteContext() {
      const { sonLaboratory, orderId, state, inspectorList, typeSource, taskSource } = this.$route.query;
      const orderChanged = this.id !== orderId;
@@ -1509,8 +1510,8 @@
            b.v.ps != undefined &&
            typeof b.v.ps.value === "string" &&
            (b.v.ps.value.includes("检验值") ||
              b.v.ps.value === "计算值" ||
              b.v.ps.value === "最终值" ||
              isInspectionValueAnnotation(b.v.ps.value, "计算值") ||
              isInspectionValueAnnotation(b.v.ps.value, "最终值") ||
              b.v.ps.value === "设备名称")
          ) {
            b.v["v"] = "";
@@ -1575,12 +1576,12 @@
          if (value === undefined || value === null) {
            return;
          }
          cell.v.v = value;
          cell.v.v = formatInspectionValue(value, parseInspectionValueAnnotation(cell.v.ps && cell.v.ps.value));
          if (typeof item === "object" && item.u) {
            cell.u = item.u;
          }
          this.param[a.templateId][key] = {
            v: value,
            v: cell.v.v,
            u: typeof item === "object" ? item.u : cell.u,
          };
        });
@@ -2012,8 +2013,8 @@
            cell.v.ps != undefined &&
            typeof cell.v.ps.value === "string" &&
            (cell.v.ps.value.includes("检验值") ||
              cell.v.ps.value === "计算值" ||
              cell.v.ps.value === "最终值" ||
              isInspectionValueAnnotation(cell.v.ps.value, "计算值") ||
              isInspectionValueAnnotation(cell.v.ps.value, "最终值") ||
              cell.v.ps.value === "设备名称");
          const isExportResult = resultHeader && exportRows.has(cell.r) && cell.c === resultHeader.c;
          if (!isEditable && !isExportResult) {
src/views/business/inspectionView/index.vue
@@ -250,14 +250,14 @@
                  </template>
                  <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '计算值' &&
                      isInspectionValueAnnotation(n.v.ps.value, '计算值') &&
                      state == 1
                    "><span :style="`font-family:${n.v.ff} !important;`">{{
                      n.v.v
                    }}</span></template>
                  <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '最终值' &&
                      isInspectionValueAnnotation(n.v.ps.value, '最终值') &&
                      state == 1
                    ">
                      <span :style="`font-family:${n.v.ff} !important;`">{{
@@ -489,6 +489,7 @@
</template>
<script>
import { parseInspectionValueAnnotation, formatInspectionValue, isInspectionValueAnnotation } from "@/utils/inspectionValueFormat";
// Vue3 没有 this.$createElement(下面用 h 造 VNode 当 $msgbox 的 message)
import { h } from 'vue'
import { readDetectionTimeRange, isCompleteDetectionTimeRange, toDetectionTimePayload } from '@/utils/detectionTimeRange'
@@ -846,6 +847,7 @@
    this.stopWorker();
  },
  methods: {
    isInspectionValueAnnotation,
    syncRouteContext() {
      const { sonLaboratory, orderId, state, inspectorList, typeSource } = this.$route.query;
      const orderChanged = this.id !== orderId;
@@ -1779,8 +1781,8 @@
            b.v.ps != undefined &&
            typeof b.v.ps.value === "string" &&
            (b.v.ps.value.includes("检验值") ||
              b.v.ps.value === "计算值" ||
              b.v.ps.value === "最终值" ||
              isInspectionValueAnnotation(b.v.ps.value, "计算值") ||
              isInspectionValueAnnotation(b.v.ps.value, "最终值") ||
              b.v.ps.value === "设备名称")
          ) {
            b.v["v"] = "";
@@ -1845,12 +1847,12 @@
          if (value === undefined || value === null) {
            return;
          }
          cell.v.v = value;
          cell.v.v = formatInspectionValue(value, parseInspectionValueAnnotation(cell.v.ps && cell.v.ps.value));
          if (typeof item === "object" && item.u) {
            cell.u = item.u;
          }
          this.param[a.templateId][key] = {
            v: value,
            v: cell.v.v,
            u: typeof item === "object" ? item.u : cell.u,
          };
        });
@@ -2233,8 +2235,8 @@
            cell.v.ps != undefined &&
            typeof cell.v.ps.value === "string" &&
            (cell.v.ps.value.includes("检验值") ||
              cell.v.ps.value === "计算值" ||
              cell.v.ps.value === "最终值" ||
              isInspectionValueAnnotation(cell.v.ps.value, "计算值") ||
              isInspectionValueAnnotation(cell.v.ps.value, "最终值") ||
              cell.v.ps.value === "设备名称");
          const isExportResult = resultHeader && exportRows.has(cell.r) && cell.c === resultHeader.c;
          if (!isEditable && !isExportResult) {
src/workers/InspectionWorker.worker.js
@@ -1,6 +1,6 @@
// 多线程里面需要保存的数据
import Big from "big.js";
import { parseInspectionValueAnnotation, formatInspectionValue } from "../utils/inspectionValueFormat";
import { parseInspectionValueAnnotation, formatInspectionValue, isInspectionValueAnnotation } from "../utils/inspectionValueFormat";
let code = "";
// 表格数据(渲染)
@@ -574,8 +574,8 @@
          b.v.ps != undefined &&
          typeof b.v.ps.value == "string" &&
          (b.v.ps.value.includes("检验值") ||
            b.v.ps.value === "计算值" ||
            b.v.ps.value === "最终值" ||
            isInspectionValueAnnotation(b.v.ps.value, "计算值") ||
            isInspectionValueAnnotation(b.v.ps.value, "最终值") ||
            b.v.ps.value === "设备名称");
        const isExportResult = resultHeader && exportRows.has(b.r) && b.c === resultHeader.c;
        if (!isEditable && !isExportResult) {