From 3f6b16f8be87b1ca151e9e0facff3b8b3a2fa7ab Mon Sep 17 00:00:00 2001 From: bestlee Date: Wed, 30 Sep 2026 09:15:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4=E5=8F=B0=E8=B4=A6=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/api/changeLedger.ts | 10 +++++ src/views/changeLedger/modules/list.vue | 38 +++++++++++++++++-- .../changeStatistics/modules/pieChart.vue | 6 ++- .../changeStatistics/modules/pieChart2.vue | 5 ++- .../changeStatistics/modules/ringChart.vue | 10 ++++- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/service/api/changeLedger.ts b/src/service/api/changeLedger.ts index f2d7417..9b4783a 100644 --- a/src/service/api/changeLedger.ts +++ b/src/service/api/changeLedger.ts @@ -9,3 +9,13 @@ export function changeLedgerListApi(params:any) { }); } +// 导出 +export function exportChangeLedgerApi(params:any) { + return request({ + url: `/api/reports/changes/export`, + method: 'get', + params, + responseType: 'blob', // 重点,responseType设置为 blob + }); +} + diff --git a/src/views/changeLedger/modules/list.vue b/src/views/changeLedger/modules/list.vue index f175f04..81a9397 100644 --- a/src/views/changeLedger/modules/list.vue +++ b/src/views/changeLedger/modules/list.vue @@ -6,8 +6,8 @@ import { useRouterPush } from '@/hooks/common/router'; import { tagTextColor, tagBgColor, tagBorderColor, getTimeRangeStamp, formatTimestamp } from '@/utils/common'; import { systemConfigApi } from '@/service/api/system'; import { orgListApi } from '@/service/api/user'; -import { changeLedgerListApi } from '@/service/api/changeLedger'; import { urgeApi } from '@/service/api/change'; +import { changeLedgerListApi, exportChangeLedgerApi } from '@/service/api/changeLedger'; const { routerPushByKey } = useRouterPush(); const themeStore = useThemeStore(); @@ -88,8 +88,40 @@ const revokeSaving = ref(false); const list = ref([]); // 导出台账 -const exportChanges = () => { - window.$message?.info('还差接口'); +const exportChanges = async () => { + loading.value = true; + const {data,error} = await exportChangeLedgerApi({ + kw: formInfo.value.kw, + type: formInfo.value.type, + level: formInfo.value.level, + status: formInfo.value.status, + org_id: formInfo.value.org_id, + apply_time_start: formatTimestamp(formInfo.value.apply_time_start), + apply_time_end: formatTimestamp(formInfo.value.apply_time_end), + }); + if(!error){ + if (!data) { + return; + } + // 确保 res 为 Blob 类型(若 API 返回 ArrayBuffer 或原始数据,需适配) + let blob; + if (data instanceof Blob) { + blob = data; + } else { + // 假设返回的是二进制数据(如 ArrayBuffer),指定 MIME 类型 + blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); + } + const url = window.URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.download = '变更台账.xlsx'; // 推荐使用 download 属性 + document.body.appendChild(link); + link.click(); + // 清理:移除链接并释放 URL 对象 + document.body.removeChild(link); + window.URL.revokeObjectURL(url); + } + loading.value = false; } // 自定义渲染展开图标 diff --git a/src/views/changeStatistics/modules/pieChart.vue b/src/views/changeStatistics/modules/pieChart.vue index 55904d3..0764d05 100644 --- a/src/views/changeStatistics/modules/pieChart.vue +++ b/src/views/changeStatistics/modules/pieChart.vue @@ -1,5 +1,5 @@