| | |
| | | disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="超发数量:"> |
| | | <el-input :model-value="excessDeliveryQuantity" |
| | | disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30" |
| | | v-if="deliveryForm.type === '货车'"> |
| | |
| | | ) |
| | | ); |
| | | }); |
| | | const getDeliveryBatchDeliveryMax = row => { |
| | | const productQuantity = getCurrentDeliveryRowQuantity(); |
| | | const batchQuantity = Number(getDeliveryBatchQuantity(row) || 0); |
| | | const otherBatchTotal = roundAmount( |
| | | (deliveryForm.value.batchNoList || []).reduce( |
| | | (sum, item) => { |
| | | if (item?.id === row?.id) return sum; |
| | | return sum + Number(item?.deliveryQuantity || 0); |
| | | }, |
| | | 0 |
| | | const excessDeliveryQuantity = computed(() => { |
| | | return roundAmount( |
| | | Math.max( |
| | | 0, |
| | | selectedDeliveryQuantity.value - getCurrentDeliveryRowQuantity() |
| | | ) |
| | | ); |
| | | const remainingProductQuantity = roundAmount( |
| | | Math.max(0, productQuantity - otherBatchTotal) |
| | | ); |
| | | return Math.max(0, Math.min(batchQuantity, remainingProductQuantity)); |
| | | }); |
| | | const getDeliveryBatchDeliveryMax = row => { |
| | | const batchQuantity = Number(getDeliveryBatchQuantity(row) || 0); |
| | | return Math.max(0, batchQuantity); |
| | | }; |
| | | const handleDeliveryBatchQuantityChange = row => { |
| | | const productQuantity = getCurrentDeliveryRowQuantity(); |
| | | const batchQuantity = Number(getDeliveryBatchQuantity(row) || 0); |
| | | const otherBatchTotal = roundAmount( |
| | | (deliveryForm.value.batchNoList || []).reduce( |
| | | (sum, item) => { |
| | | if (item?.id === row?.id) return sum; |
| | | return sum + Number(item?.deliveryQuantity || 0); |
| | | }, |
| | | 0 |
| | | ) |
| | | ); |
| | | const remainingProductQuantity = roundAmount( |
| | | Math.max(0, productQuantity - otherBatchTotal) |
| | | ); |
| | | const currentValue = Number(row?.deliveryQuantity || 0); |
| | | |
| | | if (currentValue > batchQuantity) { |
| | | row.deliveryQuantity = batchQuantity; |
| | | proxy.$modal.msgWarning("发货数量不能大于库存数量"); |
| | | } else if (currentValue > remainingProductQuantity) { |
| | | row.deliveryQuantity = remainingProductQuantity; |
| | | proxy.$modal.msgWarning("所有批次发货数量之和不能大于待发货数量"); |
| | | } |
| | | }; |
| | | const getSelectedDeliveryBatchRows = () => { |
| | |
| | | const selectedBatchRows = getSelectedDeliveryBatchRows(); |
| | | if (selectedBatchRows.length === 0) { |
| | | proxy.$modal.msgWarning("请至少填写一个批号的发货数量"); |
| | | return; |
| | | } |
| | | const totalDeliveryQuantity = roundAmount( |
| | | selectedBatchRows.reduce( |
| | | (sum, item) => sum + Number(item.deliveryQuantity || 0), |
| | | 0 |
| | | ) |
| | | ); |
| | | const currentRowNoQuantity = Number( |
| | | currentDeliveryRow.value?.noQuantity || 0 |
| | | ); |
| | | if ( |
| | | currentRowNoQuantity > 0 && |
| | | totalDeliveryQuantity > currentRowNoQuantity |
| | | ) { |
| | | proxy.$modal.msgWarning("批号发货总数不能超过待发货数量"); |
| | | return; |
| | | } |
| | | // 保存当前展开的行ID,以便发货后重新加载子表格数据 |