From 354237d27855137db87ce00b0a1a07c1f133243e Mon Sep 17 00:00:00 2001 From: bestlee Date: Thu, 24 Sep 2026 16:52:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4=E6=8A=95=E5=85=A5=E5=92=8C?= =?UTF-8?q?=E6=95=88=E6=9E=9C-=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/api/pendingChange.ts | 9 +++++++++ src/views/my/effect/index.vue | 26 +++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/service/api/pendingChange.ts b/src/service/api/pendingChange.ts index e1dd84c..2903dc2 100644 --- a/src/service/api/pendingChange.ts +++ b/src/service/api/pendingChange.ts @@ -17,3 +17,12 @@ export function effectListApi(params:{page_num:number,page_size:number}) { params, }); } + +// 变更投入和效果导出 +export function exportEffectApi() { + return request({ + url: `/api/reports/invest-effect/export`, + method: 'get', + responseType: 'blob', // 重点,responseType设置为 blob + }); +} diff --git a/src/views/my/effect/index.vue b/src/views/my/effect/index.vue index 32f63ef..88b9afb 100644 --- a/src/views/my/effect/index.vue +++ b/src/views/my/effect/index.vue @@ -5,7 +5,7 @@ import { useThemeStore } from '@/store/modules/theme'; import { useRouterPush } from '@/hooks/common/router'; import { tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common'; import { systemConfigApi } from '@/service/api/system'; -import { effectListApi } from '@/service/api/pendingChange'; +import { effectListApi, exportEffectApi } from '@/service/api/pendingChange'; const themeStore = useThemeStore(); const { routerPushByKey } = useRouterPush(); @@ -30,8 +30,28 @@ const typeList = ref([]); const levelList = ref([]); // 导出文件 -const exportFile = () => { - window.$message?.info('还差接口') +const exportFile = async () => { + const {data,error} = await exportEffectApi(); + if(!error){ + console.log(data); + // 确保 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); + } } // 查看 const openRow = (r: any) => {