| | |
| | | </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> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测单位:" prop="checkCompany"> |
| | | <el-input v-model="form.checkCompany" placeholder="请输入" clearable :disabled="isViewMode"/> |
| | | </el-form-item> |
| | |
| | | qualifiedQuantity: "", |
| | | unqualifiedQuantity: "", |
| | | checkCompany: "", |
| | | isSampling: 0, |
| | | samplingQuantity: "", |
| | | }, |
| | | rules: { |
| | | checkTime: [{ required: true, message: "请输入", trigger: "blur" }], |
| | |
| | | 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 { form, rules } = toRefs(data); |
| | |
| | | const n = Number(fromApi); |
| | | if (!Number.isNaN(n)) return n; |
| | | } |
| | | const quantity = Number(form.value.quantity); |
| | | const qualified = Number(form.value.qualifiedQuantity); |
| | | if (!quantity || Number.isNaN(quantity)) return null; |
| | | const qualifiedNum = Number.isNaN(qualified) ? 0 : qualified; |
| | | return (qualifiedNum / quantity) * 100; |
| | | const qualified = Number(form.value.qualifiedQuantity) || 0; |
| | | const unqualified = Number(form.value.unqualifiedQuantity) || 0; |
| | | const total = qualified + unqualified; |
| | | if (!total || total === 0) return null; |
| | | return (qualified / total) * 100; |
| | | }); |
| | | |
| | | const passRateDisplayText = computed(() => { |
| | |
| | | ]); |
| | | userList.value = userListsRes.data; |
| | | |
| | | form.value = {} |
| | | form.value = { isSampling: 0, samplingQuantity: "" } |
| | | testStandardOptions.value = []; |
| | | tableData.value = []; |
| | | |
| | | if (operationType.value === 'edit' || operationType.value === 'view') { |
| | | // 先保存 testStandardId,避免被清空 |
| | | const savedTestStandardId = row.testStandardId; |
| | | // 先设置表单数据,但暂时清空 testStandardId,等选项加载完成后再设置 |
| | | form.value = {...row, testStandardId: ''} |
| | | const { passRate, ...rowWithoutPassRate } = row; |
| | | form.value = { ...rowWithoutPassRate, testStandardId: '' }; |
| | | currentProductId.value = row.productId || 0 |
| | | // 清空验证状态,避免数据加载过程中的校验闪烁 |
| | | nextTick(() => { |
| | |
| | | // 并行加载规格型号和指标选项 |
| | | const params = { |
| | | productId: currentProductId.value, |
| | | productModelId: form.value.productModelId || undefined, |
| | | inspectType: 2 |
| | | }; |
| | | |
| | |
| | | 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 handleQualifiedQuantityChange = (value) => { |
| | |
| | | } |
| | | }); |
| | | } |
| | | const getList = () => { |
| | | const getList = (modelId) => { |
| | | if (!currentProductId.value) { |
| | | testStandardOptions.value = []; |
| | | tableData.value = []; |
| | |
| | | } |
| | | let params = { |
| | | productId: currentProductId.value, |
| | | productModelId: modelId ?? form.value.productModelId ?? undefined, |
| | | inspectType: 2 |
| | | }; |
| | | qualityInspectDetailByProductId(params).then(res => { |
| | |
| | | tableData.value = res.data; |
| | | }); |
| | | } |
| | | // 是否抽检切换 |
| | | const handleSamplingChange = (value) => { |
| | | if (value !== 1) { |
| | | form.value.samplingQuantity = ""; |
| | | nextTick(() => { |
| | | proxy.$refs?.formRef?.clearValidate?.("samplingQuantity"); |
| | | }); |
| | | } |
| | | } |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | .sampling-radio-group { |
| | | height: 32px; |
| | | } |
| | | </style> |