| | |
| | | <el-table-column label="产品名称" prop="productName" min-width="120" /> |
| | | <el-table-column label="单位产出需要数量" min-width="140"> |
| | | <template #default="{ row }"> |
| | | <el-input-number v-model="row.unitQuantity" :min="0" :precision="2" size="small" style="width: 100%" /> |
| | | <el-input-number |
| | | v-model="row.unitQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | size="small" |
| | | style="width: 100%" |
| | | @change="(val) => handleUnitQuantityChange(val, row)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="需求数量" min-width="120"> |
| | |
| | | }); |
| | | }; |
| | | |
| | | // 监听物料清单变化,当单位产出需要数量变化时重新计算需求数量 |
| | | watch(() => productStructureRecords.value, (newRecords, oldRecords) => { |
| | | if (oldRecords && oldRecords.length > 0) { |
| | | oldRecords.forEach((oldItem, index) => { |
| | | const newItem = newRecords[index]; |
| | | if (oldItem && newItem && newItem.unitQuantity !== oldItem.unitQuantity) { |
| | | newItem.demandedQuantity = (newItem.unitQuantity || 1) * (formState.value.quantity || 1); |
| | | } |
| | | }); |
| | | } |
| | | }, { deep: true }); |
| | | |
| | | // 监听需求数量变化,重新计算物料需求数量 |
| | | watch(() => formState.value.quantity, (newQty) => { |
| | | if (productStructureRecords.value.length > 0 && newQty) { |
| | | productStructureRecords.value = productStructureRecords.value.map(item => ({ |
| | | ...item, |
| | | demandedQuantity: (item.unitQuantity || 1) * newQty |
| | | })); |
| | | productStructureRecords.value.forEach(item => { |
| | | item.demandedQuantity = (item.unitQuantity || 1) * newQty; |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | // 单位产出需要数量变化处理 |
| | | const handleUnitQuantityChange = (val, row) => { |
| | | row.demandedQuantity = (val || 1) * (formState.value.quantity || 1); |
| | | }; |
| | | |
| | | // 工序选择变化处理 |
| | | const handleProcessChange = (processId, row) => { |
| | | const selectedProcess = processRouteItemsOptions.value.find(item => item.processId === processId); |