feat:【代码优化】减少部分模块的 import * 的 API
This commit is contained in:
@@ -7,10 +7,10 @@ import { onMounted, ref } from 'vue';
|
||||
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
|
||||
import dayjs from 'dayjs';
|
||||
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
|
||||
|
||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
||||
import { getMemberRegisterCountList } from '#/api/mall/statistics/member';
|
||||
|
||||
import {
|
||||
getMemberStatisticsChartOptions,
|
||||
@@ -41,7 +41,7 @@ const timeRangeConfig = {
|
||||
const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天
|
||||
|
||||
/** 时间范围类型单选按钮选中 */
|
||||
const handleTimeRangeTypeChange = async () => {
|
||||
async function handleTimeRangeTypeChange() {
|
||||
// 设置时间范围
|
||||
let beginTime: Dayjs;
|
||||
let endTime: Dayjs;
|
||||
@@ -71,13 +71,13 @@ const handleTimeRangeTypeChange = async () => {
|
||||
}
|
||||
}
|
||||
// 发送时间范围选中事件
|
||||
await getMemberRegisterCountList(beginTime, endTime);
|
||||
};
|
||||
await loadMemberRegisterCountList(beginTime, endTime);
|
||||
}
|
||||
|
||||
async function getMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) {
|
||||
async function loadMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const list = await MemberStatisticsApi.getMemberRegisterCountList(
|
||||
const list = await getMemberRegisterCountList(
|
||||
beginTime.toDate(),
|
||||
endTime.toDate(),
|
||||
);
|
||||
|
||||
@@ -6,9 +6,9 @@ import { CountTo } from '@vben/common-ui';
|
||||
|
||||
import { ElCard } from 'element-plus';
|
||||
|
||||
import * as ProductSpuApi from '#/api/mall/product/spu';
|
||||
import * as PayStatisticsApi from '#/api/mall/statistics/pay';
|
||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
||||
import { getTabsCount } from '#/api/mall/product/spu';
|
||||
import { getWalletRechargePrice } from '#/api/mall/statistics/pay';
|
||||
import { getOrderCount } from '#/api/mall/statistics/trade';
|
||||
|
||||
/** 运营数据卡片 */
|
||||
defineOptions({ name: 'OperationDataCard' });
|
||||
@@ -51,8 +51,8 @@ const data = reactive({
|
||||
});
|
||||
|
||||
/** 查询订单数据 */
|
||||
async function getOrderData() {
|
||||
const orderCount = await TradeStatisticsApi.getOrderCount();
|
||||
async function loadOrderData() {
|
||||
const orderCount = await getOrderCount();
|
||||
if (orderCount.undelivered) {
|
||||
data.orderUndelivered.value = orderCount.undelivered;
|
||||
}
|
||||
@@ -68,16 +68,16 @@ async function getOrderData() {
|
||||
}
|
||||
|
||||
/** 查询商品数据 */
|
||||
async function getProductData() {
|
||||
const productCount = await ProductSpuApi.getTabsCount();
|
||||
async function loadProductData() {
|
||||
const productCount = await getTabsCount();
|
||||
data.productForSale.value = productCount['0'] || 0;
|
||||
data.productInWarehouse.value = productCount['1'] || 0;
|
||||
data.productAlertStock.value = productCount['3'] || 0;
|
||||
}
|
||||
|
||||
/** 查询钱包充值数据 */
|
||||
async function getWalletRechargeData() {
|
||||
const paySummary = await PayStatisticsApi.getWalletRechargePrice();
|
||||
async function loadWalletRechargeData() {
|
||||
const paySummary = await getWalletRechargePrice();
|
||||
data.rechargePrice.value = paySummary.rechargePrice;
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ function handleClick(routerName: string) {
|
||||
|
||||
/** 激活时 */
|
||||
onActivated(() => {
|
||||
getOrderData();
|
||||
getProductData();
|
||||
getWalletRechargeData();
|
||||
loadOrderData();
|
||||
loadProductData();
|
||||
loadWalletRechargeData();
|
||||
});
|
||||
|
||||
/** 初始化 */
|
||||
|
||||
@@ -11,7 +11,7 @@ import { fenToYuan } from '@vben/utils';
|
||||
import dayjs from 'dayjs';
|
||||
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
|
||||
|
||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
||||
import { getOrderCountTrendComparison } from '#/api/mall/statistics/trade';
|
||||
|
||||
import {
|
||||
getTradeTrendChartOptions,
|
||||
@@ -76,15 +76,15 @@ async function handleTimeRangeTypeChange() {
|
||||
}
|
||||
}
|
||||
// 发送时间范围选中事件
|
||||
await getOrderCountTrendComparison(beginTime, endTime);
|
||||
await loadOrderCountTrendComparison(beginTime, endTime);
|
||||
}
|
||||
|
||||
/** 查询订单数量趋势对照数据 */
|
||||
async function getOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {
|
||||
async function loadOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {
|
||||
loading.value = true;
|
||||
try {
|
||||
// 1. 查询数据
|
||||
const list = await TradeStatisticsApi.getOrderCountTrendComparison(
|
||||
const list = await getOrderCountTrendComparison(
|
||||
timeRangeType.value,
|
||||
beginTime.toDate(),
|
||||
endTime.toDate(),
|
||||
|
||||
@@ -3,7 +3,7 @@ import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { handleTree } from '@vben/utils';
|
||||
|
||||
import * as ProductCategoryApi from '#/api/mall/product/category';
|
||||
import { getCategoryList } from '#/api/mall/product/category';
|
||||
|
||||
/** 商品分类选择组件 */
|
||||
defineOptions({ name: 'ProductCategorySelect' });
|
||||
@@ -42,8 +42,7 @@ const selectCategoryId = computed({
|
||||
/** 初始化 */
|
||||
const categoryList = ref<any[]>([]); // 分类树
|
||||
onMounted(async () => {
|
||||
// 获得分类树
|
||||
const data = await ProductCategoryApi.getCategoryList({
|
||||
const data = await getCategoryList({
|
||||
parentId: props.parentId,
|
||||
});
|
||||
categoryList.value = handleTree(data, 'id', 'parentId');
|
||||
|
||||
@@ -8,7 +8,7 @@ import { fenToYuan } from '@vben/utils';
|
||||
|
||||
import { ElCol, ElRow } from 'element-plus';
|
||||
|
||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
||||
import { getMemberSummary } from '#/api/mall/statistics/member';
|
||||
|
||||
import MemberAreaCard from './modules/area-card.vue';
|
||||
import MemberFunnelCard from './modules/funnel-card.vue';
|
||||
@@ -22,15 +22,15 @@ const loading = ref(true); // 加载中
|
||||
const summary = ref<MallMemberStatisticsApi.Summary>(); // 会员统计数据
|
||||
|
||||
/** 查询会员统计 */
|
||||
async function getMemberSummary() {
|
||||
summary.value = await MemberStatisticsApi.getMemberSummary();
|
||||
async function loadMemberSummary() {
|
||||
summary.value = await getMemberSummary();
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
await getMemberSummary();
|
||||
await loadMemberSummary();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
import { ElCard } from 'element-plus';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
||||
import { getMemberAreaStatisticsList } from '#/api/mall/statistics/member';
|
||||
|
||||
import { getAreaChartOptions, getAreaTableColumns } from './area-chart-options';
|
||||
|
||||
@@ -44,10 +44,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
|
||||
/** 按照省份,查询会员统计列表 */
|
||||
async function getMemberAreaStatisticsList() {
|
||||
async function loadMemberAreaStatisticsList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const list = await MemberStatisticsApi.getMemberAreaStatisticsList();
|
||||
const list = await getMemberAreaStatisticsList();
|
||||
areaStatisticsList.value = list.map(
|
||||
(item: MallMemberStatisticsApi.AreaStatistics) => ({
|
||||
...item,
|
||||
@@ -80,7 +80,7 @@ function areaReplace(areaName: string): string {
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getMemberAreaStatisticsList();
|
||||
loadMemberAreaStatisticsList();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { fenToYuan } from '@vben/utils';
|
||||
|
||||
import { ElCard } from 'element-plus';
|
||||
|
||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
||||
import { getMemberAnalyse } from '#/api/mall/statistics/member';
|
||||
import { ShortcutDateRangePicker } from '#/components/shortcut-date-range-picker';
|
||||
|
||||
/** 会员概览卡片 */
|
||||
@@ -23,7 +23,7 @@ async function loadData(times: [Dayjs, Dayjs]) {
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
analyseData.value = await MemberStatisticsApi.getMemberAnalyse({
|
||||
analyseData.value = await getMemberAnalyse({
|
||||
times,
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { ElCard } from 'element-plus';
|
||||
|
||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
||||
import { getMemberSexStatisticsList } from '#/api/mall/statistics/member';
|
||||
|
||||
import { getSexChartOptions } from './sex-chart-options';
|
||||
|
||||
@@ -23,10 +23,10 @@ const chartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts } = useEcharts(chartRef);
|
||||
|
||||
/** 按照性别,查询会员统计列表 */
|
||||
async function getMemberSexStatisticsList() {
|
||||
async function loadMemberSexStatisticsList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const list = await MemberStatisticsApi.getMemberSexStatisticsList();
|
||||
const list = await getMemberSexStatisticsList();
|
||||
const dictDataList = getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number');
|
||||
dictDataList.push({ label: '未知', value: null } as any);
|
||||
const chartData = dictDataList.map((dictData: any) => {
|
||||
@@ -49,7 +49,7 @@ async function getMemberSexStatisticsList() {
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getMemberSexStatisticsList();
|
||||
loadMemberSexStatisticsList();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { ElCard } from 'element-plus';
|
||||
|
||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
||||
import { getMemberTerminalStatisticsList } from '#/api/mall/statistics/member';
|
||||
|
||||
import { getTerminalChartOptions } from './terminal-chart-options';
|
||||
|
||||
@@ -20,10 +20,10 @@ const chartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts } = useEcharts(chartRef);
|
||||
|
||||
/** 按照终端,查询会员统计列表 */
|
||||
const getMemberTerminalStatisticsList = async () => {
|
||||
const loadMemberTerminalStatisticsList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const list = await MemberStatisticsApi.getMemberTerminalStatisticsList();
|
||||
const list = await getMemberTerminalStatisticsList();
|
||||
const dictDataList = getDictOptions('terminal', 'number');
|
||||
const chartData = dictDataList.map((dictData: any) => {
|
||||
const userCount = list.find(
|
||||
@@ -43,7 +43,7 @@ const getMemberTerminalStatisticsList = async () => {
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getMemberTerminalStatisticsList();
|
||||
loadMemberTerminalStatisticsList();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { formatDateTime } from '@vben/utils';
|
||||
import { ElCard } from 'element-plus';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import * as ProductStatisticsApi from '#/api/mall/statistics/product';
|
||||
import { getProductStatisticsRankPage } from '#/api/mall/statistics/product';
|
||||
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
||||
|
||||
/** 商品排行 */
|
||||
@@ -104,7 +104,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page, sorts }) => {
|
||||
return await ProductStatisticsApi.getProductStatisticsRankPage({
|
||||
return await getProductStatisticsRankPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||
|
||||
@@ -21,8 +21,13 @@ import {
|
||||
import dayjs from 'dayjs';
|
||||
import { ElButton, ElCard, ElCol, ElRow } from 'element-plus';
|
||||
|
||||
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,13 +109,11 @@ async function handleExport() {
|
||||
});
|
||||
// 发起导出
|
||||
exportLoading.value = true;
|
||||
const data = await ProductStatisticsApi.exportProductStatisticsExcel({
|
||||
const data = await exportProductStatisticsExcel({
|
||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||
});
|
||||
// 处理下载
|
||||
downloadFileFromBlobPart({ fileName: '商品状况.xlsx', source: data });
|
||||
} catch {
|
||||
// 用户取消导出
|
||||
} finally {
|
||||
exportLoading.value = false;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils';
|
||||
|
||||
import { ElCol, ElRow } from 'element-plus';
|
||||
|
||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
||||
import { getTradeStatisticsSummary } from '#/api/mall/statistics/trade';
|
||||
|
||||
import TradeTrendCard from './modules/trend-card.vue';
|
||||
|
||||
@@ -31,14 +31,14 @@ function calculateRelativeRate(value?: number, reference?: number): string {
|
||||
}
|
||||
|
||||
/** 查询交易统计 */
|
||||
async function getTradeStatisticsSummary() {
|
||||
summary.value = await TradeStatisticsApi.getTradeStatisticsSummary();
|
||||
async function loadTradeStatisticsSummary() {
|
||||
summary.value = await getTradeStatisticsSummary();
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
loading.value = true;
|
||||
await getTradeStatisticsSummary();
|
||||
await loadTradeStatisticsSummary();
|
||||
loading.value = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -21,7 +21,11 @@ import {
|
||||
import dayjs from 'dayjs';
|
||||
import { ElButton, ElCard, ElCol, ElRow } from 'element-plus';
|
||||
|
||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
||||
import {
|
||||
exportTradeStatisticsExcel,
|
||||
getTradeStatisticsAnalyse,
|
||||
getTradeStatisticsList,
|
||||
} from '#/api/mall/statistics/trade';
|
||||
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
||||
|
||||
import { getTradeTrendChartOptions } from './trend-chart-options';
|
||||
@@ -51,7 +55,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => {
|
||||
/** 处理日期范围变化 */
|
||||
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
||||
if (times?.length !== 2) {
|
||||
getTradeTrendData();
|
||||
loadTradeTrendData();
|
||||
return;
|
||||
}
|
||||
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
|
||||
@@ -65,29 +69,32 @@ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
||||
];
|
||||
|
||||
// 查询数据
|
||||
getTradeTrendData();
|
||||
loadTradeTrendData();
|
||||
};
|
||||
|
||||
/** 处理交易状况查询 */
|
||||
async function getTradeTrendData() {
|
||||
async function loadTradeTrendData() {
|
||||
trendLoading.value = true;
|
||||
try {
|
||||
await Promise.all([getTradeStatisticsAnalyse(), getTradeStatisticsList()]);
|
||||
await Promise.all([
|
||||
loadTradeStatisticsAnalyse(),
|
||||
loadTradeStatisticsList(),
|
||||
]);
|
||||
} finally {
|
||||
trendLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询交易状况数据统计 */
|
||||
async function getTradeStatisticsAnalyse() {
|
||||
trendSummary.value = await TradeStatisticsApi.getTradeStatisticsAnalyse({
|
||||
async function loadTradeStatisticsAnalyse() {
|
||||
trendSummary.value = await getTradeStatisticsAnalyse({
|
||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询交易状况数据列表 */
|
||||
async function getTradeStatisticsList() {
|
||||
const list = await TradeStatisticsApi.getTradeStatisticsList({
|
||||
async function loadTradeStatisticsList() {
|
||||
const list = await getTradeStatisticsList({
|
||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||
});
|
||||
|
||||
@@ -104,7 +111,7 @@ async function handleExport() {
|
||||
});
|
||||
// 发起导出
|
||||
exportLoading.value = true;
|
||||
const data = await TradeStatisticsApi.exportTradeStatisticsExcel({
|
||||
const data = await exportTradeStatisticsExcel({
|
||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||
});
|
||||
// 处理下载
|
||||
|
||||
Reference in New Issue
Block a user