src/views/qualityManagement/processInspection/components/formDia.vue
@@ -43,8 +43,21 @@
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="规格型号:" prop="model">
              <el-input v-model="form.model" placeholder="请输入" clearable/>
            <el-form-item label="规格型号:" prop="productModelId">
              <el-select
                v-model="form.productModelId"
                placeholder="请选择"
                clearable
                @change="getProductModel"
                style="width: 100%"
              >
                <el-option
                  v-for="item in modelOptions"
                  :key="item.id"
                  :label="item.model"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -141,7 +154,7 @@
<script setup>
import {ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
import {productTreeList} from "@/api/basicData/product.js";
import {modelList, productTreeList} from "@/api/basicData/product.js";
import {productProcessListPage} from "@/api/basicData/productProcess.js";
import {qualityInspectAdd, qualityInspectUpdate} from "@/api/qualityManagement/rawMaterialInspection.js";
import {qualityInspectDetailByProductId, getQualityTestStandardParamByTestStandardId} from "@/api/qualityManagement/metricMaintenance.js";
@@ -159,6 +172,7 @@
    checkName: "",
    productName: "",
    productId: "",
    productModelId: "",
    model: "",
    testStandardId: "",
    unit: "",
@@ -171,6 +185,7 @@
    processId: [{ required: true, message: "请选择工序", trigger: "change" }],
    checkName: [{ required: false, message: "请输入", trigger: "blur" }],
    productId: [{ required: true, message: "请输入", trigger: "blur" }],
    productModelId: [{required: true, message: "请选择规格型号", trigger: "change"}],
    model: [{ required: false, message: "请输入", trigger: "blur" }],
    testStandardId: [{required: true, message: "请选择指标", trigger: "change"}],
    unit: [{ required: false, message: "请输入", trigger: "blur" }],
@@ -211,6 +226,7 @@
const tableLoading = ref(false);
const currentProductId = ref(0);
const processOptions = ref([]); // 工序下拉框数据
const modelOptions = ref([]); // 规格型号下拉框数据
const testStandardOptions = ref([]); // 指标选择下拉框数据
// 获取工序列表
@@ -241,6 +257,7 @@
   form.value = {}
   testStandardOptions.value = [];
   tableData.value = [];
   modelOptions.value = [];
   getProductOptions();
   // 先加载工序列表
   await getProcessList();
@@ -260,6 +277,10 @@
      currentProductId.value = row.productId || 0
      // 编辑模式下,先加载指标选项,然后加载参数列表
      if (currentProductId.value) {
         // 加载规格型号选项
         modelList({ id: currentProductId.value }).then((res) => {
            modelOptions.value = res;
         });
         // 先加载指标选项
         let params = {
            productId: currentProductId.value,
@@ -307,10 +328,26 @@
const getModels = (value) => {
   currentProductId.value = value
  form.value.productName = findNodeById(productOptions.value, value);
   modelOptions.value = [];
   form.value.productModelId = "";
   form.value.model = "";
   if (currentProductId.value) {
      modelList({ id: value }).then((res) => {
         modelOptions.value = res;
      });
      getList();
   }
};
const getProductModel = (value) => {
   const index = modelOptions.value.findIndex((item) => item.id === value);
   if (index !== -1) {
      form.value.model = modelOptions.value[index].model;
      form.value.unit = modelOptions.value[index].unit;
   } else {
      form.value.model = "";
      form.value.unit = "";
   }
};
const findNodeById = (nodes, productId) => {
  for (let i = 0; i < nodes.length; i++) {
    if (nodes[i].value === productId) {