gongchunyi
2026-09-18 4dee4cb5b31a7f1dcd2c7b3d72f74b78d2fe3f29
src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
@@ -14,6 +14,7 @@
                  v-model="form.supplier"
                  placeholder="请选择"
                  clearable
                  filterable
                  :disabled="isViewMode || supplierQuantityDisabled"
              >
                <el-option
@@ -96,6 +97,23 @@
              <el-input-number :step="0.01" :min="0" :max="form.quantity || 0" style="width: 100%"
                               v-model="form.unqualifiedQuantity" placeholder="请输入" :precision="2"
                               @change="onUnqualifiedChange" :disabled="isViewMode"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="是否抽检:" prop="isSampling">
              <el-radio-group v-model="form.isSampling" class="sampling-radio-group" :disabled="isViewMode" @change="handleSamplingChange">
                <el-radio-button :label="1">是</el-radio-button>
                <el-radio-button :label="0">否</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.isSampling === 1">
            <el-form-item label="抽检数量:" prop="samplingQuantity">
              <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.samplingQuantity"
                               placeholder="请输入" clearable :precision="2" :disabled="isViewMode"/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -190,6 +208,8 @@
    unit: "",
    quantity: "",
    checkCompany: "",
    isSampling: 0,
    samplingQuantity: "",
  },
  rules: {
    checkTime: [{required: true, message: "请输入", trigger: "blur"},],
@@ -203,6 +223,8 @@
    qualifiedQuantity: [{required: true, message: "请输入", trigger: "blur"}],
    unqualifiedQuantity: [{required: true, message: "请输入", trigger: "blur"}],
    checkCompany: [{required: false, message: "请输入", trigger: "blur"}],
    isSampling: [{required: true, message: "请选择是否抽检", trigger: "change"}],
    samplingQuantity: [{required: true, message: "请输入抽检数量", trigger: "blur"}],
  },
});
const tableColumn = ref([
@@ -307,6 +329,8 @@
    unit: "",
    quantity: "",
    checkCompany: "",
    isSampling: 0,
    samplingQuantity: "",
  }
  testStandardOptions.value = [];
  tableData.value = [];
@@ -325,7 +349,11 @@
        modelOptions.value = res || [];
        // 同步回填 model / unit(有些接口返回的 row 里可能没带全)
        if (form.value.productModelId) {
          handleChangeModel(form.value.productModelId);
          const selectedModel = modelOptions.value.find(item => item.id == form.value.productModelId);
          if (selectedModel) {
            form.value.model = selectedModel.model || '';
            form.value.unit = selectedModel.unit || '';
          }
        }
      } catch (e) {
        console.error("加载规格型号失败", e);
@@ -337,6 +365,7 @@
      // 先加载指标选项
      let params = {
        productId: currentProductId.value,
        productModelId: form.value.productModelId || undefined,
        inspectType: 0
      }
      qualityInspectDetailByProductId(params).then(res => {
@@ -401,6 +430,8 @@
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 || '';
  // 规格型号变化后按 产品+规格型号 重新过滤可选指标
  getList(value);
}
const findNodeById = (nodes, productId) => {
@@ -459,7 +490,7 @@
  })
}
const getList = () => {
const getList = (modelId) => {
  if (!currentProductId.value) {
    testStandardOptions.value = [];
    tableData.value = [];
@@ -467,6 +498,7 @@
  }
  let params = {
    productId: currentProductId.value,
    productModelId: modelId ?? form.value.productModelId ?? undefined,
    inspectType: 0
  }
  qualityInspectDetailByProductId(params).then(res => {
@@ -531,6 +563,16 @@
  }
};
// 是否抽检切换
const handleSamplingChange = (value) => {
  if (value !== 1) {
    form.value.samplingQuantity = "";
    nextTick(() => {
      proxy.$refs?.formRef?.clearValidate?.("samplingQuantity");
    });
  }
};
// 关闭弹框
const closeDia = () => {
  proxy.resetForm("formRef");
@@ -546,5 +588,7 @@
</script>
<style scoped>
.sampling-radio-group {
  height: 32px;
}
</style>