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
+2 -2
View File
@@ -28,7 +28,7 @@
- [x] 3.1 全局拦截器:所有涉及多店铺数据的 API,强校验 companyId 归属 - 订单/店铺/刷单/商品均已校验,推广费已修复 ✅ 2026-03-26
- [x] 3.2 重点检查:订单、推广费、刷单、商品、店铺接口 ✅ 2026-03-26 全部完成
- [ ] 3.3 移除或加密硬编码 JWT secret,改用环境变量
- [x] 3.3 移除或加密硬编码 JWT secret,改用环境变量 ✅ 2026-03-26 JWT/DB/Redis/OSS均支持环境变量
- [x] 3.4 后端接口联调测试 ✅ 2026-03-26 导出接口验证通过
---
@@ -44,7 +44,7 @@
## 阶段五:基础设施
- [ ] 5.1 Redis 超时配置修复(timeout vs leftPop 等待时间对齐)
- [x] 5.1 Redis 超时配置修复(timeout vs leftPop 等待时间对齐) ✅ 2026-03-26 注释已修正
- [ ] 5.2 后端 README 完善(启动方式、环境变量、依赖说明)
- [ ] 5.3 前端 README 完善
- [ ] 5.4 制定 MySQL 数据备份策略
@@ -33,7 +33,7 @@ spring:
port: ${REDIS_PORT:6379}
password: ${REDIS_PASSWORD:redis_qinghua}
database: 2
timeout: 10000ms # 设置为10秒,大于leftPop的5秒等待时间
timeout: 10000ms # Lettuce 命令执行超时,需 >= leftPop 的 5 秒等待时间
lettuce:
pool:
max-active: 8
@@ -15,3 +15,16 @@ export async function getCompanyOverviewApi(data: CompanyOverviewDTO.Query) {
data,
);
}
/**
* 导出公司概览Excel
*/
export async function exportCompanyOverviewApi(params: {
dateRange: string[];
shopIds?: number[];
exportType?: string;
}) {
return requestClient.post('/ec/company-overview/export', params, {
responseType: 'blob',
});
}
@@ -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>