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

@@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue'; import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import * as MemberStatisticsApi from '#/api/mall/statistics/member'; import { getMemberRegisterCountList } from '#/api/mall/statistics/member';
import { import {
getMemberStatisticsChartOptions, getMemberStatisticsChartOptions,
@@ -71,13 +71,13 @@ async function handleTimeRangeTypeChange() {
} }
} }
// 发送时间范围选中事件 // 发送时间范围选中事件
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; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberRegisterCountList( const list = await getMemberRegisterCountList(
beginTime.toDate(), beginTime.toDate(),
endTime.toDate(), endTime.toDate(),
); );

View File

@@ -6,9 +6,9 @@ import { CountTo } from '@vben/common-ui';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getTabsCount } from '#/api/mall/product/spu';
import * as PayStatisticsApi from '#/api/mall/statistics/pay'; import { getWalletRechargePrice } from '#/api/mall/statistics/pay';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade'; import { getOrderCount } from '#/api/mall/statistics/trade';
/** 运营数据卡片 */ /** 运营数据卡片 */
defineOptions({ name: 'OperationDataCard' }); defineOptions({ name: 'OperationDataCard' });
@@ -51,8 +51,8 @@ const data = reactive({
}); });
/** 查询订单数据 */ /** 查询订单数据 */
async function getOrderData() { async function loadOrderData() {
const orderCount = await TradeStatisticsApi.getOrderCount(); const orderCount = await getOrderCount();
if (orderCount.undelivered) { if (orderCount.undelivered) {
data.orderUndelivered.value = orderCount.undelivered; data.orderUndelivered.value = orderCount.undelivered;
} }
@@ -68,16 +68,16 @@ async function getOrderData() {
} }
/** 查询商品数据 */ /** 查询商品数据 */
async function getProductData() { async function loadProductData() {
const productCount = await ProductSpuApi.getTabsCount(); const productCount = await getTabsCount();
data.productForSale.value = productCount['0'] || 0; data.productForSale.value = productCount['0'] || 0;
data.productInWarehouse.value = productCount['1'] || 0; data.productInWarehouse.value = productCount['1'] || 0;
data.productAlertStock.value = productCount['3'] || 0; data.productAlertStock.value = productCount['3'] || 0;
} }
/** 查询钱包充值数据 */ /** 查询钱包充值数据 */
async function getWalletRechargeData() { async function loadWalletRechargeData() {
const paySummary = await PayStatisticsApi.getWalletRechargePrice(); const paySummary = await getWalletRechargePrice();
data.rechargePrice.value = paySummary.rechargePrice; data.rechargePrice.value = paySummary.rechargePrice;
} }
@@ -88,16 +88,16 @@ function handleClick(routerName: string) {
/** 激活时 */ /** 激活时 */
onActivated(() => { onActivated(() => {
getOrderData(); loadOrderData();
getProductData(); loadProductData();
getWalletRechargeData(); loadWalletRechargeData();
}); });
/** 初始化 */ /** 初始化 */
onMounted(() => { onMounted(() => {
getOrderData(); loadOrderData();
getProductData(); loadProductData();
getWalletRechargeData(); loadWalletRechargeData();
}); });
</script> </script>

View File

@@ -11,7 +11,7 @@ import { fenToYuan } from '@vben/utils';
import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue'; import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade'; import { getOrderCountTrendComparison } from '#/api/mall/statistics/trade';
import { import {
getTradeTrendChartOptions, 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; loading.value = true;
try { try {
// 1. 查询数据 // 1. 查询数据
const list = await TradeStatisticsApi.getOrderCountTrendComparison( const list = await getOrderCountTrendComparison(
timeRangeType.value, timeRangeType.value,
beginTime.toDate(), beginTime.toDate(),
endTime.toDate(), endTime.toDate(),

View File

@@ -42,7 +42,6 @@ const selectCategoryId = computed({
/** 初始化 */ /** 初始化 */
const categoryList = ref<any[]>([]); // 分类树 const categoryList = ref<any[]>([]); // 分类树
onMounted(async () => { onMounted(async () => {
// 获得分类树
const data = await getCategoryList({ const data = await getCategoryList({
parentId: props.parentId, parentId: props.parentId,
}); });

View File

@@ -5,7 +5,7 @@ import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTe
import { onMounted, ref, watch } from 'vue'; import { onMounted, ref, watch } from 'vue';
import * as CouponTemplateApi from '#/api/mall/promotion/coupon/couponTemplate';
import { import {
CouponDiscount, CouponDiscount,
@@ -23,7 +23,7 @@ watch(
() => props.property.couponIds, () => props.property.couponIds,
async () => { async () => {
if (props.property.couponIds?.length > 0) { if (props.property.couponIds?.length > 0) {
couponList.value = await CouponTemplateApi.getCouponTemplateList( couponList.value = await getCouponTemplateList(
props.property.couponIds, props.property.couponIds,
); );
} }

View File

@@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils';
import { Image } from 'ant-design-vue'; import { Image } from 'ant-design-vue';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getSpuDetailList } from '#/api/mall/product/spu';
/** 商品卡片 */ /** 商品卡片 */
defineOptions({ name: 'ProductCard' }); defineOptions({ name: 'ProductCard' });
@@ -20,7 +20,7 @@ const spuList = ref<MallSpuApi.Spu[]>([]);
watch( watch(
() => props.property.spuIds, () => props.property.spuIds,
async () => { async () => {
spuList.value = await ProductSpuApi.getSpuDetailList(props.property.spuIds); spuList.value = await getSpuDetailList(props.property.spuIds);
}, },
{ {
immediate: true, immediate: true,

View File

@@ -7,7 +7,7 @@ import { onMounted, ref, watch } from 'vue';
import { fenToYuan } from '@vben/utils'; import { fenToYuan } from '@vben/utils';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getSpuDetailList } from '#/api/mall/product/spu';
/** 商品栏 */ /** 商品栏 */
defineOptions({ name: 'ProductList' }); defineOptions({ name: 'ProductList' });
@@ -18,7 +18,7 @@ const spuList = ref<MallSpuApi.Spu[]>([]);
watch( watch(
() => props.property.spuIds, () => props.property.spuIds,
async () => { async () => {
spuList.value = await ProductSpuApi.getSpuDetailList(props.property.spuIds); spuList.value = await getSpuDetailList(props.property.spuIds);
}, },
{ {
immediate: true, immediate: true,

View File

@@ -5,7 +5,7 @@ import type { MallArticleApi } from '#/api/mall/promotion/article';
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
import * as ArticleApi from '#/api/mall/promotion/article/index';
/** 营销文章 */ /** 营销文章 */
defineOptions({ name: 'PromotionArticle' }); defineOptions({ name: 'PromotionArticle' });
@@ -18,7 +18,7 @@ watch(
() => props.property.id, () => props.property.id,
async () => { async () => {
if (props.property.id) { if (props.property.id) {
article.value = await ArticleApi.getArticle(props.property.id); article.value = await getArticle(props.property.id);
} }
}, },
{ {

View File

@@ -9,7 +9,7 @@ import { useVModel } from '@vueuse/core';
import { Form, FormItem, Select } from 'ant-design-vue'; import { Form, FormItem, Select } from 'ant-design-vue';
import * as ArticleApi from '#/api/mall/promotion/article/index';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
@@ -27,7 +27,7 @@ const loading = ref(false);
// 查询文章列表 // 查询文章列表
const queryArticleList = async (title?: string) => { const queryArticleList = async (title?: string) => {
loading.value = true; loading.value = true;
const { list } = await ArticleApi.getArticlePage({ const { list } = await getArticlePage({
title, title,
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,

View File

@@ -10,8 +10,8 @@ import { fenToYuan } from '@vben/utils';
import { Image } from 'ant-design-vue'; import { Image } from 'ant-design-vue';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getSpuDetailList } from '#/api/mall/product/spu';
import * as CombinationActivityApi from '#/api/mall/promotion/combination/combinationActivity'; import { getCombinationActivityListByIds, getCombinationActivityPage } from '#/api/mall/promotion/combination/combinationActivity';
/** 拼团卡片 */ /** 拼团卡片 */
defineOptions({ name: 'PromotionCombination' }); defineOptions({ name: 'PromotionCombination' });
@@ -34,7 +34,7 @@ watch(
if (Array.isArray(activityIds) && activityIds.length > 0) { if (Array.isArray(activityIds) && activityIds.length > 0) {
// 获取拼团活动详情列表 // 获取拼团活动详情列表
combinationActivityList.value = combinationActivityList.value =
await CombinationActivityApi.getCombinationActivityListByIds( await getCombinationActivityListByIds(
activityIds, activityIds,
); );
@@ -44,7 +44,7 @@ watch(
.map((activity) => activity.spuId) .map((activity) => activity.spuId)
.filter((spuId): spuId is number => typeof spuId === 'number'); .filter((spuId): spuId is number => typeof spuId === 'number');
if (spuIdList.value.length > 0) { if (spuIdList.value.length > 0) {
spuList.value = await ProductSpuApi.getSpuDetailList(spuIdList.value); spuList.value = await getSpuDetailList(spuIdList.value);
} }
// 更新 SPU 的最低价格 // 更新 SPU 的最低价格

View File

@@ -24,7 +24,7 @@ import {
Tooltip, Tooltip,
} from 'ant-design-vue'; } from 'ant-design-vue';
import * as CombinationActivityApi from '#/api/mall/promotion/combination/combinationActivity'; import { getCombinationActivityListByIds, getCombinationActivityPage } from '#/api/mall/promotion/combination/combinationActivity';
import UploadImg from '#/components/upload/image-upload.vue'; import UploadImg from '#/components/upload/image-upload.vue';
import CombinationShowcase from '#/views/mall/promotion/combination/components/combination-showcase.vue'; import CombinationShowcase from '#/views/mall/promotion/combination/components/combination-showcase.vue';
import { ColorInput } from '#/views/mall/promotion/components'; import { ColorInput } from '#/views/mall/promotion/components';
@@ -38,7 +38,7 @@ const formData = useVModel(props, 'modelValue', emit);
// 活动列表 // 活动列表
const activityList = ref<MallCombinationActivityApi.CombinationActivity[]>([]); const activityList = ref<MallCombinationActivityApi.CombinationActivity[]>([]);
onMounted(async () => { onMounted(async () => {
const { list } = await CombinationActivityApi.getCombinationActivityPage({ const { list } = await getCombinationActivityPage({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
status: CommonStatusEnum.ENABLE, status: CommonStatusEnum.ENABLE,

View File

@@ -9,8 +9,8 @@ import { fenToYuan } from '@vben/utils';
import { Image } from 'ant-design-vue'; import { Image } from 'ant-design-vue';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getSpuDetailList } from '#/api/mall/product/spu';
import * as PointActivityApi from '#/api/mall/promotion/point';
/** 积分商城卡片 */ /** 积分商城卡片 */
defineOptions({ name: 'PromotionPoint' }); defineOptions({ name: 'PromotionPoint' });
@@ -31,7 +31,7 @@ watch(
if (Array.isArray(activityIds) && activityIds.length > 0) { if (Array.isArray(activityIds) && activityIds.length > 0) {
// 获取积分商城活动详情列表 // 获取积分商城活动详情列表
pointActivityList.value = pointActivityList.value =
await PointActivityApi.getPointActivityListByIds(activityIds); await getPointActivityListByIds(activityIds);
// 获取积分商城活动的 SPU 详情列表 // 获取积分商城活动的 SPU 详情列表
spuList.value = []; spuList.value = [];
@@ -39,7 +39,7 @@ watch(
(activity) => activity.spuId, (activity) => activity.spuId,
); );
if (spuIdList.value.length > 0) { if (spuIdList.value.length > 0) {
spuList.value = (await ProductSpuApi.getSpuDetailList( spuList.value = (await getSpuDetailList(
spuIdList.value, spuIdList.value,
)) as MallPointActivityApi.SpuExtensionWithPoint[]; )) as MallPointActivityApi.SpuExtensionWithPoint[];
} }

View File

@@ -10,8 +10,8 @@ import { fenToYuan } from '@vben/utils';
import { Image } from 'ant-design-vue'; import { Image } from 'ant-design-vue';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getSpuDetailList } from '#/api/mall/product/spu';
import * as SeckillActivityApi from '#/api/mall/promotion/seckill/seckillActivity'; import { getSeckillActivityListByIds } from '#/api/mall/promotion/seckill/seckillActivity';
/** 秒杀卡片 */ /** 秒杀卡片 */
defineOptions({ name: 'PromotionSeckill' }); defineOptions({ name: 'PromotionSeckill' });
@@ -32,7 +32,7 @@ watch(
if (Array.isArray(activityIds) && activityIds.length > 0) { if (Array.isArray(activityIds) && activityIds.length > 0) {
// 获取秒杀活动详情列表 // 获取秒杀活动详情列表
seckillActivityList.value = seckillActivityList.value =
await SeckillActivityApi.getSeckillActivityListByIds(activityIds); await getSeckillActivityListByIds(activityIds);
// 获取秒杀活动的 SPU 详情列表 // 获取秒杀活动的 SPU 详情列表
spuList.value = []; spuList.value = [];
@@ -40,7 +40,7 @@ watch(
.map((activity) => activity.spuId) .map((activity) => activity.spuId)
.filter((spuId): spuId is number => typeof spuId === 'number'); .filter((spuId): spuId is number => typeof spuId === 'number');
if (spuIdList.value.length > 0) { if (spuIdList.value.length > 0) {
spuList.value = await ProductSpuApi.getSpuDetailList(spuIdList.value); spuList.value = await getSpuDetailList(spuIdList.value);
} }
// 更新 SPU 的最低价格 // 更新 SPU 的最低价格

View File

@@ -55,7 +55,7 @@ async function initGiveCouponList() {
// return; // return;
// } // }
// const tempLateIds = Object.keys(rewardRule.value.giveCouponTemplateCounts); // const tempLateIds = Object.keys(rewardRule.value.giveCouponTemplateCounts);
// const data = await CouponTemplateApi.getCouponTemplateList(tempLateIds); // const data = await getCouponTemplateList(tempLateIds);
// if (!data) { // if (!data) {
// return; // return;
// } // }

View File

@@ -8,7 +8,7 @@ import { fenToYuan } from '@vben/utils';
import { Col, Row } from 'ant-design-vue'; import { Col, Row } from 'ant-design-vue';
import * as MemberStatisticsApi from '#/api/mall/statistics/member'; import { getMemberSummary } from '#/api/mall/statistics/member';
import MemberAreaCard from './modules/area-card.vue'; import MemberAreaCard from './modules/area-card.vue';
import MemberFunnelCard from './modules/funnel-card.vue'; import MemberFunnelCard from './modules/funnel-card.vue';
@@ -22,15 +22,15 @@ const loading = ref(true); // 加载中
const summary = ref<MallMemberStatisticsApi.Summary>(); // 会员统计数据 const summary = ref<MallMemberStatisticsApi.Summary>(); // 会员统计数据
/** 查询会员统计 */ /** 查询会员统计 */
async function getMemberSummary() { async function loadMemberSummary() {
summary.value = await MemberStatisticsApi.getMemberSummary(); summary.value = await getMemberSummary();
} }
/** 初始化 */ /** 初始化 */
onMounted(async () => { onMounted(async () => {
loading.value = true; loading.value = true;
try { try {
await getMemberSummary(); await loadMemberSummary();
} finally { } finally {
loading.value = false; loading.value = false;
} }

View File

@@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { Card, Spin } from 'ant-design-vue'; import { Card, Spin } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; 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'; import { getAreaChartOptions, getAreaTableColumns } from './area-chart-options';
@@ -44,10 +44,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
}); });
/** 按照省份,查询会员统计列表 */ /** 按照省份,查询会员统计列表 */
async function getMemberAreaStatisticsList() { async function loadMemberAreaStatisticsList() {
loading.value = true; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberAreaStatisticsList(); const list = await getMemberAreaStatisticsList();
areaStatisticsList.value = list.map( areaStatisticsList.value = list.map(
(item: MallMemberStatisticsApi.AreaStatistics) => ({ (item: MallMemberStatisticsApi.AreaStatistics) => ({
...item, ...item,
@@ -80,7 +80,7 @@ function areaReplace(areaName: string): string {
/** 初始化 */ /** 初始化 */
onMounted(() => { onMounted(() => {
getMemberAreaStatisticsList(); loadMemberAreaStatisticsList();
}); });
</script> </script>

View File

@@ -7,7 +7,7 @@ import { fenToYuan } from '@vben/utils';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import * as MemberStatisticsApi from '#/api/mall/statistics/member'; import { getMemberAnalyse } from '#/api/mall/statistics/member';
import { ShortcutDateRangePicker } from '#/components/shortcut-date-range-picker'; import { ShortcutDateRangePicker } from '#/components/shortcut-date-range-picker';
/** 会员概览卡片 */ /** 会员概览卡片 */
@@ -23,7 +23,7 @@ async function loadData(times: [Dayjs, Dayjs]) {
} }
loading.value = true; loading.value = true;
try { try {
analyseData.value = await MemberStatisticsApi.getMemberAnalyse({ analyseData.value = await getMemberAnalyse({
times, times,
}); });
} finally { } finally {

View File

@@ -11,7 +11,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { Card, Spin } from 'ant-design-vue'; import { Card, Spin } from 'ant-design-vue';
import * as MemberStatisticsApi from '#/api/mall/statistics/member'; import { getMemberSexStatisticsList } from '#/api/mall/statistics/member';
import { getSexChartOptions } from './sex-chart-options'; import { getSexChartOptions } from './sex-chart-options';
@@ -23,10 +23,10 @@ const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef); const { renderEcharts } = useEcharts(chartRef);
/** 按照性别,查询会员统计列表 */ /** 按照性别,查询会员统计列表 */
async function getMemberSexStatisticsList() { async function loadMemberSexStatisticsList() {
loading.value = true; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberSexStatisticsList(); const list = await getMemberSexStatisticsList();
const dictDataList = getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number'); const dictDataList = getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number');
dictDataList.push({ label: '未知', value: null } as any); dictDataList.push({ label: '未知', value: null } as any);
const chartData = dictDataList.map((dictData: any) => { const chartData = dictDataList.map((dictData: any) => {
@@ -49,7 +49,7 @@ async function getMemberSexStatisticsList() {
/** 初始化 */ /** 初始化 */
onMounted(() => { onMounted(() => {
getMemberSexStatisticsList(); loadMemberSexStatisticsList();
}); });
</script> </script>

View File

@@ -8,7 +8,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { Card, Spin } from 'ant-design-vue'; import { Card, Spin } from 'ant-design-vue';
import * as MemberStatisticsApi from '#/api/mall/statistics/member'; import { getMemberTerminalStatisticsList } from '#/api/mall/statistics/member';
import { getTerminalChartOptions } from './terminal-chart-options'; import { getTerminalChartOptions } from './terminal-chart-options';
@@ -20,10 +20,10 @@ const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef); const { renderEcharts } = useEcharts(chartRef);
/** 按照终端,查询会员统计列表 */ /** 按照终端,查询会员统计列表 */
const getMemberTerminalStatisticsList = async () => { const loadMemberTerminalStatisticsList = async () => {
loading.value = true; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberTerminalStatisticsList(); const list = await getMemberTerminalStatisticsList();
const dictDataList = getDictOptions('terminal', 'number'); const dictDataList = getDictOptions('terminal', 'number');
const chartData = dictDataList.map((dictData: any) => { const chartData = dictDataList.map((dictData: any) => {
const userCount = list.find( const userCount = list.find(
@@ -43,7 +43,7 @@ const getMemberTerminalStatisticsList = async () => {
/** 初始化 */ /** 初始化 */
onMounted(() => { onMounted(() => {
getMemberTerminalStatisticsList(); loadMemberTerminalStatisticsList();
}); });
</script> </script>

View File

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

View File

@@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils';
import { Col, Row } from 'ant-design-vue'; import { Col, Row } from 'ant-design-vue';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade'; import { getTradeStatisticsSummary } from '#/api/mall/statistics/trade';
import TradeTrendCard from './modules/trend-card.vue'; import TradeTrendCard from './modules/trend-card.vue';
@@ -31,14 +31,14 @@ function calculateRelativeRate(value?: number, reference?: number): string {
} }
/** 查询交易统计 */ /** 查询交易统计 */
async function getTradeStatisticsSummary() { async function loadTradeStatisticsSummary() {
summary.value = await TradeStatisticsApi.getTradeStatisticsSummary(); summary.value = await getTradeStatisticsSummary();
} }
/** 初始化 */ /** 初始化 */
onMounted(async () => { onMounted(async () => {
loading.value = true; loading.value = true;
await getTradeStatisticsSummary(); await loadTradeStatisticsSummary();
loading.value = false; loading.value = false;
}); });
</script> </script>

View File

@@ -21,8 +21,13 @@ import {
import { Button, Card, Col, Row, Spin } from 'ant-design-vue'; import { Button, Card, Col, Row, Spin } from 'ant-design-vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
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 ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
import { $t } from '#/locales';
import { getTradeTrendChartOptions } from './trend-chart-options'; import { getTradeTrendChartOptions } from './trend-chart-options';
@@ -51,7 +56,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => {
/** 处理日期范围变化 */ /** 处理日期范围变化 */
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => { const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
if (times?.length !== 2) { if (times?.length !== 2) {
getTradeTrendData(); loadTradeTrendData();
return; return;
} }
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天 // 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
@@ -65,29 +70,32 @@ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
]; ];
// 查询数据 // 查询数据
getTradeTrendData(); loadTradeTrendData();
}; };
/** 处理交易状况查询 */ /** 处理交易状况查询 */
async function getTradeTrendData() { async function loadTradeTrendData() {
trendLoading.value = true; trendLoading.value = true;
try { try {
await Promise.all([getTradeStatisticsAnalyse(), getTradeStatisticsList()]); await Promise.all([
loadTradeStatisticsAnalyse(),
loadTradeStatisticsList(),
]);
} finally { } finally {
trendLoading.value = false; trendLoading.value = false;
} }
} }
/** 查询交易状况数据统计 */ /** 查询交易状况数据统计 */
async function getTradeStatisticsAnalyse() { async function loadTradeStatisticsAnalyse() {
trendSummary.value = await TradeStatisticsApi.getTradeStatisticsAnalyse({ trendSummary.value = await getTradeStatisticsAnalyse({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
} }
/** 查询交易状况数据列表 */ /** 查询交易状况数据列表 */
async function getTradeStatisticsList() { async function loadTradeStatisticsList() {
const list = await TradeStatisticsApi.getTradeStatisticsList({ const list = await getTradeStatisticsList({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
@@ -104,7 +112,7 @@ async function handleExport() {
}); });
// 发起导出 // 发起导出
exportLoading.value = true; exportLoading.value = true;
const data = await TradeStatisticsApi.exportTradeStatisticsExcel({ const data = await exportTradeStatisticsExcel({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
// 处理下载 // 处理下载

View File

@@ -7,10 +7,10 @@ import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
import dayjs from 'dayjs'; 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 { import {
getMemberStatisticsChartOptions, getMemberStatisticsChartOptions,
@@ -41,7 +41,7 @@ const timeRangeConfig = {
const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天 const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天
/** 时间范围类型单选按钮选中 */ /** 时间范围类型单选按钮选中 */
const handleTimeRangeTypeChange = async () => { async function handleTimeRangeTypeChange() {
// 设置时间范围 // 设置时间范围
let beginTime: Dayjs; let beginTime: Dayjs;
let endTime: 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; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberRegisterCountList( const list = await getMemberRegisterCountList(
beginTime.toDate(), beginTime.toDate(),
endTime.toDate(), endTime.toDate(),
); );

View File

@@ -6,9 +6,9 @@ import { CountTo } from '@vben/common-ui';
import { ElCard } from 'element-plus'; import { ElCard } from 'element-plus';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getTabsCount } from '#/api/mall/product/spu';
import * as PayStatisticsApi from '#/api/mall/statistics/pay'; import { getWalletRechargePrice } from '#/api/mall/statistics/pay';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade'; import { getOrderCount } from '#/api/mall/statistics/trade';
/** 运营数据卡片 */ /** 运营数据卡片 */
defineOptions({ name: 'OperationDataCard' }); defineOptions({ name: 'OperationDataCard' });
@@ -51,8 +51,8 @@ const data = reactive({
}); });
/** 查询订单数据 */ /** 查询订单数据 */
async function getOrderData() { async function loadOrderData() {
const orderCount = await TradeStatisticsApi.getOrderCount(); const orderCount = await getOrderCount();
if (orderCount.undelivered) { if (orderCount.undelivered) {
data.orderUndelivered.value = orderCount.undelivered; data.orderUndelivered.value = orderCount.undelivered;
} }
@@ -68,16 +68,16 @@ async function getOrderData() {
} }
/** 查询商品数据 */ /** 查询商品数据 */
async function getProductData() { async function loadProductData() {
const productCount = await ProductSpuApi.getTabsCount(); const productCount = await getTabsCount();
data.productForSale.value = productCount['0'] || 0; data.productForSale.value = productCount['0'] || 0;
data.productInWarehouse.value = productCount['1'] || 0; data.productInWarehouse.value = productCount['1'] || 0;
data.productAlertStock.value = productCount['3'] || 0; data.productAlertStock.value = productCount['3'] || 0;
} }
/** 查询钱包充值数据 */ /** 查询钱包充值数据 */
async function getWalletRechargeData() { async function loadWalletRechargeData() {
const paySummary = await PayStatisticsApi.getWalletRechargePrice(); const paySummary = await getWalletRechargePrice();
data.rechargePrice.value = paySummary.rechargePrice; data.rechargePrice.value = paySummary.rechargePrice;
} }
@@ -88,9 +88,9 @@ function handleClick(routerName: string) {
/** 激活时 */ /** 激活时 */
onActivated(() => { onActivated(() => {
getOrderData(); loadOrderData();
getProductData(); loadProductData();
getWalletRechargeData(); loadWalletRechargeData();
}); });
/** 初始化 */ /** 初始化 */

View File

@@ -11,7 +11,7 @@ import { fenToYuan } from '@vben/utils';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus'; import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade'; import { getOrderCountTrendComparison } from '#/api/mall/statistics/trade';
import { import {
getTradeTrendChartOptions, 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; loading.value = true;
try { try {
// 1. 查询数据 // 1. 查询数据
const list = await TradeStatisticsApi.getOrderCountTrendComparison( const list = await getOrderCountTrendComparison(
timeRangeType.value, timeRangeType.value,
beginTime.toDate(), beginTime.toDate(),
endTime.toDate(), endTime.toDate(),

View File

@@ -3,7 +3,7 @@ import { computed, onMounted, ref } from 'vue';
import { handleTree } from '@vben/utils'; import { handleTree } from '@vben/utils';
import * as ProductCategoryApi from '#/api/mall/product/category'; import { getCategoryList } from '#/api/mall/product/category';
/** 商品分类选择组件 */ /** 商品分类选择组件 */
defineOptions({ name: 'ProductCategorySelect' }); defineOptions({ name: 'ProductCategorySelect' });
@@ -42,8 +42,7 @@ const selectCategoryId = computed({
/** 初始化 */ /** 初始化 */
const categoryList = ref<any[]>([]); // 分类树 const categoryList = ref<any[]>([]); // 分类树
onMounted(async () => { onMounted(async () => {
// 获得分类树 const data = await getCategoryList({
const data = await ProductCategoryApi.getCategoryList({
parentId: props.parentId, parentId: props.parentId,
}); });
categoryList.value = handleTree(data, 'id', 'parentId'); categoryList.value = handleTree(data, 'id', 'parentId');

View File

@@ -8,7 +8,7 @@ import { fenToYuan } from '@vben/utils';
import { ElCol, ElRow } from 'element-plus'; 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 MemberAreaCard from './modules/area-card.vue';
import MemberFunnelCard from './modules/funnel-card.vue'; import MemberFunnelCard from './modules/funnel-card.vue';
@@ -22,15 +22,15 @@ const loading = ref(true); // 加载中
const summary = ref<MallMemberStatisticsApi.Summary>(); // 会员统计数据 const summary = ref<MallMemberStatisticsApi.Summary>(); // 会员统计数据
/** 查询会员统计 */ /** 查询会员统计 */
async function getMemberSummary() { async function loadMemberSummary() {
summary.value = await MemberStatisticsApi.getMemberSummary(); summary.value = await getMemberSummary();
} }
/** 初始化 */ /** 初始化 */
onMounted(async () => { onMounted(async () => {
loading.value = true; loading.value = true;
try { try {
await getMemberSummary(); await loadMemberSummary();
} finally { } finally {
loading.value = false; loading.value = false;
} }

View File

@@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { ElCard } from 'element-plus'; import { ElCard } from 'element-plus';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; 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'; import { getAreaChartOptions, getAreaTableColumns } from './area-chart-options';
@@ -44,10 +44,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
}); });
/** 按照省份,查询会员统计列表 */ /** 按照省份,查询会员统计列表 */
async function getMemberAreaStatisticsList() { async function loadMemberAreaStatisticsList() {
loading.value = true; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberAreaStatisticsList(); const list = await getMemberAreaStatisticsList();
areaStatisticsList.value = list.map( areaStatisticsList.value = list.map(
(item: MallMemberStatisticsApi.AreaStatistics) => ({ (item: MallMemberStatisticsApi.AreaStatistics) => ({
...item, ...item,
@@ -80,7 +80,7 @@ function areaReplace(areaName: string): string {
/** 初始化 */ /** 初始化 */
onMounted(() => { onMounted(() => {
getMemberAreaStatisticsList(); loadMemberAreaStatisticsList();
}); });
</script> </script>

View File

@@ -7,7 +7,7 @@ import { fenToYuan } from '@vben/utils';
import { ElCard } from 'element-plus'; 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'; import { ShortcutDateRangePicker } from '#/components/shortcut-date-range-picker';
/** 会员概览卡片 */ /** 会员概览卡片 */
@@ -23,7 +23,7 @@ async function loadData(times: [Dayjs, Dayjs]) {
} }
loading.value = true; loading.value = true;
try { try {
analyseData.value = await MemberStatisticsApi.getMemberAnalyse({ analyseData.value = await getMemberAnalyse({
times, times,
}); });
} finally { } finally {

View File

@@ -11,7 +11,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { ElCard } from 'element-plus'; 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'; import { getSexChartOptions } from './sex-chart-options';
@@ -23,10 +23,10 @@ const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef); const { renderEcharts } = useEcharts(chartRef);
/** 按照性别,查询会员统计列表 */ /** 按照性别,查询会员统计列表 */
async function getMemberSexStatisticsList() { async function loadMemberSexStatisticsList() {
loading.value = true; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberSexStatisticsList(); const list = await getMemberSexStatisticsList();
const dictDataList = getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number'); const dictDataList = getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number');
dictDataList.push({ label: '未知', value: null } as any); dictDataList.push({ label: '未知', value: null } as any);
const chartData = dictDataList.map((dictData: any) => { const chartData = dictDataList.map((dictData: any) => {
@@ -49,7 +49,7 @@ async function getMemberSexStatisticsList() {
/** 初始化 */ /** 初始化 */
onMounted(() => { onMounted(() => {
getMemberSexStatisticsList(); loadMemberSexStatisticsList();
}); });
</script> </script>

View File

@@ -8,7 +8,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { ElCard } from 'element-plus'; 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'; import { getTerminalChartOptions } from './terminal-chart-options';
@@ -20,10 +20,10 @@ const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef); const { renderEcharts } = useEcharts(chartRef);
/** 按照终端,查询会员统计列表 */ /** 按照终端,查询会员统计列表 */
const getMemberTerminalStatisticsList = async () => { const loadMemberTerminalStatisticsList = async () => {
loading.value = true; loading.value = true;
try { try {
const list = await MemberStatisticsApi.getMemberTerminalStatisticsList(); const list = await getMemberTerminalStatisticsList();
const dictDataList = getDictOptions('terminal', 'number'); const dictDataList = getDictOptions('terminal', 'number');
const chartData = dictDataList.map((dictData: any) => { const chartData = dictDataList.map((dictData: any) => {
const userCount = list.find( const userCount = list.find(
@@ -43,7 +43,7 @@ const getMemberTerminalStatisticsList = async () => {
/** 初始化 */ /** 初始化 */
onMounted(() => { onMounted(() => {
getMemberTerminalStatisticsList(); loadMemberTerminalStatisticsList();
}); });
</script> </script>

View File

@@ -11,7 +11,7 @@ import { formatDateTime } from '@vben/utils';
import { ElCard } from 'element-plus'; import { ElCard } from 'element-plus';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; 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'; import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
/** 商品排行 */ /** 商品排行 */
@@ -104,7 +104,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
proxyConfig: { proxyConfig: {
ajax: { ajax: {
query: async ({ page, sorts }) => { query: async ({ page, sorts }) => {
return await ProductStatisticsApi.getProductStatisticsRankPage({ return await getProductStatisticsRankPage({
pageNo: page.currentPage, pageNo: page.currentPage,
pageSize: page.pageSize, pageSize: page.pageSize,
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,

View File

@@ -21,8 +21,13 @@ import {
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { ElButton, ElCard, ElCol, ElRow } from 'element-plus'; 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 ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
import { $t } from '#/locales';
import { getProductSummaryChartOptions } from './summary-chart-options'; import { getProductSummaryChartOptions } from './summary-chart-options';
@@ -51,7 +56,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => {
/** 处理日期范围变化 */ /** 处理日期范围变化 */
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => { const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
if (times?.length !== 2) { if (times?.length !== 2) {
getProductTrendData(); loadProductTrendData();
return; return;
} }
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天 // 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
@@ -65,29 +70,29 @@ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
]; ];
// 查询数据 // 查询数据
getProductTrendData(); loadProductTrendData();
}; };
/** 处理商品状况查询 */ /** 处理商品状况查询 */
const getProductTrendData = async () => { const loadProductTrendData = async () => {
trendLoading.value = true; trendLoading.value = true;
try { try {
await Promise.all([getProductTrendSummary(), getProductStatisticsList()]); await Promise.all([loadProductTrendSummary(), loadProductStatisticsList()]);
} finally { } finally {
trendLoading.value = false; trendLoading.value = false;
} }
}; };
/** 查询商品状况数据统计 */ /** 查询商品状况数据统计 */
async function getProductTrendSummary() { async function loadProductTrendSummary() {
trendSummary.value = await ProductStatisticsApi.getProductStatisticsAnalyse({ trendSummary.value = await getProductStatisticsAnalyse({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
} }
/** 查询商品状况数据列表 */ /** 查询商品状况数据列表 */
async function getProductStatisticsList() { async function loadProductStatisticsList() {
const list = await ProductStatisticsApi.getProductStatisticsList({ const list = await getProductStatisticsList({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
@@ -104,13 +109,11 @@ async function handleExport() {
}); });
// 发起导出 // 发起导出
exportLoading.value = true; exportLoading.value = true;
const data = await ProductStatisticsApi.exportProductStatisticsExcel({ const data = await exportProductStatisticsExcel({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
// 处理下载 // 处理下载
downloadFileFromBlobPart({ fileName: '商品状况.xlsx', source: data }); downloadFileFromBlobPart({ fileName: '商品状况.xlsx', source: data });
} catch {
// 用户取消导出
} finally { } finally {
exportLoading.value = false; exportLoading.value = false;
} }

View File

@@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils';
import { ElCol, ElRow } from 'element-plus'; 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'; import TradeTrendCard from './modules/trend-card.vue';
@@ -31,14 +31,14 @@ function calculateRelativeRate(value?: number, reference?: number): string {
} }
/** 查询交易统计 */ /** 查询交易统计 */
async function getTradeStatisticsSummary() { async function loadTradeStatisticsSummary() {
summary.value = await TradeStatisticsApi.getTradeStatisticsSummary(); summary.value = await getTradeStatisticsSummary();
} }
/** 初始化 */ /** 初始化 */
onMounted(async () => { onMounted(async () => {
loading.value = true; loading.value = true;
await getTradeStatisticsSummary(); await loadTradeStatisticsSummary();
loading.value = false; loading.value = false;
}); });
</script> </script>

View File

@@ -21,7 +21,11 @@ import {
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { ElButton, ElCard, ElCol, ElRow } from 'element-plus'; 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 ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
import { getTradeTrendChartOptions } from './trend-chart-options'; import { getTradeTrendChartOptions } from './trend-chart-options';
@@ -51,7 +55,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => {
/** 处理日期范围变化 */ /** 处理日期范围变化 */
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => { const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
if (times?.length !== 2) { if (times?.length !== 2) {
getTradeTrendData(); loadTradeTrendData();
return; return;
} }
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天 // 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
@@ -65,29 +69,32 @@ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
]; ];
// 查询数据 // 查询数据
getTradeTrendData(); loadTradeTrendData();
}; };
/** 处理交易状况查询 */ /** 处理交易状况查询 */
async function getTradeTrendData() { async function loadTradeTrendData() {
trendLoading.value = true; trendLoading.value = true;
try { try {
await Promise.all([getTradeStatisticsAnalyse(), getTradeStatisticsList()]); await Promise.all([
loadTradeStatisticsAnalyse(),
loadTradeStatisticsList(),
]);
} finally { } finally {
trendLoading.value = false; trendLoading.value = false;
} }
} }
/** 查询交易状况数据统计 */ /** 查询交易状况数据统计 */
async function getTradeStatisticsAnalyse() { async function loadTradeStatisticsAnalyse() {
trendSummary.value = await TradeStatisticsApi.getTradeStatisticsAnalyse({ trendSummary.value = await getTradeStatisticsAnalyse({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
} }
/** 查询交易状况数据列表 */ /** 查询交易状况数据列表 */
async function getTradeStatisticsList() { async function loadTradeStatisticsList() {
const list = await TradeStatisticsApi.getTradeStatisticsList({ const list = await getTradeStatisticsList({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
@@ -104,7 +111,7 @@ async function handleExport() {
}); });
// 发起导出 // 发起导出
exportLoading.value = true; exportLoading.value = true;
const data = await TradeStatisticsApi.exportTradeStatisticsExcel({ const data = await exportTradeStatisticsExcel({
times: searchTimes.value.length > 0 ? searchTimes.value : undefined, times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
}); });
// 处理下载 // 处理下载