gaoluyang
2026-06-30 113ca01ea4abdeee4e01695df973219ee4671ef0
src/views/qualityManagement/processInspection/components/formDia.vue
@@ -4,13 +4,17 @@
        v-model="dialogFormVisible"
        :title="operationType === 'add' ? '新增过程检验' : '编辑过程检验'"
        width="70%"
            draggable
        @close="closeDia"
    >
      <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="工序:" prop="process">
              <el-input v-model="form.process" placeholder="请输入" clearable/>
              <el-select v-model="form.process" placeholder="请选择" clearable>
                <el-option label="试压" value="试压" />
                <el-option label="抽检" value="抽检" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -104,7 +108,7 @@
</template>
<script setup>
import {ref, computed} from "vue";
import {ref, computed, reactive, toRefs, getCurrentInstance} from "vue";
import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
import {modelList, productTreeList} from "@/api/basicData/product.js";
import {qualityInspectAdd, qualityInspectUpdate} from "@/api/qualityManagement/rawMaterialInspection.js";
@@ -204,10 +208,47 @@
         });
      }
      getQualityInspectParamList(row.id)
   } else {
      // 新增时设置默认值
      form.value.process = "试压"; // 工序默认为试压
      form.value.unit = "包"; // 单位默认为包
      form.value.quantity = 3; // 数量默认为3
      form.value.checkResult = "合格"; // 检验结果默认为合格
         // 产品名称默认傻老大原味瓜子(质检试压)
         productTreeList({productName: '质量'}).then((res) => {
            productOptions.value = convertIdToValue(res);
            // 递归查找目标节点
               const findTarget = (nodes) => {
                  for (const node of nodes) {
                     if (node.label === "傻老大原味瓜子(质检试压)") {
                        return node;
                     }
                     if (node.children && node.children.length > 0) {
                        const found = findTarget(node.children);
                        if (found) return found;
                     }
                  }
                  return null;
               };
               const target = findTarget(res);
            if (target) {
               form.value.productId = target.id;
               form.value.productName = target.label;
               currentProductId.value = target.id;
               // 加载规格列表
               modelList({ id: target.id }).then((modelRes) => {
                  modelOptions.value = modelRes;
               });
               // 加载检验参数
               qualityInspectDetailByProductId(target.id).then((paramRes) => {
                  tableData.value = paramRes.data;
               });
            }
         });
   }
   // 默认检验员为当前登录人,检测日期默认为当天(空时填充)
   if (currentUserName.value && !form.value.checkName) {
      form.value.checkName = currentUserName.value;
   if (!form.value.checkName) {
      form.value.checkName = "侯盛杰";
   }
   if (!form.value.checkTime) {
      form.value.checkTime = getToday();