From dc3fc550fe292043cc452dc9aeb0c8a1eeab3b30 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 24 九月 2026 16:54:39 +0800
Subject: [PATCH] feat: 新增多模块导入导出入口

---
 src/views/customerService/expiryAfterSales/index.vue |   96 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 92 insertions(+), 4 deletions(-)

diff --git a/src/views/customerService/expiryAfterSales/index.vue b/src/views/customerService/expiryAfterSales/index.vue
index 9966785..1316593 100644
--- a/src/views/customerService/expiryAfterSales/index.vue
+++ b/src/views/customerService/expiryAfterSales/index.vue
@@ -34,10 +34,13 @@
 				>閲嶇疆</el-button
 				>
 			</div>
-			<div class="table_actions">
-				<el-button type="primary" @click="openForm('add')">鏂板</el-button>
-				<el-button type="danger" @click="handleDelete">鍒犻櫎</el-button>
-			</div>
+		</div>
+
+		<div class="table_header" style="display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-bottom: 10px;">
+			<el-button type="primary" @click="openForm('add')">鏂板</el-button>
+			<el-button type="info" plain icon="Upload" @click="handleImport">瀵煎叆</el-button>
+			<el-button @click="handleExport">瀵煎嚭</el-button>
+			<el-button type="danger" @click="handleDelete">鍒犻櫎</el-button>
 		</div>
 
 		<div class="table_list">
@@ -65,6 +68,28 @@
 			</PIMTable>
 		</div>
 		<form-dia ref="formDia" @close="handleQuery"></form-dia>
+		<!-- 涓存湡鍞悗瀵煎叆瀵硅瘽妗� -->
+		<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
+			<el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url"
+				:disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess"
+				:on-error="handleFileError" :auto-upload="false" drag>
+				<el-icon class="el-icon--upload"><upload-filled /></el-icon>
+				<div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+				<template #tip>
+					<div class="el-upload__tip text-center">
+						<span>浠呭厑璁稿鍏� xls銆亁lsx 鏍煎紡鏂囦欢銆�</span>
+						<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
+							@click="importTemplate">涓嬭浇妯℃澘</el-link>
+					</div>
+				</template>
+			</el-upload>
+			<template #footer>
+				<div class="dialog-footer">
+					<el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+					<el-button @click="upload.open = false">鍙� 娑�</el-button>
+				</div>
+			</template>
+		</el-dialog>
 	</div>
 </template>
 
@@ -75,6 +100,7 @@
 import {ElMessageBox} from "element-plus";
 import {expiryAfterSalesDelete, expiryAfterSalesListPage} from "@/api/customerService/index.js";
 import useUserStore from "@/store/modules/user.js";
+import { getToken } from "@/utils/auth.js";
 const { proxy } = getCurrentInstance();
 const userStore = useUserStore()
 
@@ -263,6 +289,68 @@
 		});
 };
 
+// 瀵煎嚭
+const handleExport = () => {
+	ElMessageBox.confirm("鏄惁纭瀵煎嚭鍏ㄩ儴涓存湡鍞悗鏁版嵁锛�", "瀵煎嚭", {
+		confirmButtonText: "纭",
+		cancelButtonText: "鍙栨秷",
+		type: "warning",
+	}).then(() => {
+		proxy.download("/afterSalesNearExpiryService/export", {}, "涓存湡鍞悗绠$悊.xlsx");
+	}).catch(() => {
+		proxy.$modal.msg("宸插彇娑�");
+	});
+};
+
+// 瀵煎叆
+const uploadRef = ref();
+const upload = reactive({
+	open: false,
+	title: "",
+	isUploading: false,
+	headers: { Authorization: "Bearer " + getToken() },
+	url: import.meta.env.VITE_APP_BASE_API + "/afterSalesNearExpiryService/import",
+});
+const handleImport = () => {
+	upload.title = "涓存湡鍞悗瀵煎叆";
+	upload.open = true;
+};
+const importTemplate = () => {
+	proxy.download("/afterSalesNearExpiryService/importTemplate", {}, "涓存湡鍞悗绠$悊瀵煎叆妯℃澘.xlsx");
+};
+const submitFileForm = () => {
+	upload.isUploading = true;
+	uploadRef.value.submit();
+};
+const handleFileUploadProgress = () => {
+	upload.isUploading = true;
+};
+const handleFileSuccess = (response) => {
+	upload.isUploading = false;
+	upload.open = false;
+	uploadRef.value.clearFiles();
+	if (response.code === 200) {
+		const failCount = response.failCount || 0;
+		if (failCount > 0) {
+			const errors = Array.isArray(response.errors) ? response.errors : [];
+			proxy.$modal.alert(`${response.msg}\n\n${errors.join("\n")}`, "瀵煎叆缁撴灉", {
+				confirmButtonText: "鐭ラ亾浜�",
+			}).then(() => {
+				getList();
+			});
+		} else {
+			proxy.$modal.msgSuccess(response.msg || "瀵煎叆鎴愬姛");
+			getList();
+		}
+	} else {
+		proxy.$modal.msgError(response.msg || "瀵煎叆澶辫触");
+	}
+};
+const handleFileError = () => {
+	upload.isUploading = false;
+	proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+};
+
 onMounted(() => {
 	getList();
 });

--
Gitblit v1.9.3