mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:09:19 +08:00
feat(frontend): 店铺概览页添加导出按钮
- 新增 exportByPost 通用导出工具(处理 blob 下载) - 店铺概览页导出按钮绑定事件,支持当前页面日期范围导出 - shop/apis.ts 新增导出 API 函数
This commit is contained in:
@@ -12,6 +12,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 { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'ShopOverview' });
|
||||
@@ -27,6 +28,7 @@ const shopId = computed(() => {
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const exportLoading = ref(false);
|
||||
const overviewData = ref<null | ShopVO.OverviewStatistics>(null);
|
||||
|
||||
// 日期范围
|
||||
@@ -222,6 +224,23 @@ const loadOverviewData = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 导出店铺概览
|
||||
const handleExportShopOverview = async () => {
|
||||
if (!shopId.value) return;
|
||||
try {
|
||||
exportLoading.value = true;
|
||||
const shopName = overviewData.value?.shopName || `店铺${shopId.value}`;
|
||||
const [startDate, endDate] = dateRange.value;
|
||||
const filename = `${shopName}_概览_${startDate.format('YYYYMMDD')}_${endDate.format('YYYYMMDD')}.xlsx`;
|
||||
await exportByPost('/ec/shop/export-overview', {
|
||||
shopId: shopId.value,
|
||||
dateRange: [startDate.format('YYYY-MM-DD'), endDate.format('YYYY-MM-DD')],
|
||||
}, filename);
|
||||
} finally {
|
||||
exportLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const refreshOverviewByCurrentParams = async (force = false) => {
|
||||
applyDateRangeFromRouteQuery();
|
||||
if (!shopId.value) return;
|
||||
@@ -716,8 +735,10 @@ onActivated(async () => {
|
||||
<Button
|
||||
type="primary"
|
||||
class="!h-auto !rounded-2xl !border-none !bg-slate-900 !px-8 !py-3 !text-sm !font-black !shadow-xl !shadow-slate-200 !transition-all hover:!scale-105 active:!scale-95"
|
||||
:loading="exportLoading"
|
||||
@click="handleExportShopOverview"
|
||||
>
|
||||
导出商品明细报表
|
||||
导出店铺概览
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user