| | |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogFormVisible" |
| | | :title="operationType === 'add' ? '新增出厂检验' : '编辑出厂检验'" |
| | | :title="operationType === 'add' ? '新增成品检验' : '编辑成品检验'" |
| | | width="70%" |
| | | @close="closeDia" |
| | | > |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="生产批号:"> |
| | | <el-input |
| | | :model-value="productionBatchDisplay" |
| | | disabled |
| | | placeholder="—" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="指标选择:" prop="testStandardId"> |
| | | <el-select |
| | | v-model="form.testStandardId" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="单位:" prop="unit"> |
| | | <el-input v-model="form.unit" placeholder="请输入" disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <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" :disabled="quantityDisabled"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="料号:" prop="materialCode"> |
| | | <el-input v-model="form.materialCode" placeholder="请输入" disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="不良数量:" prop="defectiveQuantity"> |
| | | <el-input v-model="form.defectiveQuantity" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="单位:" prop="unit"> |
| | | <el-input v-model="form.unit" placeholder="请输入" disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="合格数量:" prop="qualifiedQuantity"> |
| | | <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.qualifiedQuantity" placeholder="请输入" clearable :precision="2" disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="不良原因:" prop="defectiveReason"> |
| | | <el-select v-model="form.defectiveReason" placeholder="请选择" clearable style="width: 100%"> |
| | | <el-option :label="item.label" :value="item.value" v-for="(item,index) in defective_reason" :key="index" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测单位:" prop="checkCompany"> |
| | | <el-input v-model="form.checkCompany" placeholder="请输入" clearable/> |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="检验员:" prop="checkName"> |
| | | <el-select v-model="form.checkName" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" |
| | | :value="item.nickName"/> |
| | | </el-select> |
| | | <el-select v-model="form.checkName" placeholder="请选择" clearable> |
| | | <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"> |
| | |
| | | productModelId: "", |
| | | model: "", |
| | | testStandardId: "", |
| | | defectiveReason: undefined, |
| | | unit: "", |
| | | materialCode: "", |
| | | /** 来自生产工单/台账,仅展示 */ |
| | | batchNo: "", |
| | | qualifiedQuantity: "", |
| | | quantity: "", |
| | | checkCompany: "", |
| | | checkResult: "", |
| | |
| | | const v = form.value || {}; |
| | | return !!(v.productMainId != null || v.purchaseLedgerId != null); |
| | | }); |
| | | |
| | | /** 生产批号展示(接口可能为 batchNo 或 productionBatchNo) */ |
| | | const productionBatchDisplay = computed(() => { |
| | | const f = form.value || {}; |
| | | const v = f.batchNo ?? f.productionBatchNo; |
| | | if (v === null || v === undefined || String(v).trim() === "") { |
| | | return ""; |
| | | } |
| | | return String(v); |
| | | }); |
| | | const supplierList = ref([]); |
| | | const productOptions = ref([]); |
| | | const { defective_reason } = proxy.useDict("defective_reason"); |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "指标", |
| | |
| | | const testStandardOptions = ref([]); // 指标选择下拉框数据 |
| | | const modelOptions = ref([]); |
| | | |
| | | // 监听不良数量变化,自动更新数量 |
| | | // 当 defectiveQuantity 增加时,quantity 减少;当 defectiveQuantity 减少时,quantity 增加 |
| | | watch(() => form.value.defectiveQuantity, (newVal, oldVal) => { |
| | | if (newVal > form.value.quantity) { |
| | | form.value.defectiveQuantity = form.value.quantity; |
| | | } |
| | | form.value.qualifiedQuantity = Number((form.value.quantity - newVal).toFixed(2)); |
| | | }); |
| | | |
| | | // 监听总数量变化,自动更新合格数量 |
| | | watch(() => form.value.quantity, (newVal, oldVal) => { |
| | | const totalQty = Number(newVal) || 0; |
| | | const defectiveQty = Number(form.value.defectiveQuantity) || 0; |
| | | |
| | | // 确保不良数量不超过总数量 |
| | | if (defectiveQty > totalQty) { |
| | | form.value.defectiveQuantity = totalQty; |
| | | } |
| | | |
| | | // 计算合格数量 |
| | | form.value.qualifiedQuantity = Number((totalQty - defectiveQty).toFixed(2)); |
| | | }); |
| | | |
| | | // 打开弹框 |
| | | const openDialog = async (type, row) => { |
| | | operationType.value = type; |
| | |
| | | // 先保存 testStandardId,避免被清空 |
| | | const savedTestStandardId = row.testStandardId; |
| | | // 先设置表单数据,但暂时清空 testStandardId,等选项加载完成后再设置 |
| | | form.value = {...row, testStandardId: ''} |
| | | form.value = { ...row, testStandardId: "" }; |
| | | // 生产批号:与生产工单字段对齐,兼容多种后端字段名 |
| | | form.value.batchNo = |
| | | row.batchNo ?? row.productionBatchNo ?? form.value.batchNo ?? ""; |
| | | currentProductId.value = row.productId || 0 |
| | | // 清空验证状态,避免数据加载过程中的校验闪烁 |
| | | nextTick(() => { |
| | |
| | | if (selectedModel) { |
| | | form.value.model = selectedModel.model || ''; |
| | | form.value.unit = selectedModel.unit || ''; |
| | | form.value.materialCode = selectedModel.materialCode || ''; |
| | | } |
| | | } |
| | | |
| | |
| | | const getModels = (value) => { |
| | | form.value.productModelId = undefined; |
| | | form.value.unit = undefined; |
| | | form.value.materialCode = undefined; |
| | | modelOptions.value = []; |
| | | currentProductId.value = value |
| | | form.value.productName = findNodeById(productOptions.value, value); |
| | |
| | | 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 || ''; |
| | | form.value.materialCode = modelOptions.value.find(item => item.id == value)?.materialCode || ''; |
| | | } |
| | | |
| | | const findNodeById = (nodes, productId) => { |