| | |
| | | <!-- 发货弹框 --> |
| | | <el-dialog v-model="deliveryFormVisible" |
| | | title="发货信息" |
| | | width="40%" |
| | | width="70%" |
| | | @close="closeDeliveryDia"> |
| | | <el-form :model="deliveryForm" |
| | | label-width="120px" |
| | |
| | | if (type === "edit") { |
| | | productForm.value = { ...row }; |
| | | productIndex.value = index; |
| | | // 如果没有 totalQuantity,自动计算:总数 = 每件数量 * 数量 |
| | | if (!productForm.value.totalQuantity && productForm.value.quantity) { |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | } |
| | | // 编辑时根据产品大类名称反查 tree 节点 id,并加载规格型号列表 |
| | | try { |
| | | const options = |
| | |
| | | const batchNoList = await getDeliveryBatchNoList( |
| | | row.productModelId || row.modelId |
| | | ); |
| | | |
| | | // 自动分配发货数量:按照待发货数量,从上到下依次分配 |
| | | const noQuantity = Number(row?.noQuantity || 0); |
| | | let remainingQuantity = noQuantity; |
| | | batchNoList.forEach(item => { |
| | | if (remainingQuantity <= 0) { |
| | | item.deliveryQuantity = 0; |
| | | return; |
| | | } |
| | | const batchStockQuantity = getDeliveryBatchQuantity(item); |
| | | // 当前批次可分配的数量:取剩余待发货数量和库存数量的较小值 |
| | | const assignQuantity = Math.min(remainingQuantity, batchStockQuantity); |
| | | item.deliveryQuantity = assignQuantity; |
| | | remainingQuantity -= assignQuantity; |
| | | }); |
| | | |
| | | deliveryForm.value = { |
| | | shippingCarNumber: "", |
| | | expressCompany: "", |