| | |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="发货类型" |
| | | width="100" |
| | | align="center"> |
| | | <template #default="scope"> |
| | | <el-tag v-if="getShippingTypeText(scope.row)" |
| | | :type="getShippingTypeTag(scope.row)" |
| | | size="small"> |
| | | {{ getShippingTypeText(scope.row) }} |
| | | </el-tag> |
| | | <el-tag v-else |
| | | type="info" |
| | | size="small">- |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="快递公司" |
| | | prop="expressCompany" |
| | | show-overflow-tooltip /> |
| | |
| | | value="货车" /> |
| | | <el-option label="快递" |
| | | value="快递" /> |
| | | <el-option label="自送" |
| | | value="自送" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="已选择发货数量:"> |
| | | <el-input :model-value="selectedDeliveryQuantity" |
| | | disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24" |
| | | v-if="deliveryForm.type === '货车'"> |
| | | <el-row :gutter="30" |
| | | v-if="deliveryForm.type === '货车'"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="发货车牌号:" |
| | | prop="shippingCarNumber"> |
| | | <el-input v-model="deliveryForm.shippingCarNumber" |
| | |
| | | clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24" |
| | | v-else> |
| | | </el-row> |
| | | <el-row :gutter="30" |
| | | v-else-if="deliveryForm.type === '快递'"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="快递公司:" |
| | | prop="expressCompany"> |
| | | <el-input v-model="deliveryForm.expressCompany" |
| | |
| | | tableAmountFormatter, |
| | | formatDecimal, |
| | | buildAmountSummaryFormat, |
| | | roundAmount, |
| | | } from "@/utils/numberFormat"; |
| | | import ImageUpload from "@/components/AttachmentUpload/image/index.vue"; |
| | | import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue"; |
| | |
| | | rawList.forEach(item => { |
| | | total += Number(getDeliveryBatchQuantity(item) || 0); |
| | | }); |
| | | currentStock.value = total; |
| | | currentStock.value = roundAmount(total); |
| | | } catch (e) { |
| | | console.error(e); |
| | | currentStock.value = 0; |
| | |
| | | const getCurrentDeliveryRowQuantity = () => { |
| | | return Number(currentDeliveryRow.value?.noQuantity || 0); |
| | | }; |
| | | const selectedDeliveryQuantity = computed(() => { |
| | | return roundAmount( |
| | | (deliveryForm.value.batchNoList || []).reduce( |
| | | (sum, item) => sum + Number(item?.deliveryQuantity || 0), |
| | | 0 |
| | | ) |
| | | ); |
| | | }); |
| | | const getDeliveryBatchDeliveryMax = row => { |
| | | const productQuantity = getCurrentDeliveryRowQuantity(); |
| | | const batchQuantity = Number(getDeliveryBatchQuantity(row) || 0); |
| | | const otherBatchTotal = (deliveryForm.value.batchNoList || []).reduce( |
| | | (sum, item) => { |
| | | if (item?.id === row?.id) return sum; |
| | | return sum + Number(item?.deliveryQuantity || 0); |
| | | }, |
| | | 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 = Math.max( |
| | | 0, |
| | | productQuantity - otherBatchTotal |
| | | const remainingProductQuantity = roundAmount( |
| | | Math.max(0, productQuantity - otherBatchTotal) |
| | | ); |
| | | return Math.max(0, Math.min(batchQuantity, remainingProductQuantity)); |
| | | }; |
| | | const handleDeliveryBatchQuantityChange = row => { |
| | | const productQuantity = getCurrentDeliveryRowQuantity(); |
| | | const batchQuantity = Number(getDeliveryBatchQuantity(row) || 0); |
| | | const otherBatchTotal = (deliveryForm.value.batchNoList || []).reduce( |
| | | (sum, item) => { |
| | | if (item?.id === row?.id) return sum; |
| | | return sum + Number(item?.deliveryQuantity || 0); |
| | | }, |
| | | 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 = Math.max( |
| | | 0, |
| | | productQuantity - otherBatchTotal |
| | | const remainingProductQuantity = roundAmount( |
| | | Math.max(0, productQuantity - otherBatchTotal) |
| | | ); |
| | | const currentValue = Number(row?.deliveryQuantity || 0); |
| | | |
| | |
| | | shippingCarNumber: "", |
| | | expressCompany: "", |
| | | expressNumber: "", |
| | | type: "货车", // 货车, 快递 |
| | | type: "货车", // 货车, 快递, 自送 |
| | | }, |
| | | deliveryRules: { |
| | | shippingCarNumber: [ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * 获取发货类型文本(货车/快递/自送) |
| | | * 子表行未返回发货类型字段,依据互斥的发货信息推断: |
| | | * 有车牌为货车,有快递公司/单号为快递,已发货但两者皆无为自送 |
| | | */ |
| | | const getShippingTypeText = row => { |
| | | if (!row) return ""; |
| | | if (row.shippingCarNumber) return "货车"; |
| | | if (row.expressCompany || row.expressNumber) return "快递"; |
| | | if (row.shippingDate) return "自送"; |
| | | return ""; |
| | | }; |
| | | |
| | | const getShippingTypeTag = row => { |
| | | const type = getShippingTypeText(row); |
| | | const typeTagMap = { |
| | | 货车: "warning", |
| | | 快递: "primary", |
| | | 自送: "success", |
| | | }; |
| | | return typeTagMap[type] || "info"; |
| | | }; |
| | | |
| | | /** |
| | | * 判断是否可以发货 |
| | | * 只有在产品状态是充足,发货状态是待发货和审核拒绝的时候才可以发货 |
| | | * @param row 行数据 |
| | |
| | | proxy.$modal.msgWarning("请至少填写一个批号的发货数量"); |
| | | return; |
| | | } |
| | | const totalDeliveryQuantity = selectedBatchRows.reduce( |
| | | (sum, item) => sum + Number(item.deliveryQuantity || 0), |
| | | 0 |
| | | const totalDeliveryQuantity = roundAmount( |
| | | selectedBatchRows.reduce( |
| | | (sum, item) => sum + Number(item.deliveryQuantity || 0), |
| | | 0 |
| | | ) |
| | | ); |
| | | const currentRowNoQuantity = Number( |
| | | currentDeliveryRow.value?.noQuantity || 0 |
| | |
| | | if (val === "货车") { |
| | | deliveryForm.value.expressCompany = ""; |
| | | deliveryForm.value.expressNumber = ""; |
| | | } else if (val === "快递") { |
| | | deliveryForm.value.shippingCarNumber = ""; |
| | | } else { |
| | | deliveryForm.value.shippingCarNumber = ""; |
| | | deliveryForm.value.expressCompany = ""; |
| | | deliveryForm.value.expressNumber = ""; |
| | | } |
| | | }; |
| | | |