From 77375416dc7257c4d286aa891a4fa1ea43e9a373 Mon Sep 17 00:00:00 2001
From: buaixuexideshitongxue <2936013465@qq.com>
Date: Thu, 8 Jan 2026 17:51:42 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B6=89=E8=AE=BF=E6=B6=89=E8=AF=89--=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E5=AF=BC=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/data/complaintCollection.ts | 42 ++++++++++++++++++++++++++
src/views/data/ComplaintCollection.vue | 10 +++++-
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/src/api/data/complaintCollection.ts b/src/api/data/complaintCollection.ts
index 9bbb34f..3b42779 100644
--- a/src/api/data/complaintCollection.ts
+++ b/src/api/data/complaintCollection.ts
@@ -1,4 +1,6 @@
import request from "@/api/request";
+import feedback from "../../utils/feedback";
+import {getToken} from "../../utils/token";
export function getComplaintCollectionPage(body) {
return request.post({
@@ -64,3 +66,43 @@ export function handlerData(body) {
body
});
}
+
+
+/**
+ * 导出
+ */
+export async function exportData(body) {
+ const response = await fetch('/api/v2/data/complaintCollection/exportData', {
+ method: 'POST',
+ headers: {
+ 'Authorization': getToken(),
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(body)
+ })
+ if (!response.ok) {
+ feedback.msgError('导出失败')
+ return
+ }
+ // 👉 关键:直接拿 blob
+ const blob = await response.blob()
+ let filename = '涉访涉诉数据.xlsx'
+ const disposition = response.headers.get('content-disposition')
+ if (disposition) {
+ const match = disposition.match(/filename\*=UTF-8''(.+)/)
+ if (match) {
+ filename = decodeURIComponent(match[1])
+ }
+ }
+ // 👉 触发下载
+ const url = window.URL.createObjectURL(blob)
+ const a = document.createElement('a')
+ a.href = url
+ a.download = filename
+
+ document.body.appendChild(a)
+ a.click()
+
+ document.body.removeChild(a)
+ window.URL.revokeObjectURL(url)
+}
\ No newline at end of file
diff --git a/src/views/data/ComplaintCollection.vue b/src/views/data/ComplaintCollection.vue
index 85c1def..e23ebe7 100644
--- a/src/views/data/ComplaintCollection.vue
+++ b/src/views/data/ComplaintCollection.vue
@@ -212,6 +212,7 @@