feat(statistics): 新增下载全部月份收入统计报表功能
- 在 API 模块中添加 `downloadAllMonthIncomeStatistics` 方法,用于请求全部月份收入统计报表数据 - 新增路由 `/statistics/download-reports` 并配置对应页面组件 - 创建下载页面视图,包含触发下载的按钮及加载状态处理 - 使用 `downloadFileFromBlobPart` 工具函数处理文件下载并命名为“财务报表.xlsx”
This commit is contained in:
@@ -139,4 +139,14 @@ export const statisticsApi = {
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 下载全部月份的收入统计报表
|
||||
* @returns 全部月份的收入统计报表数据
|
||||
*/
|
||||
downloadAllMonthIncomeStatistics: () => {
|
||||
return defaultRequestClient.download<Blob>('common/statistics/getMonthStatistics', {
|
||||
data: {},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -65,6 +65,15 @@ const routes: RouteRecordRaw[] = [
|
||||
path: '/statistics/finance-month-report',
|
||||
component: () => import('#/views/statistics/summary-month/report.vue'),
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
title: '下载全部报表',
|
||||
keepAlive: true,
|
||||
},
|
||||
name: 'DownloadReports',
|
||||
path: '/statistics/download-reports',
|
||||
component: () => import('#/views/statistics/download/index.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
41
apps/finance/src/views/statistics/download/index.vue
Normal file
41
apps/finance/src/views/statistics/download/index.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { statisticsApi } from '#/api/statistics';
|
||||
|
||||
// 下载全部报表
|
||||
const downloadAllReportsLoading = ref(false);
|
||||
async function downloadAllReports() {
|
||||
downloadAllReportsLoading.value = true;
|
||||
try {
|
||||
// 下载全部报表
|
||||
const Blob = await statisticsApi.downloadAllMonthIncomeStatistics();
|
||||
|
||||
downloadFileFromBlobPart({
|
||||
source: Blob,
|
||||
fileName: '财务报表.xlsx',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('下载全部报表失败:', error);
|
||||
} finally {
|
||||
downloadAllReportsLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<div class="flex h-full rounded-md bg-white p-4">
|
||||
<Button type="primary" :loading="downloadAllReportsLoading" @click="downloadAllReports">
|
||||
下载报表
|
||||
</Button>
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
Reference in New Issue
Block a user