From ba516e0748b221ae59aff5fdc681b83893386397 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 24 四月 2026 10:12:03 +0800
Subject: [PATCH] fix: 出入库审批

---
 src/views/inventoryManagement/dispatchLog/Record.vue       |   64 +++++++++++++++++++++
 src/api/inventoryManagement/stockOut.js                    |    9 +++
 src/api/inventoryManagement/stockInRecord.js               |    9 +++
 src/views/inventoryManagement/receiptManagement/Record.vue |   66 ++++++++++++++++++++++
 4 files changed, 148 insertions(+), 0 deletions(-)

diff --git a/src/api/inventoryManagement/stockInRecord.js b/src/api/inventoryManagement/stockInRecord.js
index 1746bfe..4c450fb 100644
--- a/src/api/inventoryManagement/stockInRecord.js
+++ b/src/api/inventoryManagement/stockInRecord.js
@@ -24,4 +24,13 @@
         method: "delete",
         data: ids,
     });
+};
+
+// 鎵归噺瀹℃壒鍏ュ簱璁板綍锛坅pprovalStatus: approved/rejected锛�
+export const batchApproveStockInRecords = (data) => {
+    return request({
+        url: "/stockInRecord/approve",
+        method: "post",
+        data,
+    });
 };
\ No newline at end of file
diff --git a/src/api/inventoryManagement/stockOut.js b/src/api/inventoryManagement/stockOut.js
index 3d260b3..f4fc40f 100644
--- a/src/api/inventoryManagement/stockOut.js
+++ b/src/api/inventoryManagement/stockOut.js
@@ -17,3 +17,12 @@
         data: ids,
     });
 }
+
+// 鎵归噺瀹℃壒鍑哄簱璁板綍锛坅pprovalStatus: approved/rejected锛�
+export const batchApproveStockOutRecords = (data) => {
+    return request({
+        url: "/stockOutRecord/approve",
+        method: "post",
+        data,
+    });
+}
diff --git a/src/views/inventoryManagement/dispatchLog/Record.vue b/src/views/inventoryManagement/dispatchLog/Record.vue
index ddaea92..061aeeb 100644
--- a/src/views/inventoryManagement/dispatchLog/Record.vue
+++ b/src/views/inventoryManagement/dispatchLog/Record.vue
@@ -27,6 +27,7 @@
 				>
 			</div>
 			<div>
+				<el-button type="primary" @click="handleBatchApprove">瀹℃壒</el-button>
 				<el-button @click="handleOut">瀵煎嚭</el-button>
 				<el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
 				<el-button type="primary" plain @click="handlePrint">鎵撳嵃</el-button>
@@ -93,6 +94,11 @@
             {{ getRecordType(scope.row.recordType) }}
           </template>
         </el-table-column>
+				<el-table-column label="瀹℃壒鐘舵��" prop="approvalStatus" show-overflow-tooltip>
+					<template #default="scope">
+						{{ getApprovalStatusLabel(scope.row.approvalStatus) }}
+					</template>
+				</el-table-column>
 			</el-table>
 			<pagination
 				v-show="total > 0"
@@ -115,6 +121,7 @@
 import {
 	getStockOutPage,
 	delStockOut,
+	batchApproveStockOutRecords,
 } from "@/api/inventoryManagement/stockOut.js";
 import {
   findAllQualifiedStockOutRecordTypeOptions, findAllUnQualifiedStockOutRecordTypeOptions,
@@ -190,6 +197,25 @@
   return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
 }
 
+const approvalStatusLabelMap = {
+	0: "寰呭鎵�",
+	1: "閫氳繃",
+	2: "椹冲洖",
+	pending: "寰呭鎵�",
+	approved: "閫氳繃",
+	rejected: "椹冲洖",
+	PENDING: "寰呭鎵�",
+	APPROVED: "閫氳繃",
+	REJECTED: "椹冲洖",
+};
+
+const getApprovalStatusLabel = (status) => {
+	if (status === null || status === undefined || status === "") {
+		return "寰呭鎵�";
+	}
+	return approvalStatusLabelMap[status] || "寰呭鎵�";
+};
+
 // 鑾峰彇鏉ユ簮绫诲瀷閫夐」
 const fetchStockRecordTypeOptions = () => {
   if (props.type === '0') {
@@ -213,6 +239,44 @@
 };
 const expandedRowKeys = ref([]);
 
+const handleBatchApprove = () => {
+	if (selectedRows.value.length === 0) {
+		proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+		return;
+	}
+	const ids = selectedRows.value.map((item) => item.id);
+	ElMessageBox.confirm("璇烽�夋嫨瀹℃壒缁撴灉", "瀹℃壒", {
+		confirmButtonText: "閫氳繃",
+		cancelButtonText: "椹冲洖",
+		type: "warning",
+		distinguishCancelAndClose: true,
+	})
+		.then(() => {
+			batchApproveStockOutRecords({ ids, approvalStatus: "閫氳繃" })
+				.then(() => {
+					proxy.$modal.msgSuccess("瀹℃壒閫氳繃鎴愬姛");
+					getList();
+				})
+				.catch(() => {
+					proxy.$modal.msgError("瀹℃壒閫氳繃澶辫触");
+				});
+		})
+		.catch((action) => {
+			if (action === "cancel") {
+				batchApproveStockOutRecords({ ids, approvalStatus: "椹冲洖" })
+					.then(() => {
+						proxy.$modal.msgSuccess("瀹℃壒椹冲洖鎴愬姛");
+						getList();
+					})
+					.catch(() => {
+						proxy.$modal.msgError("瀹℃壒椹冲洖澶辫触");
+					});
+				return;
+			}
+			proxy.$modal.msg("宸插彇娑�");
+		});
+};
+
 // 瀵煎嚭
 const handleOut = () => {
 	ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
diff --git a/src/views/inventoryManagement/receiptManagement/Record.vue b/src/views/inventoryManagement/receiptManagement/Record.vue
index 17ac048..013bac5 100644
--- a/src/views/inventoryManagement/receiptManagement/Record.vue
+++ b/src/views/inventoryManagement/receiptManagement/Record.vue
@@ -31,6 +31,7 @@
         </el-button>
       </div>
       <div>
+        <el-button type="primary" @click="handleBatchApprove">瀹℃壒</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger"
                    plain
@@ -86,6 +87,13 @@
             {{ getRecordType(scope.row.recordType) }}
           </template>
         </el-table-column>
+        <el-table-column label="瀹℃壒鐘舵��"
+                         prop="approvalStatus"
+                         show-overflow-tooltip>
+          <template #default="scope">
+            {{ getApprovalStatusLabel(scope.row.approvalStatus) }}
+          </template>
+        </el-table-column>
       </el-table>
       <pagination v-show="total > 0"
                   :total="total"
@@ -110,6 +118,7 @@
 import {
   getStockInRecordListPage,
   batchDeleteStockInRecords,
+  batchApproveStockInRecords,
 } from "@/api/inventoryManagement/stockInRecord.js";
 import {
   findAllQualifiedStockInRecordTypeOptions, findAllUnQualifiedStockInRecordTypeOptions,
@@ -159,6 +168,25 @@
   return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
 }
 
+const approvalStatusLabelMap = {
+  0: "寰呭鎵�",
+  1: "閫氳繃",
+  2: "椹冲洖",
+  pending: "寰呭鎵�",
+  approved: "閫氳繃",
+  rejected: "椹冲洖",
+  PENDING: "寰呭鎵�",
+  APPROVED: "閫氳繃",
+  REJECTED: "椹冲洖",
+};
+
+const getApprovalStatusLabel = (status) => {
+  if (status === null || status === undefined || status === "") {
+    return "寰呭鎵�";
+  }
+  return approvalStatusLabelMap[status] || "寰呭鎵�";
+};
+
 const pageProductChange = obj => {
   page.current = obj.page;
   page.size = obj.limit;
@@ -202,6 +230,44 @@
 
 const expandedRowKeys = ref([]);
 
+const handleBatchApprove = () => {
+  if (selectedRows.value.length === 0) {
+    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+    return;
+  }
+  const ids = selectedRows.value.map(item => item.id);
+  ElMessageBox.confirm("璇烽�夋嫨瀹℃壒缁撴灉", "瀹℃壒", {
+    confirmButtonText: "閫氳繃",
+    cancelButtonText: "椹冲洖",
+    type: "warning",
+    distinguishCancelAndClose: true,
+  })
+      .then(() => {
+        batchApproveStockInRecords({ids, approvalStatus: "閫氳繃"})
+            .then(() => {
+              proxy.$modal.msgSuccess("瀹℃壒閫氳繃鎴愬姛");
+              getList();
+            })
+            .catch(() => {
+              proxy.$modal.msgError("瀹℃壒閫氳繃澶辫触");
+            });
+      })
+      .catch((action) => {
+        if (action === "cancel") {
+          batchApproveStockInRecords({ids, approvalStatus: "椹冲洖"})
+              .then(() => {
+                proxy.$modal.msgSuccess("瀹℃壒椹冲洖鎴愬姛");
+                getList();
+              })
+              .catch(() => {
+                proxy.$modal.msgError("瀹℃壒椹冲洖澶辫触");
+              });
+          return;
+        }
+        proxy.$modal.msg("宸插彇娑�");
+      });
+};
+
 // 瀵煎嚭
 const handleOut = () => {
   ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {

--
Gitblit v1.9.3