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 | 103 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 72 insertions(+), 31 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index f1fb9a2..351cefd 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -45,16 +45,22 @@
<el-table-column align="center" type="selection" width="55" />
<el-table-column type="expand">
<template #default="props">
- <el-table :data="props.row.children" border show-summary :summary-method="summarizeChildrenTable">
- <el-table-column align="center" label="搴忓彿" type="index" width="60" />
- <el-table-column label="浜у搧澶х被" prop="productCategory" />
- <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
- <el-table-column label="鍗曚綅" prop="unit" />
- <el-table-column label="鏁伴噺" prop="quantity" />
- <el-table-column label="绋庣巼(%)" prop="taxRate" />
- <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" />
- <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
- <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
+ <el-table :data="props.row.children" border show-summary :summary-method="summarizeChildrenTable" style="min-width: 1200px;"
+ scrollbar-always-on>
+ <el-table-column align="center" label="搴忓彿" type="index" width="70" />
+ <el-table-column label="浜у搧澶х被" prop="productCategory" width="160" />
+ <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" width="220" />
+ <el-table-column label="鍗曚綅" prop="unit" width="100" />
+ <el-table-column label="鏁伴噺" prop="quantity" width="120" />
+ <el-table-column label="绋庣巼(%)" prop="taxRate" width="120" />
+ <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" width="160" />
+ <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" width="180" />
+ <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" width="180" />
+ <el-table-column fixed="right" label="鎿嶄綔" width="150" align="center">
+ <template #default="scope">
+ <el-button link type="primary" size="small" @click="openDeliveryForm(props.row, scope.row)">鍙戣揣</el-button>
+ </template>
+ </el-table-column>
</el-table>
</template>
</el-table-column>
@@ -70,12 +76,11 @@
<el-table-column label="褰曞叆浜�" prop="entryPersonName" width="100" show-overflow-tooltip />
<el-table-column label="褰曞叆鏃ユ湡" prop="entryDate" width="120" show-overflow-tooltip />
<el-table-column label="绛捐鏃ユ湡" prop="executionDate" width="120" show-overflow-tooltip />
- <el-table-column fixed="right" label="鎿嶄綔" min-width="200" align="center">
+ <el-table-column fixed="right" label="鎿嶄綔" min-width="150" align="center">
<template #default="scope">
- <el-button link type="primary" size="small" :disabled="scope.row.invoiceTotal>0 || scope.row.entryPersonName !== userStore.nickName" @click="openForm('edit', scope.row)">缂栬緫</el-button>
+ <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">缂栬緫</el-button>
<!-- <el-button link type="primary" size="small" @click="openForm('view', scope.row)">璇︽儏</el-button>-->
<el-button link type="primary" size="small" @click="downLoadFile(scope.row)">闄勪欢</el-button>
- <el-button link type="primary" size="small" @click="openDeliveryForm(scope.row)">鍙戣揣</el-button>
</template>
</el-table-column>
</el-table>
@@ -142,7 +147,7 @@
<el-col :span="12">
<el-form-item label="褰曞叆鏃ユ湡锛�" prop="entryDate">
<el-date-picker style="width: 100%" v-model="form.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
- type="date" placeholder="璇烽�夋嫨" clearable disabled />
+ type="date" placeholder="璇烽�夋嫨" clearable />
</el-form-item>
</el-col>
</el-row>
@@ -477,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();
@@ -505,12 +514,9 @@
customerContractNo: "", // 瀹㈡埛鍚堝悓缂栧彿
salesContractNo: "", // 閿�鍞悎鍚岀紪鍙�
projectName: "", // 椤圭洰鍚嶇О
- entryDate: [
- dayjs().format("YYYY-MM-DD"),
- dayjs().add(1, "day").format("YYYY-MM-DD"),
- ], // 褰曞叆鏃ユ湡
- entryDateStart: dayjs().format("YYYY-MM-DD"),
- entryDateEnd: dayjs().add(1, "day").format("YYYY-MM-DD"),
+ entryDate: null, // 褰曞叆鏃ユ湡
+ entryDateStart: undefined,
+ entryDateEnd: undefined,
},
form: {
salesContractNo: "",
@@ -591,7 +597,7 @@
// 鍙戣揣鐩稿叧
const deliveryFormVisible = ref(false);
-const currentDeliveryRow = ref(null);
+const currentDeliveryContext = ref(null);
const deliveryFormData = reactive({
deliveryForm: {
shippingDate: "",
@@ -1526,13 +1532,48 @@
}
// 鎵撳紑鍙戣揣寮规
-const openDeliveryForm = (row) => {
- currentDeliveryRow.value = row;
- 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("鑾峰彇搴撳瓨淇℃伅澶辫触锛岃閲嶈瘯");
+ }
};
// 鎻愪氦鍙戣揣琛ㄥ崟
@@ -1540,14 +1581,14 @@
proxy.$refs["deliveryFormRef"].validate((valid) => {
if (valid) {
addShippingInfo({
- salesLedgerId: currentDeliveryRow.value.id,
+ salesLedgerId: currentDeliveryContext.value.parentRow.id,
+ salesLedgerProductId: currentDeliveryContext.value.productRow.id,
shippingDate: deliveryForm.value.shippingDate,
shippingCarNumber: deliveryForm.value.shippingCarNumber,
})
.then(() => {
proxy.$modal.msgSuccess("鍙戣揣鎴愬姛");
closeDeliveryDia();
- getList();
})
.catch(() => {
proxy.$modal.msgError("鍙戣揣澶辫触锛岃閲嶈瘯");
@@ -1560,7 +1601,7 @@
const closeDeliveryDia = () => {
proxy.resetForm("deliveryFormRef");
deliveryFormVisible.value = false;
- currentDeliveryRow.value = null;
+ currentDeliveryContext.value = null;
};
onMounted(() => {
--
Gitblit v1.9.3