gongchunyi
20 小时以前 3a7267cd8eebce7c75afb142f8632bfadd5e7a49
src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
@@ -14,6 +14,7 @@
                  v-model="form.supplier"
                  placeholder="请选择"
                  clearable
                  :disabled="supplierQuantityDisabled"
              >
                <el-option
                    v-for="item in supplierList"
@@ -71,13 +72,20 @@
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="单位:" prop="unit">
              <el-input v-model="form.unit" disabled/>
              <el-input v-model="form.unit" placeholder="自动带出" readonly class="readonly-display"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="厚度:" prop="thickness">
              <el-input v-model="form.thickness" placeholder="自动带出" readonly class="readonly-display"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="数量:" prop="quantity">
              <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.quantity" placeholder="请输入"
                               clearable :precision="2"/>
                               clearable :precision="2" :disabled="supplierQuantityDisabled"/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -99,8 +107,9 @@
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="检验员:" prop="checkName">
              <el-input v-model="form.checkName" placeholder="请输入" clearable/>
              <el-select v-model="form.checkName" placeholder="请选择" clearable style="width: 100%">
                <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -143,12 +152,13 @@
</template>
<script setup>
import {ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
import {ref, reactive, toRefs, computed, getCurrentInstance, nextTick} 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";
import {qualityInspectParamDel, qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js";
import {qualityInspectDetailByProductId, getQualityTestStandardParamByTestStandardId} from "@/api/qualityManagement/metricMaintenance.js";
import {userListNoPage} from "@/api/system/user.js";
const {proxy} = getCurrentInstance()
const emit = defineEmits(['close'])
@@ -166,6 +176,7 @@
    model: "",
    testStandardId: "",
    unit: "",
    thickness: "",
    quantity: "",
    checkCompany: "",
    checkResult: "",
@@ -178,6 +189,7 @@
    productModelId: [{required: true, message: "请选择产品型号", trigger: "change"}],
    testStandardId: [{required: false, message: "请选择指标", trigger: "change"}],
    unit: [{required: false, message: "请输入", trigger: "blur"}],
    thickness: [{required: false, message: "请输入", trigger: "blur"}],
    quantity: [{required: true, message: "请输入", trigger: "blur"}],
    checkCompany: [{required: false, message: "请输入", trigger: "blur"}],
    checkResult: [{required: true, message: "请选择检测结果", trigger: "change"}],
@@ -216,6 +228,13 @@
const currentProductId = ref(0);
const testStandardOptions = ref([]); // 指标选择下拉框数据
const modelOptions = ref([]);
const userList = ref([]); // 检验员下拉列表
// 编辑时:productMainId 或 purchaseLedgerId 任一有值则供应商、数量置灰
const supplierQuantityDisabled = computed(() => {
  const v = form.value || {};
  return !!(v.productMainId != null || v.purchaseLedgerId != null);
});
// 打开弹框
const openDialog = async (type, row) => {
@@ -223,6 +242,14 @@
  getOptions().then((res) => {
    supplierList.value = res.data;
  });
  try {
    const userRes = await userListNoPage();
    userList.value = userRes.data || [];
  } catch (e) {
    console.error("加载检验员列表失败", e);
    userList.value = [];
  }
  // 先重置表单数据(保持字段完整,避免弹窗首次渲染时触发必填红框“闪一下”)
   form.value = {
    checkTime: "",
@@ -234,6 +261,7 @@
    model: "",
    testStandardId: "",
    unit: "",
    thickness: "",
    quantity: "",
    checkCompany: "",
    checkResult: "",
@@ -316,6 +344,7 @@
const getModels = (value) => {
  form.value.productModelId = undefined;
  form.value.unit = undefined;
  form.value.thickness = undefined;
  modelOptions.value = [];
  currentProductId.value = value
  form.value.productName = findNodeById(productOptions.value, value);
@@ -328,8 +357,10 @@
};
const handleChangeModel = (value) => {
  form.value.model = modelOptions.value.find(item => item.id == value)?.model || '';
  form.value.unit = modelOptions.value.find(item => item.id == value)?.unit || '';
  const selectedModel = modelOptions.value.find(item => item.id == value);
  form.value.model = selectedModel?.model || '';
  form.value.unit = selectedModel?.unit || '';
  form.value.thickness = selectedModel?.thickness ?? '';
}
const findNodeById = (nodes, productId) => {
@@ -446,4 +477,15 @@
<style scoped>
:deep(.readonly-display .el-input__wrapper) {
  background-color: var(--el-disabled-bg-color);
  box-shadow: 0 0 0 1px var(--el-disabled-border-color) inset;
}
:deep(.readonly-display .el-input__inner) {
  color: var(--el-disabled-text-color);
  -webkit-text-fill-color: var(--el-disabled-text-color);
  cursor: not-allowed;
}
</style>