mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 01:09:19 +08:00
feat: 公司概览 Dashboard 添加导出按钮
- company-overview/apis.ts 新增导出 API - Dashboard 页面导出按钮绑定事件,支持当前日期范围导出 - 复用已有 exportByPost 工具函数
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user