feat:【代码优化】减少部分模块的 import * 的 API

This commit is contained in:
YunaiV
2025-10-27 09:34:45 +08:00
parent d2db16c8c6
commit 86c68b5466
35 changed files with 185 additions and 164 deletions

View File

@@ -21,8 +21,13 @@ import {
import { Button, Card, Col, Row, Spin } from 'ant-design-vue';
import dayjs from 'dayjs';
import * as ProductStatisticsApi from '#/api/mall/statistics/product';
import {
exportProductStatisticsExcel,
getProductStatisticsAnalyse,
getProductStatisticsList,
} from '#/api/mall/statistics/product';
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
import { $t } from '#/locales';
import { getProductSummaryChartOptions } from './summary-chart-options';
@@ -51,7 +56,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => {
/** 处理日期范围变化 */
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
if (times?.length !== 2) {
getProductTrendData();
loadProductTrendData();
return;
}
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
@@ -65,29 +70,29 @@ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
];
// 查询数据
getProductTrendData();
loadProductTrendData();
};
/** 处理商品状况查询 */
const getProductTrendData = async () => {
const loadProductTrendData = async () => {
trendLoading.value = true;
try {
await Promise.all([getProductTrendSummary(), getProductStatisticsList()]);
await Promise.all([loadProductTrendSummary(), loadProductStatisticsList()]);
} finally {
trendLoading.value = false;
}
};
/** 查询商品状况数据统计 */
async function getProductTrendSummary() {
trendSummary.value = await ProductStatisticsApi.getProductStatisticsAnalyse({
async function loadProductTrendSummary() {
trendSummary.value = await getProductStatisticsAnalyse({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
});
}
/** 查询商品状况数据列表 */
async function getProductStatisticsList() {
const list = await ProductStatisticsApi.getProductStatisticsList({
async function loadProductStatisticsList() {
const list = await getProductStatisticsList({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
});
@@ -104,7 +109,7 @@ async function handleExport() {
});
// 发起导出
exportLoading.value = true;
const data = await ProductStatisticsApi.exportProductStatisticsExcel({
const data = await exportProductStatisticsExcel({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
});
// 处理下载
@@ -125,7 +130,7 @@ async function handleExport() {
<template #icon>
<IconifyIcon icon="lucide:download" />
</template>
导出
{{ $t('page.action.export') }}
</Button>
</ShortcutDateRangePicker>
</div>