liding
2026-09-17 8d24d963f8b82163685c34b816998a904f08234d
src/views/business/inspectionView/index.vue
@@ -1,22 +1,7 @@
<template>
  <div v-loading="loading" class="inspection" style="background-color: rgb(245, 247, 251);">
    <el-row class="title">
      <el-col :span="8" style="text-align: left">
        <el-form :inline="true" :model="otherForm" class="form-inline" label-width="50px"
                 style="text-align: right; padding-top: 0; display: inline">
          <el-form-item label="温度:" style="margin-bottom: 0">
            <el-input v-model="otherForm.temperature" :disabled="state > 1" placeholder="" size="small"
                      style="width: 90px; line-height: 60px" @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="otherForm.humidity" :disabled="state > 1" placeholder="" size="small"
                      style="width: 90px; line-height: 60px" @change="(m) => subOtherForm(m, 'humidity')"></el-input>
            <span style="margin-left: 4px">%</span>
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="16" style="text-align: right">
      <el-col :span="24" style="text-align: right">
        <el-button size="small" type="primary" @click="refreshView">刷新</el-button>
        <el-button v-if="typeSource == 1" size="small" type="primary" @click="openPurchase">进货验证</el-button>
        <el-button v-if="state == 1 && typeSource == 1" size="small" type="primary"
@@ -73,12 +58,6 @@
          <el-input v-model="insOrder.remark" :disabled="state != 1" clearable placeholder="请输入" size="small"
                    @blur="subOtherForm(insOrder.remark, 'remark')"></el-input>
          <!-- <el-tag v-if="currentKey">{{ insOrder.remark }}</el-tag> -->
        </el-form-item>
        <el-form-item label="检验结论:">
          <el-radio-group v-model="reviewInsResult" :disabled="state != 2">
            <el-radio :label="1">合格</el-radio>
            <el-radio :label="0">不合格</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
    </div>
@@ -150,6 +129,51 @@
                     @click="dataAcquisitionEidtAble = !dataAcquisitionEidtAble">{{ dataAcquisitionEidtAble ? "关闭编辑" : "编辑数采"
            }}</el-button>
        </div>
      </div>
      <!-- 当前检验模板的检测条件与检验结论 -->
      <div class="template-panel">
        <el-form v-if="showTemplateConditions" :inline="true" :model="currentOtherForm" class="form-inline"
                 size="small" label-width="84px">
          <el-form-item v-if="insOrder.ifsOrderType !== '02wg'" label="温度:">
            <el-input v-model="currentOtherForm.temperature" :disabled="state > 1" size="small"
                      style="width: 90px" @change="m => subOtherForm(m, 'temperature')" />
            <span class="template-panel__unit">℃</span>
          </el-form-item>
          <el-form-item v-if="insOrder.ifsOrderType !== '02wg'" label="湿度:">
            <el-input v-model="currentOtherForm.humidity" :disabled="state > 1" size="small"
                      style="width: 90px" @change="m => subOtherForm(m, 'humidity')" />
            <span class="template-panel__unit">%RH</span>
          </el-form-item>
          <el-form-item v-if="insOrder.ifsOrderType !== '02wg'" label="检测时间:">
            <el-date-picker v-model="currentOtherForm.detectionTime" :disabled="state > 1" type="date"
                            value-format="yyyy-MM-dd" placeholder="请选择日期" size="small" style="width: 160px"
                            @change="m => subOtherForm(m, 'detectionTime')" />
          </el-form-item>
          <el-form-item v-if="insOrder.ifsOrderType !== '02wg'" label="检测地点:">
            <el-input v-model="currentOtherForm.detectionPlace" :disabled="state > 1" clearable
                      placeholder="请输入检测地点" size="small" style="width: 200px"
                      @change="m => subOtherForm(m, 'detectionPlace')" />
          </el-form-item>
          <el-form-item v-if="isDirectTemplateOrder()" label="设备:">
            <el-select v-model="currentOtherForm.deviceIds" :disabled="state != 1" multiple filterable clearable
                       placeholder="请选择设备" size="small" style="width: 360px"
                       @change="m => subOtherForm(m, 'deviceIds')">
              <el-option v-for="device in orderDeviceOptions" :key="device.id" :label="device.label"
                         :value="device.id" />
            </el-select>
          </el-form-item>
        </el-form>
        <el-form :inline="true" :model="currentOtherForm"
                 :class="['form-inline', { 'template-panel__conclusion--divided': showTemplateConditions }]"
                 size="small" label-width="84px">
          <el-form-item label="检验结论:">
            <el-radio-group v-model="currentOtherForm.insResult" :disabled="state != 2"
                            @change="m => subOtherForm(m, 'insResult')">
              <el-radio :label="1">合格</el-radio>
              <el-radio :label="0">不合格</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
      </div>
      <!-- 常规检验原始记录 -->
      <div id="nav" v-loading="tableLoading" class="center-box">
@@ -551,6 +575,7 @@
      comparisonList: [],
      excelMethodList: [],
      equipOptions: [],
      orderDeviceOptions: [],
      reviewLoading: false,
      reviewDia: false,
      noReason: "",
@@ -571,10 +596,8 @@
        inspectionItem: 1,
        inspectionItemSubclass: "20(常温)",
      },
      otherForm: {
        humidity: null,
        temperature: null,
      },
      // 检测条件与检验结论按模板 ID 分组
      otherForm: {},
      equipForm: {
        value0: null,
        code0: null,
@@ -724,8 +747,22 @@
    action() {
      return this.javaApi + "/insOrderPlan/uploadFile";
    },
    currentOtherForm() {
      return this.otherForm[this.currentTable] || {
        temperature: null,
        humidity: null,
        detectionTime: null,
        detectionPlace: null,
        deviceIds: [],
        insResult: null,
      };
    },
    showTemplateConditions() {
      return this.insOrder.ifsOrderType !== "02wg" || this.isDirectTemplateOrder();
    },
  },
  created() {
    this.saveQueue = Promise.resolve();
    let { sonLaboratory, orderId, state, inspectorList, typeSource } =
      this.$route.query;
    this.sonLaboratory = sonLaboratory;
@@ -898,18 +935,26 @@
        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,
        };
        // 按模板回显检测条件与检验结论
        this.otherForm = {};
        (this.insOrder.templateConditions || []).forEach((item) => {
          this.$set(this.otherForm, item.templateId, {
            temperature: item.temperature != null ? item.temperature : null,
            humidity: item.humidity != null ? item.humidity : null,
            detectionTime: item.detectionTime != null ? item.detectionTime : null,
            detectionPlace: item.detectionPlace != null ? item.detectionPlace : null,
            deviceIds: Array.isArray(item.deviceIds) ? [...item.deviceIds] : [],
            insResult: item.insResult != null ? item.insResult : null,
          });
        });
        if (this.typeSource == "1") {
          this.getRawMaterialTag(this.currentSample.id); // 原材料的检验任务查询批数
          this.rawMaterialTag = "1";
        }
        this.getEquipOptions(1);
        if (this.sonLaboratory === "新聚") {
          this.loadDeviceOptions();
        }
        // 获取当前样品的检验项
        let list = await this.getCurrentProduct(this.currentSample.id, 0);
        this.currentSample.insProduct = this.HaveJson(list);
@@ -920,6 +965,7 @@
          this.currentSample["index"] = 1;
        let bushing = this.currentSample.bushing;
        this.getTableLists(); //处理模板列表信息
        this.tableLists.forEach((item) => this.ensureOtherForm(item.templateId));
        this.currentKey = 1;
        this.getCableTag(this.currentSample.id); // 查询是否有要多次检验的电缆配置
@@ -1406,12 +1452,33 @@
        this.worker0 = null;
      }
    },
    // 保存湿度、温度数据
    ensureOtherForm(templateId) {
      if (templateId == null || this.otherForm[templateId]) return;
      this.$set(this.otherForm, templateId, {
        temperature: null,
        humidity: null,
        detectionTime: null,
        detectionPlace: null,
        deviceIds: [],
        insResult: null,
      });
    },
    // 保存当前模板的检测条件;备注仍然是订单级字段
    subOtherForm(m, type) {
      write({
        [type]: type === "remark" ? m : Number(m),
        id: this.insOrder.id,
      }).then((res) => {
      const payload = { id: this.insOrder.id };
      if (type === "remark") {
        payload.remark = m;
      } else {
        payload.templateId = this.currentTable;
        if (type === "deviceIds") {
          payload.deviceIds = Array.isArray(m) ? [...m] : [];
        } else if (type === "detectionTime" || type === "detectionPlace") {
          payload[type] = m === "" || m == null ? null : m;
        } else {
          payload[type] = Number(m);
        }
      }
      write(payload).then((res) => {
        this.$message.success("保存成功");
      });
    },
@@ -1922,6 +1989,11 @@
    },
    // 对输入值进行格式校验
    handleInput(n) {
      // 直绑模板未配置检验值类型时按自由文本处理,允许录入外观等中文结果。
      const inspectionValueType = this.getInspectionValueType(n.i);
      if (inspectionValueType === undefined || inspectionValueType === null) {
        return;
      }
      try {
        n.v.v = n.v.v.replace(/[^\d.^e>>≥≤<<断裂脆化\-/+]/g, "");
        n.v.v = n.v.v.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
@@ -1970,7 +2042,18 @@
    upInsReview(e) {
      if (e == 1) {
        // 通过
        if (this.reviewInsResult !== 0 && this.reviewInsResult !== 1) {
        let finalInsResult = this.reviewInsResult;
        if (this.isDirectTemplateOrder()) {
          const insResults = this.tableLists.map(
            item => (this.otherForm[item.templateId] || {}).insResult
          );
          const missingIndex = insResults.findIndex(result => result !== 0 && result !== 1);
          if (missingIndex > -1) {
            this.$message.error(`请选择「${this.tableLists[missingIndex].templateName}」的检验结论`);
            return;
          }
          finalInsResult = insResults.every(result => result === 1) ? 1 : 0;
        } else if (finalInsResult !== 0 && finalInsResult !== 1) {
          this.$message.error("请选择检验结论");
          return;
        }
@@ -1981,7 +2064,7 @@
          laboratory: this.sonLaboratory,
          tell: null,
          userId: this.checkUser,
          insResult: this.reviewInsResult,
          insResult: finalInsResult,
        }).then((res) => {
          if (res.code === 200) {
            this.$message.success("操作成功");
@@ -2034,12 +2117,21 @@
        this.$message.error("请指定复核人员");
        return;
      }
      if (!this.otherForm.humidity) {
        this.$message.error("请输入湿度");
        return;
      }
      if (!this.otherForm.temperature) {
        this.$message.error("请输入温度");
      const missing = [];
      this.tableLists.forEach((item) => {
        const form = this.otherForm[item.templateId] || {};
        if (this.insOrder.ifsOrderType !== "02wg") {
          if (!form.temperature) missing.push(`请填写「${item.templateName}」的温度`);
          if (!form.humidity) missing.push(`请填写「${item.templateName}」的湿度`);
          if (!form.detectionTime) missing.push(`请选择「${item.templateName}」的检测时间`);
          if (!form.detectionPlace) missing.push(`请填写「${item.templateName}」的检测地点`);
        }
        if (this.isDirectTemplateOrder() && (!form.deviceIds || form.deviceIds.length === 0)) {
          missing.push(`请选择「${item.templateName}」的设备`);
        }
      });
      if (missing.length > 0) {
        this.$message.error(missing[0]);
        return;
      }
      await this.waitForPendingSaves();
@@ -2257,8 +2349,19 @@
      this.saveInsContext();
    },
    isDirectTemplateOrder() {
      return this.sonLaboratory === "新聚" && this.currentSample &&
        (this.currentSample.insProduct || []).some((product) => product.templateRowIndex != null);
      return this.sonLaboratory === "新聚" &&
        Array.isArray(this.insOrder.templateConditions) &&
        this.insOrder.templateConditions.length > 0;
    },
    loadDeviceOptions() {
      search({ status: 0 }).then((res) => {
        this.orderDeviceOptions = (res.data || []).map((device) => ({
          id: device.id,
          label: `${device.deviceName}--${device.managementNumber}`,
        }));
      }).catch((error) => {
        console.error(error);
      });
    },
    async waitForPendingSaves() {
      const targetRevision = this.calculationRevision;
@@ -2448,6 +2551,35 @@
  text-align: left;
}
.template-panel {
  background-color: #f8f9fb;
  border: 1px solid #ebeef5;
  border-radius: 3px;
  padding: 16px 16px 4px;
  margin-bottom: 12px;
  text-align: left;
}
.template-panel>>>.el-form-item {
  display: inline-flex;
  align-items: center;
  margin-bottom: 12px;
}
.template-panel>>>.el-form-item__label {
  flex: none;
}
.template-panel__unit {
  margin-left: 4px;
  color: #606266;
}
.template-panel__conclusion--divided {
  border-top: 1px dashed #e4e7ed;
  padding-top: 12px;
}
.center {
  width: 100%;
  /* max-height: 580px; */