src/views/business/inspectionTask/components/InspectionWord.vue
@@ -26,6 +26,21 @@
            </el-select>
          </div>
        </div>
        <div style="text-align: left; margin-top: 8px;">
          <el-form :inline="true" :model="currentOtherForm" class="form-inline" label-width="50px"
            style="text-align: left; display: inline">
            <el-form-item label="温度:" style="margin-bottom: 0">
              <el-input v-model="currentOtherForm.temperature" :disabled="state > 1" placeholder="" size="small"
                style="width: 90px" @change="m => subOtherForm(m, 'temperature')"></el-input>
              <span style="margin-left: 4px">℃</span>
            </el-form-item>
            <el-form-item label="湿度:" style="margin-bottom: 0">
              <el-input v-model="currentOtherForm.humidity" :disabled="state > 1" placeholder="" size="small"
                style="width: 90px" @change="m => subOtherForm(m, 'humidity')"></el-input>
              <span style="margin-left: 4px">%RH</span>
            </el-form-item>
          </el-form>
        </div>
        <!-- 常规检验原始记录 -->
        <div id="tableBox" v-loading="tableLoading" class="center-box">
          <table v-for="(item, index) in tableList" :key="index + currentTable + currentSample.id" border="1"
@@ -220,7 +235,8 @@
  getInsProductUnqualifiedRetest,
  search, selectUserCondition,
  submitPlan,
  verifyPlan
  verifyPlan,
  write
} from "@/api/business/inspectionTask";
import { getUserNow, saveUnqualifiedContext } from "@/api/business/rawMaterialOrder";
import InspectionWorker from '@/workers/InspectionWorker.worker';
@@ -340,10 +356,8 @@
      numOptions: [],
      temperatureOptions: [],
      wareTableData: [],
      otherForm: {
        humidity: null,
        temperature: null,
      },
      // 温度、湿度按模板 id 分组:{ [templateId]: { temperature, humidity } }
      otherForm: {},
      equipForm: {
        value0: null,
        code0: null,
@@ -418,6 +432,13 @@
    },
    action() {
      return this.javaApi + "/insOrderPlan/uploadFile";
    },
    // 当前模板对应的温度、湿度
    currentOtherForm() {
      return this.otherForm[this.currentTable] || {
        temperature: null,
        humidity: null
      }
    }
  },
  created() {
@@ -453,11 +474,15 @@
        this.sampleProduct = res.data.sampleProduct
        this.currentSample = this.HaveJson(this.sampleProduct[0])
        let insProduct = this.HaveJson(this.currentSample.insProduct)
        // 温度、湿度赋值
        this.otherForm = {
          temperature: this.insOrder.temperature ? this.insOrder.temperature : null,
          humidity: this.insOrder.humidity ? this.insOrder.humidity : null,
        }
        // 温度、湿度赋值:按模板 id 分组回显
        this.otherForm = {}
        const conditionList = this.insOrder.templateConditions || []
        conditionList.forEach(item => {
          this.$set(this.otherForm, item.templateId, {
            temperature: item.temperature != null ? item.temperature : null,
            humidity: item.humidity != null ? item.humidity : null
          })
        })
        if (this.typeSource == '1') {
          this.retestTag = '1'
        }
@@ -515,6 +540,8 @@
            if (this.tableLists && this.tableLists.length > 0) {
              this.tableList = null;
              this.tableList = this.tableLists.filter(m => m.templateId == val1)
              // 模板集合可能变化,补齐温度、湿度槽位
              this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
              // 对模板进行处理
              this.handleTableData()
            }
@@ -846,6 +873,8 @@
        this.tableList = null;
        this.tableList = [this.tableLists[0]]
        this.currentTable = this.tableLists[0].templateId;
        // 补齐每个模板的温度、湿度槽位
        this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
        // 处理页面列表数据
        this.handleTableData()
      }
@@ -875,6 +904,8 @@
        this.tableList = [this.tableLists[0]]
        this.currentTable = this.tableLists[0].templateId;
        this.currentSample.insProduct = this.HaveJson(list)
        // 补齐每个模板的温度、湿度槽位
        this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
        // 处理页面列表数据
        this.handleTableData()
      }
@@ -1210,15 +1241,24 @@
    // 对输入值进行格式校验
    handleInput(n) {
      try {
        n.v.v = n.v.v.replace(/[^\d.^e>\-/+]/g, '');
        n.v.v = n.v.v.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
        n.v.v = n.v.v.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        n.v.v = n.v.v.replace(/\/{2,}/g, "/"); //只保留第一个/清除多余的
        n.v.v = n.v.v.replace("/", "$#$").replace(/\//g, "").replace("$#$", "/");
        const v = n.v.v;
        // 能力范围已废弃,检验值类型不再作为判断依据。整串只由算式字符组成时才规范化格式,
        // 出现中文等其它字符即按文本处理原样保留,否则文字会被逐字删掉
        if (typeof v !== "string" || /[^\d.^e>>≥≤<<断裂脆化\-/+]/.test(v)) {
          return;
        }
        n.v.v = v
          .replace(/\.{2,}/g, ".") //只保留第一个. 清除多余的
          .replace(".", "$#$")
          .replace(/\./g, "")
          .replace("$#$", ".")
          .replace(/\/{2,}/g, "/") //只保留第一个/清除多余的
          .replace("/", "$#$")
          .replace(/\//g, "")
          .replace("$#$", "/");
      } catch (error) {
        console.log(error);
      }
    },
    getInspectionItemType(id) {
      for (var a in this.currentSample.insProduct) {
@@ -1332,17 +1372,42 @@
        this.$message.error('未输入不通过原因')
      }
    },
    // 保证模板的温度、湿度槽位存在
    ensureOtherForm(templateId) {
      if (templateId == null) return
      if (!this.otherForm[templateId]) {
        this.$set(this.otherForm, templateId, {
          temperature: null,
          humidity: null
        })
      }
    },
    // 保存当前模板的温度、湿度
    subOtherForm(m, type) {
      write({
        id: this.insOrder.id,
        templateId: this.currentTable,
        [type]: Number(m)
      }).then(res => {
        this.$message.success("保存成功")
      })
    },
    submit() {
      if (this.verifyUser === null || this.verifyUser === '') {
        this.$message.error("请指定复核人员")
        return
      }
      if (!this.otherForm.humidity) {
        this.$message.error("请输入湿度")
        return
      }
      if (!this.otherForm.temperature) {
        this.$message.error("请输入温度")
      const labels = { temperature: "温度", humidity: "湿度" }
      const keys = ["temperature", "humidity"]
      const missing = []
      this.tableLists.forEach(m => {
        const form = this.otherForm[m.templateId] || {}
        keys.forEach(key => {
          if (!form[key]) missing.push(`「${m.templateName}」的${labels[key]}`)
        })
      })
      if (missing.length > 0) {
        this.$message.error(`请填写${missing[0]}`)
        return
      }
      this.submitLoading = true;