| | |
| | | prop="quantity" /> |
| | | <el-table-column label="每件数量" |
| | | prop="singleQuantity" /> |
| | | <el-table-column label="总数" |
| | | prop="totalQuantity" /> |
| | | <el-table-column label="待发货数量" |
| | | prop="noQuantity" /> |
| | | <el-table-column label="税率(%)" |
| | |
| | | prop="quantity" /> |
| | | <el-table-column label="每件数量" |
| | | prop="singleQuantity" /> |
| | | <el-table-column label="总数" |
| | | prop="totalQuantity" /> |
| | | <el-table-column label="税率(%)" |
| | | prop="taxRate" /> |
| | | <el-table-column label="含税单价(元)" |
| | |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="总数:" |
| | | prop="totalQuantity"> |
| | | <el-input v-model="productForm.totalQuantity" |
| | | placeholder="自动计算" |
| | | disabled |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | |
| | | <!-- 发货弹框 --> |
| | | <el-dialog v-model="deliveryFormVisible" |
| | | title="发货信息" |
| | | width="40%" |
| | | width="70%" |
| | | @close="closeDeliveryDia"> |
| | | <el-form :model="deliveryForm" |
| | | label-width="120px" |
| | |
| | | unit: "", |
| | | quantity: "", |
| | | singleQuantity: 1, |
| | | totalQuantity: "", |
| | | taxInclusiveUnitPrice: "", |
| | | taxRate: "", |
| | | taxInclusiveTotalPrice: "", |
| | |
| | | productData.value = products.map(p => { |
| | | const quantity = Number(p.quantity ?? 0) || 0; |
| | | const unitPrice = Number(p.unitPrice ?? 0) || 0; |
| | | const singleQuantity = 1; |
| | | const taxRate = "13"; // 默认 13%,便于直接提交(如需可在产品中自行修改) |
| | | const taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | const taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice( |
| | |
| | | specificationModel: p.specification || "", |
| | | unit: p.unit || "", |
| | | quantity: quantity, |
| | | singleQuantity: singleQuantity, |
| | | totalQuantity: String(quantity * singleQuantity), |
| | | taxRate: taxRate, |
| | | taxInclusiveUnitPrice: unitPrice.toFixed(2), |
| | | taxInclusiveTotalPrice: taxInclusiveTotalPrice, |
| | |
| | | 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 totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice); |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | |
| | | if (!totalPrice || !quantity || quantity <= 0) { |
| | | return; |
| | |
| | | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税单价 = 含税总价 / (数量 * 每件数量) |
| | | productForm.value.taxInclusiveUnitPrice = (totalPrice / (quantity * singleQuantity)).toFixed(2); |
| | | // 计算含税单价 = 含税总价 / 数量 |
| | | productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productForm.value.taxRate) { |
| | |
| | | productForm.value.taxRate |
| | | ); |
| | | } |
| | | |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | |
| | | ); |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | const taxRate = parseFloat(productForm.value.taxRate); |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | |
| | | if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) { |
| | | return; |
| | |
| | | const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal); |
| | | productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2); |
| | | |
| | | // 计算含税单价 = 含税总价 / (数量 * 每件数量) |
| | | // 计算含税单价 = 含税总价 / 数量 |
| | | productForm.value.taxInclusiveUnitPrice = ( |
| | | inclusiveTotalPrice / (quantity * singleQuantity) |
| | | inclusiveTotalPrice / quantity |
| | | ).toFixed(2); |
| | | |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | |
| | | |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice); |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | |
| | | if (!quantity || quantity <= 0 || !unitPrice) { |
| | | return; |
| | |
| | | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税总价 = 单价 * 数量 * 每件数量 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2); |
| | | // 计算含税总价 = 单价 * 数量 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productForm.value.taxRate) { |
| | |
| | | productForm.value.taxRate |
| | | ); |
| | | } |
| | | |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | |
| | | |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice); |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | |
| | | if (!quantity || quantity <= 0 || !unitPrice) { |
| | | return; |
| | |
| | | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税总价 = 单价 * 数量 * 每件数量 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2); |
| | | // 计算含税总价 = 单价 * 数量 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productForm.value.taxRate) { |
| | |
| | | isCalculating.value = false; |
| | | }; |
| | | |
| | | // 根据每件数量变化计算总价 |
| | | // 根据每件数量变化计算总数 |
| | | const calculateFromSingleQuantity = () => { |
| | | if (!productForm.value.taxRate) { |
| | | proxy.$modal.msgWarning("请先选择税率"); |
| | | return; |
| | | } |
| | | if (isCalculating.value) return; |
| | | |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice); |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | |
| | | if (!quantity || quantity <= 0 || !unitPrice) { |
| | | if (!quantity || quantity <= 0) { |
| | | return; |
| | | } |
| | | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税总价 = 单价 * 数量 * 每件数量 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productForm.value.taxRate) { |
| | | productForm.value.taxExclusiveTotalPrice = |
| | | proxy.calculateTaxExclusiveTotalPrice( |
| | | productForm.value.taxInclusiveTotalPrice, |
| | | productForm.value.taxRate |
| | | ); |
| | | } |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | |
| | | 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: "", |