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 @@