From 53e0b9466d3fdd3e5caf7c42e476fffdb468bc2a Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期五, 27 三月 2026 17:17:22 +0800
Subject: [PATCH] 1

---
 src/views/salesManagement/salesLedger/index.vue |  100 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 93 insertions(+), 7 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 6254645..9ec8ef2 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -53,9 +53,11 @@
               <el-dropdown-menu>
                 <el-dropdown-item command="finishedProcessCard">鐢熶骇娴佺▼鍗★紙鎴愬搧锛�</el-dropdown-item>
                 <el-dropdown-item command="salesOrder">閿�鍞鍗�</el-dropdown-item>
+                <el-dropdown-item command="salesDeliveryNote">閿�鍞彂璐у崟</el-dropdown-item>
               </el-dropdown-menu>
             </template>
           </el-dropdown>
+          <el-button type="primary" plain @click="handlePrintLabel">鎵撳嵃鏍囩</el-button>
         </div>
       </div>
       <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
@@ -891,6 +893,9 @@
 	saleProcessBind,
 	getSaleProcessBindInfo,
 	getProcessCard,
+	getSalesOrder,
+	getSalesInvoices,
+	getSalesLabel,
 } from "@/api/salesManagement/salesLedger.js";
 import { modelList, productTreeList } from "@/api/basicData/product.js";
 import useFormData from "@/hooks/useFormData.js";
@@ -898,6 +903,8 @@
 import { getCurrentDate } from "@/utils/index.js";
 import { printFinishedProcessCard } from "./components/processCardPrint.js";
 import { printSalesOrder } from "./components/salesOrderPrint.js";
+import { printSalesDeliveryNote } from "./components/salesDeliveryPrint.js";
+import { printSalesLabel } from "./components/salesLabelPrint.js";
 // import { salesLedgerProductSetProcessFlowConfig } from "@/api/salesManagement/salesProcessFlowConfig.js";
 
 const userStore = useUserStore();
@@ -2025,14 +2032,53 @@
 };
 
 const handlePrintCommand = async (command) => {
-	if (command !== "finishedProcessCard" && command !== "salesOrder") return;
-	if (selectedRows.value.length !== 1) {
+	if (command !== "finishedProcessCard" && command !== "salesOrder" && command !== "salesDeliveryNote") return;
+	if (command === "salesDeliveryNote") {
+		if (selectedRows.value.length === 0) {
+			proxy.$modal.msgWarning("璇疯嚦灏戦�夋嫨涓�鏉¢攢鍞彴璐︽暟鎹繘琛屾墦鍗�");
+			return;
+		}
+		const customerNames = Array.from(
+			new Set(selectedRows.value.map((item) => String(item?.customerName ?? "").trim()))
+		);
+		if (customerNames.length > 1) {
+			proxy.$modal.msgWarning("浠呮敮鎸佺浉鍚屽鎴峰悕绉扮殑閿�鍞彴璐﹀悎骞跺彂璐ф墦鍗�");
+			return;
+		}
+	} else if (selectedRows.value.length !== 1) {
 		proxy.$modal.msgWarning("璇烽�夋嫨涓�鏉¢攢鍞彴璐︽暟鎹繘琛屾墦鍗�");
 		return;
 	}
 
 	const selectedRow = selectedRows.value[0];
 	const selectedId = selectedRow?.id;
+	if (command === "salesDeliveryNote") {
+		const selectedIds = selectedRows.value
+			.map((item) => item?.id)
+			.filter((id) => id !== null && id !== undefined && id !== "");
+		if (selectedIds.length !== selectedRows.value.length) {
+			proxy.$modal.msgWarning("褰撳墠閫夋嫨鏁版嵁瀛樺湪缂哄皯ID鐨勮褰曪紝鏃犳硶鎵撳嵃");
+			return;
+		}
+		const loadingText =
+			command === "salesOrder"
+				? "姝e湪鑾峰彇閿�鍞鍗曟暟鎹紝璇风◢鍊�..."
+				: command === "salesDeliveryNote"
+					? "姝e湪鑾峰彇閿�鍞彂璐у崟鏁版嵁锛岃绋嶅��..."
+					: "姝e湪鑾峰彇鐢熶骇娴佺▼鍗℃暟鎹紝璇风◢鍊�...";
+		proxy.$modal.loading(loadingText);
+		try {
+			const res = await getSalesInvoices(selectedIds);
+			const salesInvoiceData = res?.data ?? {};
+			printSalesDeliveryNote(salesInvoiceData, selectedRow);
+		} catch (error) {
+			console.error("鎵撳嵃閿�鍞彂璐у崟澶辫触:", error);
+			proxy.$modal.msgError("鎵撳嵃澶辫触锛岃绋嶅悗閲嶈瘯");
+		} finally {
+			proxy.$modal.closeLoading();
+		}
+		return;
+	}
 	if (!selectedId) {
 		proxy.$modal.msgWarning("褰撳墠閫夋嫨鏁版嵁缂哄皯ID锛屾棤娉曟墦鍗�");
 		return;
@@ -2041,24 +2087,64 @@
 	const loadingText =
 		command === "salesOrder"
 			? "姝e湪鑾峰彇閿�鍞鍗曟暟鎹紝璇风◢鍊�..."
-			: "姝e湪鑾峰彇鐢熶骇娴佺▼鍗℃暟鎹紝璇风◢鍊�...";
+			: command === "salesDeliveryNote"
+				? "姝e湪鑾峰彇閿�鍞彂璐у崟鏁版嵁锛岃绋嶅��..."
+				: "姝e湪鑾峰彇鐢熶骇娴佺▼鍗℃暟鎹紝璇风◢鍊�...";
 	proxy.$modal.loading(loadingText);
 	try {
-		const res = await getProcessCard(selectedId);
-		const processCardData = res?.data ?? {};
 		if (command === "salesOrder") {
-			printSalesOrder(processCardData);
+			const res = await getSalesOrder(selectedId);
+			const salesOrderData = res?.data ?? {};
+			printSalesOrder(salesOrderData);
 		} else {
+			const res = await getProcessCard(selectedId);
+			const processCardData = res?.data ?? {};
 			printFinishedProcessCard(processCardData);
 		}
 	} catch (error) {
-		console.error(command === "salesOrder" ? "鎵撳嵃閿�鍞鍗曞け璐�:" : "鎵撳嵃鐢熶骇娴佺▼鍗″け璐�:", error);
+		console.error(
+			command === "salesOrder"
+				? "鎵撳嵃閿�鍞鍗曞け璐�:"
+				: command === "salesDeliveryNote"
+					? "鎵撳嵃閿�鍞彂璐у崟澶辫触:"
+					: "鎵撳嵃鐢熶骇娴佺▼鍗″け璐�:",
+			error
+		);
 		proxy.$modal.msgError("鎵撳嵃澶辫触锛岃绋嶅悗閲嶈瘯");
 	} finally {
 		proxy.$modal.closeLoading();
 	}
 };
 
+const handlePrintLabel = async () => {
+	if (selectedRows.value.length !== 1) {
+		proxy.$modal.msgWarning("璇烽�夋嫨涓�鏉¢攢鍞彴璐︽暟鎹繘琛屾爣绛炬墦鍗�");
+		return;
+	}
+
+	const selectedId = selectedRows.value[0]?.id;
+	if (!selectedId) {
+		proxy.$modal.msgWarning("褰撳墠閫夋嫨鏁版嵁缂哄皯ID锛屾棤娉曟墦鍗版爣绛�");
+		return;
+	}
+
+	proxy.$modal.loading("姝e湪鑾峰彇鏍囩鏁版嵁锛岃绋嶅��...");
+	try {
+		const res = await getSalesLabel(selectedId);
+		const labelList = res?.data ?? [];
+		if (!Array.isArray(labelList) || labelList.length === 0) {
+			proxy.$modal.msgWarning("鏆傛棤鍙墦鍗版爣绛炬暟鎹�");
+			return;
+		}
+		printSalesLabel(labelList);
+	} catch (error) {
+		console.error("鎵撳嵃鏍囩澶辫触:", error);
+		proxy.$modal.msgError("鎵撳嵃鏍囩澶辫触锛岃绋嶅悗閲嶈瘯");
+	} finally {
+		proxy.$modal.closeLoading();
+	}
+};
+
 const mathNum = () => {
 	console.log("productForm.value", productForm.value);
 	if (!productForm.value.taxInclusiveUnitPrice) {

--
Gitblit v1.9.3