feat: 公司概览 Dashboard 添加导出按钮

- company-overview/apis.ts 新增导出 API
- Dashboard 页面导出按钮绑定事件,支持当前日期范围导出
- 复用已有 exportByPost 工具函数
This commit is contained in:
小蟑螂
2026-03-26 12:30:45 +08:00
parent 1fce283d3b
commit eaa6de719e
4 changed files with 34 additions and 3 deletions
@@ -15,6 +15,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { Button, DatePicker, message, Spin } from 'ant-design-vue';
import dayjs from 'dayjs';
import { exportByPost } from '#/utils/export';
import { getCompanyOverviewApi } from '#/api/ecommerce/company-overview';
import { getShopPageApi } from '#/api/ecommerce/shop';
@@ -26,6 +27,7 @@ const route = useRoute();
// 响应式数据
const loading = ref(false);
const exportLoading = ref(false);
const overviewData = ref<CompanyOverviewVO.Info | null>(null);
const shopCount = ref(0);
@@ -440,6 +442,20 @@ onMounted(async () => {
onActivated(async () => {
await refreshOverviewByCurrentParams(true);
});
// 导出公司概览
const handleExportCompanyOverview = async () => {
try {
exportLoading.value = true;
const [startDate, endDate] = dateRange.value;
const filename = `公司概览_${startDate.format('YYYYMMDD')}_${endDate.format('YYYYMMDD')}.xlsx`;
await exportByPost('/ec/company-overview/export', {
dateRange: [startDate.format('YYYY-MM-DD'), endDate.format('YYYY-MM-DD')],
}, filename);
} finally {
exportLoading.value = false;
}
};
</script>
<template>
@@ -707,6 +723,8 @@ onActivated(async () => {
<Button
type="primary"
class="!h-auto !rounded-2xl !border-none !bg-slate-900 !px-8 !py-3 !text-sm !font-bold !shadow-xl !shadow-slate-200 !transition-all hover:!scale-105 active:!scale-95"
:loading="exportLoading"
@click="handleExportCompanyOverview"
>
导出财务分析报表
</Button>