From 23623551f46642c53c94593b90ab2d1c7e493258 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期一, 22 十二月 2025 17:20:22 +0800
Subject: [PATCH] 发货前校验产品库存
---
src/views/salesManagement/salesLedger/index.vue | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 2afec1f..351cefd 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -482,6 +482,10 @@
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();
@@ -1528,13 +1532,48 @@
}
// 鎵撳紑鍙戣揣寮规
-const openDeliveryForm = (parentRow, productRow) => {
- currentDeliveryContext.value = { parentRow, productRow };
- deliveryForm.value = {
- shippingDate: getCurrentDate(),
- shippingCarNumber: "",
- };
- deliveryFormVisible.value = true;
+const openDeliveryForm = async (parentRow, productRow) => {
+ // productRow鐨刴inStock鍜宷uantity
+ 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("鑾峰彇搴撳瓨淇℃伅澶辫触锛岃閲嶈瘯");
+ }
};
// 鎻愪氦鍙戣揣琛ㄥ崟
--
Gitblit v1.9.3