变更投入和效果-导出功能

This commit is contained in:
2026-09-24 16:52:42 +08:00
parent 55c4d80211
commit 354237d278
2 changed files with 32 additions and 3 deletions
+9
View File
@@ -17,3 +17,12 @@ export function effectListApi(params:{page_num:number,page_size:number}) {
params, params,
}); });
} }
// 变更投入和效果导出
export function exportEffectApi() {
return request({
url: `/api/reports/invest-effect/export`,
method: 'get',
responseType: 'blob', // 重点,responseType设置为 blob
});
}
+23 -3
View File
@@ -5,7 +5,7 @@ import { useThemeStore } from '@/store/modules/theme';
import { useRouterPush } from '@/hooks/common/router'; import { useRouterPush } from '@/hooks/common/router';
import { tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common'; import { tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common';
import { systemConfigApi } from '@/service/api/system'; import { systemConfigApi } from '@/service/api/system';
import { effectListApi } from '@/service/api/pendingChange'; import { effectListApi, exportEffectApi } from '@/service/api/pendingChange';
const themeStore = useThemeStore(); const themeStore = useThemeStore();
const { routerPushByKey } = useRouterPush(); const { routerPushByKey } = useRouterPush();
@@ -30,8 +30,28 @@ const typeList = ref<any[]>([]);
const levelList = ref<any[]>([]); const levelList = ref<any[]>([]);
// 导出文件 // 导出文件
const exportFile = () => { const exportFile = async () => {
window.$message?.info('还差接口') 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) => { const openRow = (r: any) => {