变更投入和效果-导出功能
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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<any[]>([]);
|
||||
const levelList = ref<any[]>([]);
|
||||
|
||||
// 导出文件
|
||||
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) => {
|
||||
|
||||
Reference in New Issue
Block a user