From 3c875736f8c12f27af835da110dcc3653a8676d6 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期六, 11 七月 2026 17:09:28 +0800
Subject: [PATCH] feat: 添加采购订单导出Word文档功能
---
src/views/procurementManagement/procurementLedger/index.vue | 40 ++++++++++++++++++++++++++++++++++++++++
src/api/procurementManagement/procurementLedger.js | 10 ++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/src/api/procurementManagement/procurementLedger.js b/src/api/procurementManagement/procurementLedger.js
index 5f9df05..578d710 100644
--- a/src/api/procurementManagement/procurementLedger.js
+++ b/src/api/procurementManagement/procurementLedger.js
@@ -122,4 +122,14 @@
method: "get",
params: id,
});
+}
+
+// 瀵煎嚭閲囪喘璁㈠崟Word鏂囨。
+export function exportPurchaseOrderDocx(id) {
+ return request({
+ url: "/purchase/ledger/exportDocx",
+ method: "post",
+ params: { id },
+ responseType: "blob",
+ });
}
\ No newline at end of file
diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index c6d4c93..dd78f39 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -43,6 +43,7 @@
<el-button type="primary" @click="openForm('add')">鏂板鍙拌处</el-button>
<el-button type="primary" plain @click="handleImport">瀵煎叆</el-button>
<el-button @click="handleOut">瀵煎嚭</el-button>
+ <el-button type="success" plain @click="handleExportDocx">瀵煎嚭閲囪喘璁㈠崟</el-button>
<el-button type="danger" plain @click="handleDelete">鍒犻櫎
</el-button>
</div>
@@ -405,6 +406,7 @@
getOptions,
getPurchaseTemplateList,
delPurchaseTemplate,
+ exportPurchaseOrderDocx,
} from "@/api/procurementManagement/procurementLedger.js";
import useFormData from "@/hooks/useFormData.js";
const FileList = defineAsyncComponent(() =>
@@ -1400,6 +1402,44 @@
proxy.$modal.msg("宸插彇娑�");
});
};
+// 瀵煎嚭閲囪喘璁㈠崟锛圵ord妯℃澘锛�
+const handleExportDocx = () => {
+ if (selectedRows.value.length === 0) {
+ proxy.$modal.msgWarning("璇峰厛閫夋嫨涓�鏉℃暟鎹�");
+ return;
+ }
+ if (selectedRows.value.length > 1) {
+ proxy.$modal.msgWarning("璇烽�夋嫨涓�鏉℃暟鎹鍑�");
+ return;
+ }
+ const row = selectedRows.value[0];
+ ElMessageBox.confirm(`纭畾瀵煎嚭閲囪喘璁㈠崟锛�${row.purchaseContractNumber}锛夛紵`, "瀵煎嚭閲囪喘璁㈠崟", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "info",
+ })
+ .then(async () => {
+ try {
+ const res = await exportPurchaseOrderDocx(row.id);
+ const blob = new Blob([res], { type: "application/msword" });
+ const url = window.URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.href = url;
+ link.download = `閲囪喘璁㈠崟_${row.purchaseContractNumber || row.id}.docx`;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ window.URL.revokeObjectURL(url);
+ proxy.$modal.msgSuccess("瀵煎嚭鎴愬姛");
+ } catch (error) {
+ console.error("瀵煎嚭閲囪喘璁㈠崟澶辫触:", error);
+ proxy.$modal.msgError("瀵煎嚭澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
// 鍒犻櫎
const handleDelete = () => {
let ids = [];
--
Gitblit v1.9.3