| | |
| | | import { modelList, productTreeList } from "@/api/basicData/product.js"; |
| | | import useFormData from "@/hooks/useFormData.js"; |
| | | import dayjs from "dayjs"; |
| | | import { |
| | | getStockInPage |
| | | } from "@/api/inventoryManagement/stockIn.js"; |
| | | |
| | | |
| | | const userStore = useUserStore(); |
| | | const { proxy } = getCurrentInstance(); |
| | |
| | | } |
| | | |
| | | // 打开发货弹框 |
| | | const openDeliveryForm = (parentRow, productRow) => { |
| | | const openDeliveryForm = async (parentRow, productRow) => { |
| | | // productRow的minStock和quantity |
| | | console.log('22222', productRow) |
| | | |
| | | // 检查产品库存是否足够 |
| | | const requiredQuantity = productRow.quantity || 0; // 需要发货的数量 |
| | | |
| | | try { |
| | | // 等待获取库存信息 |
| | | const res = await getStockInPage({ |
| | | current: 1, |
| | | size: 100 |
| | | }); |
| | | // console.log('res33333', res.data.records) |
| | | // 通过 productRow.id 过滤出对应的库存记录 |
| | | const matchingStockRecords = res.data?.records?.filter(record => |
| | | record.salesLedgerProductId === productRow.id |
| | | ) || []; |
| | | |
| | | // 计算匹配记录的总库存数量 |
| | | const currentStock = matchingStockRecords.reduce((total, record) => { |
| | | return total + (record.inboundNum0 || 0); |
| | | }, 0); |
| | | // 检查库存是否充足 |
| | | if (currentStock < requiredQuantity) { |
| | | // 库存不足提示 |
| | | proxy.$modal.msgWarning(`产品库存不足`); |
| | | return; |
| | | } |
| | | |
| | | // 库存充足,继续打开发货弹框 |
| | | currentDeliveryContext.value = { parentRow, productRow }; |
| | | deliveryForm.value = { |
| | | shippingDate: getCurrentDate(), |
| | | shippingCarNumber: "", |
| | | }; |
| | | deliveryFormVisible.value = true; |
| | | |
| | | } catch (error) { |
| | | console.error('获取库存信息失败:', error); |
| | | proxy.$modal.msgError("获取库存信息失败,请重试"); |
| | | } |
| | | }; |
| | | |
| | | // 提交发货表单 |