From 86c68b5466403f4a6550999d0a12ff64d30f8e57 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 27 Oct 2025 09:34:45 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=91=E5=87=8F=E5=B0=91=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84=20import=20*=20=E7=9A=84=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/modules/member-statistics-card.vue | 8 ++--- .../mall/home/modules/operation-data-card.vue | 30 +++++++++---------- .../mall/home/modules/trade-trend-card.vue | 8 ++--- .../components/product-category-select.vue | 1 - .../components/mobile/coupon-card/index.vue | 4 +-- .../components/mobile/product-card/index.vue | 4 +-- .../components/mobile/product-list/index.vue | 4 +-- .../mobile/promotion-article/index.vue | 4 +-- .../mobile/promotion-article/property.vue | 4 +-- .../mobile/promotion-combination/index.vue | 8 ++--- .../mobile/promotion-combination/property.vue | 4 +-- .../mobile/promotion-point/index.vue | 8 ++--- .../mobile/promotion-seckill/index.vue | 8 ++--- .../components/reward-rule-coupon-select.vue | 2 +- .../views/mall/statistics/member/index.vue | 8 ++--- .../statistics/member/modules/area-card.vue | 8 ++--- .../statistics/member/modules/funnel-card.vue | 4 +-- .../statistics/member/modules/sex-card.vue | 8 ++--- .../member/modules/terminal-card.vue | 8 ++--- .../product/modules/summary-card.vue | 27 ++++++++++------- .../src/views/mall/statistics/trade/index.vue | 8 ++--- .../statistics/trade/modules/trend-card.vue | 28 ++++++++++------- .../home/modules/member-statistics-card.vue | 14 ++++----- .../mall/home/modules/operation-data-card.vue | 24 +++++++-------- .../mall/home/modules/trade-trend-card.vue | 8 ++--- .../components/product-category-select.vue | 5 ++-- .../views/mall/statistics/member/index.vue | 8 ++--- .../statistics/member/modules/area-card.vue | 8 ++--- .../statistics/member/modules/funnel-card.vue | 4 +-- .../statistics/member/modules/sex-card.vue | 8 ++--- .../member/modules/terminal-card.vue | 8 ++--- .../statistics/product/modules/rank-card.vue | 4 +-- .../product/modules/summary-card.vue | 27 +++++++++-------- .../src/views/mall/statistics/trade/index.vue | 8 ++--- .../statistics/trade/modules/trend-card.vue | 27 ++++++++++------- 35 files changed, 185 insertions(+), 164 deletions(-) diff --git a/apps/web-antd/src/views/mall/home/modules/member-statistics-card.vue b/apps/web-antd/src/views/mall/home/modules/member-statistics-card.vue index 3b7e0db48..770249117 100644 --- a/apps/web-antd/src/views/mall/home/modules/member-statistics-card.vue +++ b/apps/web-antd/src/views/mall/home/modules/member-statistics-card.vue @@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue'; import dayjs from 'dayjs'; -import * as MemberStatisticsApi from '#/api/mall/statistics/member'; +import { getMemberRegisterCountList } from '#/api/mall/statistics/member'; import { 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; try { - const list = await MemberStatisticsApi.getMemberRegisterCountList( + const list = await getMemberRegisterCountList( beginTime.toDate(), endTime.toDate(), ); diff --git a/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue b/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue index 22d9c855e..a0f46c2aa 100644 --- a/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue +++ b/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue @@ -6,9 +6,9 @@ import { CountTo } from '@vben/common-ui'; import { Card } from 'ant-design-vue'; -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,16 +88,16 @@ function handleClick(routerName: string) { /** 激活时 */ onActivated(() => { - getOrderData(); - getProductData(); - getWalletRechargeData(); + loadOrderData(); + loadProductData(); + loadWalletRechargeData(); }); /** 初始化 */ onMounted(() => { - getOrderData(); - getProductData(); - getWalletRechargeData(); + loadOrderData(); + loadProductData(); + loadWalletRechargeData(); }); diff --git a/apps/web-antd/src/views/mall/home/modules/trade-trend-card.vue b/apps/web-antd/src/views/mall/home/modules/trade-trend-card.vue index 1d5a1cf6a..2c9d72583 100644 --- a/apps/web-antd/src/views/mall/home/modules/trade-trend-card.vue +++ b/apps/web-antd/src/views/mall/home/modules/trade-trend-card.vue @@ -11,7 +11,7 @@ import { fenToYuan } from '@vben/utils'; import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue'; import dayjs from 'dayjs'; -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(), diff --git a/apps/web-antd/src/views/mall/product/category/components/product-category-select.vue b/apps/web-antd/src/views/mall/product/category/components/product-category-select.vue index 64904f88c..dedb2d2fa 100644 --- a/apps/web-antd/src/views/mall/product/category/components/product-category-select.vue +++ b/apps/web-antd/src/views/mall/product/category/components/product-category-select.vue @@ -42,7 +42,6 @@ const selectCategoryId = computed({ /** 初始化 */ const categoryList = ref([]); // 分类树 onMounted(async () => { - // 获得分类树 const data = await getCategoryList({ parentId: props.parentId, }); diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue index 23216b9a8..e5abe0662 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/coupon-card/index.vue @@ -5,7 +5,7 @@ import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTe import { onMounted, ref, watch } from 'vue'; -import * as CouponTemplateApi from '#/api/mall/promotion/coupon/couponTemplate'; + import { CouponDiscount, @@ -23,7 +23,7 @@ watch( () => props.property.couponIds, async () => { if (props.property.couponIds?.length > 0) { - couponList.value = await CouponTemplateApi.getCouponTemplateList( + couponList.value = await getCouponTemplateList( props.property.couponIds, ); } diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-card/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-card/index.vue index 13f1c0fbc..16f91e1e1 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-card/index.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-card/index.vue @@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils'; import { Image } from 'ant-design-vue'; -import * as ProductSpuApi from '#/api/mall/product/spu'; +import { getSpuDetailList } from '#/api/mall/product/spu'; /** 商品卡片 */ defineOptions({ name: 'ProductCard' }); @@ -20,7 +20,7 @@ const spuList = ref([]); watch( () => props.property.spuIds, async () => { - spuList.value = await ProductSpuApi.getSpuDetailList(props.property.spuIds); + spuList.value = await getSpuDetailList(props.property.spuIds); }, { immediate: true, diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-list/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-list/index.vue index a1322b217..d334376ee 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-list/index.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/product-list/index.vue @@ -7,7 +7,7 @@ import { onMounted, ref, watch } from 'vue'; import { fenToYuan } from '@vben/utils'; -import * as ProductSpuApi from '#/api/mall/product/spu'; +import { getSpuDetailList } from '#/api/mall/product/spu'; /** 商品栏 */ defineOptions({ name: 'ProductList' }); @@ -18,7 +18,7 @@ const spuList = ref([]); watch( () => props.property.spuIds, async () => { - spuList.value = await ProductSpuApi.getSpuDetailList(props.property.spuIds); + spuList.value = await getSpuDetailList(props.property.spuIds); }, { immediate: true, diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/index.vue index 10e9f5aa3..ef8861f68 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/index.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/index.vue @@ -5,7 +5,7 @@ import type { MallArticleApi } from '#/api/mall/promotion/article'; import { ref, watch } from 'vue'; -import * as ArticleApi from '#/api/mall/promotion/article/index'; + /** 营销文章 */ defineOptions({ name: 'PromotionArticle' }); @@ -18,7 +18,7 @@ watch( () => props.property.id, async () => { if (props.property.id) { - article.value = await ArticleApi.getArticle(props.property.id); + article.value = await getArticle(props.property.id); } }, { diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/property.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/property.vue index fb6852fb2..32cc45a28 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/property.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-article/property.vue @@ -9,7 +9,7 @@ import { useVModel } from '@vueuse/core'; import { Form, FormItem, Select } from 'ant-design-vue'; -import * as ArticleApi from '#/api/mall/promotion/article/index'; + import ComponentContainerProperty from '../../component-container-property.vue'; @@ -27,7 +27,7 @@ const loading = ref(false); // 查询文章列表 const queryArticleList = async (title?: string) => { loading.value = true; - const { list } = await ArticleApi.getArticlePage({ + const { list } = await getArticlePage({ title, pageNo: 1, pageSize: 10, diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/index.vue index 08ff86d1e..f2ec9d50b 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/index.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/index.vue @@ -10,8 +10,8 @@ import { fenToYuan } from '@vben/utils'; import { Image } from 'ant-design-vue'; -import * as ProductSpuApi from '#/api/mall/product/spu'; -import * as CombinationActivityApi from '#/api/mall/promotion/combination/combinationActivity'; +import { getSpuDetailList } from '#/api/mall/product/spu'; +import { getCombinationActivityListByIds, getCombinationActivityPage } from '#/api/mall/promotion/combination/combinationActivity'; /** 拼团卡片 */ defineOptions({ name: 'PromotionCombination' }); @@ -34,7 +34,7 @@ watch( if (Array.isArray(activityIds) && activityIds.length > 0) { // 获取拼团活动详情列表 combinationActivityList.value = - await CombinationActivityApi.getCombinationActivityListByIds( + await getCombinationActivityListByIds( activityIds, ); @@ -44,7 +44,7 @@ watch( .map((activity) => activity.spuId) .filter((spuId): spuId is number => typeof spuId === 'number'); if (spuIdList.value.length > 0) { - spuList.value = await ProductSpuApi.getSpuDetailList(spuIdList.value); + spuList.value = await getSpuDetailList(spuIdList.value); } // 更新 SPU 的最低价格 diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/property.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/property.vue index 3732af95a..affbba5a3 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/property.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-combination/property.vue @@ -24,7 +24,7 @@ import { Tooltip, } 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 CombinationShowcase from '#/views/mall/promotion/combination/components/combination-showcase.vue'; import { ColorInput } from '#/views/mall/promotion/components'; @@ -38,7 +38,7 @@ const formData = useVModel(props, 'modelValue', emit); // 活动列表 const activityList = ref([]); onMounted(async () => { - const { list } = await CombinationActivityApi.getCombinationActivityPage({ + const { list } = await getCombinationActivityPage({ pageNo: 1, pageSize: 10, status: CommonStatusEnum.ENABLE, diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue index 174b20218..676120fdc 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-point/index.vue @@ -9,8 +9,8 @@ import { fenToYuan } from '@vben/utils'; import { Image } from 'ant-design-vue'; -import * as ProductSpuApi from '#/api/mall/product/spu'; -import * as PointActivityApi from '#/api/mall/promotion/point'; +import { getSpuDetailList } from '#/api/mall/product/spu'; + /** 积分商城卡片 */ defineOptions({ name: 'PromotionPoint' }); @@ -31,7 +31,7 @@ watch( if (Array.isArray(activityIds) && activityIds.length > 0) { // 获取积分商城活动详情列表 pointActivityList.value = - await PointActivityApi.getPointActivityListByIds(activityIds); + await getPointActivityListByIds(activityIds); // 获取积分商城活动的 SPU 详情列表 spuList.value = []; @@ -39,7 +39,7 @@ watch( (activity) => activity.spuId, ); if (spuIdList.value.length > 0) { - spuList.value = (await ProductSpuApi.getSpuDetailList( + spuList.value = (await getSpuDetailList( spuIdList.value, )) as MallPointActivityApi.SpuExtensionWithPoint[]; } diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-seckill/index.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-seckill/index.vue index 0c1226df7..236cd4563 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-seckill/index.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/promotion-seckill/index.vue @@ -10,8 +10,8 @@ import { fenToYuan } from '@vben/utils'; import { Image } from 'ant-design-vue'; -import * as ProductSpuApi from '#/api/mall/product/spu'; -import * as SeckillActivityApi from '#/api/mall/promotion/seckill/seckillActivity'; +import { getSpuDetailList } from '#/api/mall/product/spu'; +import { getSeckillActivityListByIds } from '#/api/mall/promotion/seckill/seckillActivity'; /** 秒杀卡片 */ defineOptions({ name: 'PromotionSeckill' }); @@ -32,7 +32,7 @@ watch( if (Array.isArray(activityIds) && activityIds.length > 0) { // 获取秒杀活动详情列表 seckillActivityList.value = - await SeckillActivityApi.getSeckillActivityListByIds(activityIds); + await getSeckillActivityListByIds(activityIds); // 获取秒杀活动的 SPU 详情列表 spuList.value = []; @@ -40,7 +40,7 @@ watch( .map((activity) => activity.spuId) .filter((spuId): spuId is number => typeof spuId === 'number'); if (spuIdList.value.length > 0) { - spuList.value = await ProductSpuApi.getSpuDetailList(spuIdList.value); + spuList.value = await getSpuDetailList(spuIdList.value); } // 更新 SPU 的最低价格 diff --git a/apps/web-antd/src/views/mall/promotion/rewardActivity/components/reward-rule-coupon-select.vue b/apps/web-antd/src/views/mall/promotion/rewardActivity/components/reward-rule-coupon-select.vue index 20be01d5b..e2844fc11 100644 --- a/apps/web-antd/src/views/mall/promotion/rewardActivity/components/reward-rule-coupon-select.vue +++ b/apps/web-antd/src/views/mall/promotion/rewardActivity/components/reward-rule-coupon-select.vue @@ -55,7 +55,7 @@ async function initGiveCouponList() { // return; // } // const tempLateIds = Object.keys(rewardRule.value.giveCouponTemplateCounts); - // const data = await CouponTemplateApi.getCouponTemplateList(tempLateIds); + // const data = await getCouponTemplateList(tempLateIds); // if (!data) { // return; // } diff --git a/apps/web-antd/src/views/mall/statistics/member/index.vue b/apps/web-antd/src/views/mall/statistics/member/index.vue index da8c8b243..8ccd67237 100644 --- a/apps/web-antd/src/views/mall/statistics/member/index.vue +++ b/apps/web-antd/src/views/mall/statistics/member/index.vue @@ -8,7 +8,7 @@ import { fenToYuan } from '@vben/utils'; 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 MemberFunnelCard from './modules/funnel-card.vue'; @@ -22,15 +22,15 @@ const loading = ref(true); // 加载中 const summary = ref(); // 会员统计数据 /** 查询会员统计 */ -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; } diff --git a/apps/web-antd/src/views/mall/statistics/member/modules/area-card.vue b/apps/web-antd/src/views/mall/statistics/member/modules/area-card.vue index 9f2440ff4..dc7c67e1a 100644 --- a/apps/web-antd/src/views/mall/statistics/member/modules/area-card.vue +++ b/apps/web-antd/src/views/mall/statistics/member/modules/area-card.vue @@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; import { Card, Spin } from 'ant-design-vue'; 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(); }); diff --git a/apps/web-antd/src/views/mall/statistics/member/modules/funnel-card.vue b/apps/web-antd/src/views/mall/statistics/member/modules/funnel-card.vue index 72437d9fe..fc1a7a4a0 100644 --- a/apps/web-antd/src/views/mall/statistics/member/modules/funnel-card.vue +++ b/apps/web-antd/src/views/mall/statistics/member/modules/funnel-card.vue @@ -7,7 +7,7 @@ import { fenToYuan } from '@vben/utils'; 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'; /** 会员概览卡片 */ @@ -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 { diff --git a/apps/web-antd/src/views/mall/statistics/member/modules/sex-card.vue b/apps/web-antd/src/views/mall/statistics/member/modules/sex-card.vue index 2938b8eb3..567ecc424 100644 --- a/apps/web-antd/src/views/mall/statistics/member/modules/sex-card.vue +++ b/apps/web-antd/src/views/mall/statistics/member/modules/sex-card.vue @@ -11,7 +11,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; 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'; @@ -23,10 +23,10 @@ const chartRef = ref(); 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(); }); diff --git a/apps/web-antd/src/views/mall/statistics/member/modules/terminal-card.vue b/apps/web-antd/src/views/mall/statistics/member/modules/terminal-card.vue index fc5075504..bb3103704 100644 --- a/apps/web-antd/src/views/mall/statistics/member/modules/terminal-card.vue +++ b/apps/web-antd/src/views/mall/statistics/member/modules/terminal-card.vue @@ -8,7 +8,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; 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'; @@ -20,10 +20,10 @@ const chartRef = ref(); 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(); }); diff --git a/apps/web-antd/src/views/mall/statistics/product/modules/summary-card.vue b/apps/web-antd/src/views/mall/statistics/product/modules/summary-card.vue index dfc076368..9f2fde400 100644 --- a/apps/web-antd/src/views/mall/statistics/product/modules/summary-card.vue +++ b/apps/web-antd/src/views/mall/statistics/product/modules/summary-card.vue @@ -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() { - 导出 + {{ $t('page.action.export') }} diff --git a/apps/web-antd/src/views/mall/statistics/trade/index.vue b/apps/web-antd/src/views/mall/statistics/trade/index.vue index 8cc2aa71c..6e87786f9 100644 --- a/apps/web-antd/src/views/mall/statistics/trade/index.vue +++ b/apps/web-antd/src/views/mall/statistics/trade/index.vue @@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils'; 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'; @@ -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; }); diff --git a/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue b/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue index 78117cde7..1dd4fc24b 100644 --- a/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue +++ b/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue @@ -21,8 +21,13 @@ import { import { Button, Card, Col, Row, Spin } from 'ant-design-vue'; 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 { $t } from '#/locales'; import { getTradeTrendChartOptions } from './trend-chart-options'; @@ -51,7 +56,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => { /** 处理日期范围变化 */ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => { if (times?.length !== 2) { - getTradeTrendData(); + loadTradeTrendData(); return; } // 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天 @@ -65,29 +70,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 +112,7 @@ async function handleExport() { }); // 发起导出 exportLoading.value = true; - const data = await TradeStatisticsApi.exportTradeStatisticsExcel({ + const data = await exportTradeStatisticsExcel({ times: searchTimes.value.length > 0 ? searchTimes.value : undefined, }); // 处理下载 diff --git a/apps/web-ele/src/views/mall/home/modules/member-statistics-card.vue b/apps/web-ele/src/views/mall/home/modules/member-statistics-card.vue index e9e83c86e..91661214d 100644 --- a/apps/web-ele/src/views/mall/home/modules/member-statistics-card.vue +++ b/apps/web-ele/src/views/mall/home/modules/member-statistics-card.vue @@ -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(), ); diff --git a/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue b/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue index f193e62f1..4f6354bfe 100644 --- a/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue +++ b/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue @@ -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(); }); /** 初始化 */ diff --git a/apps/web-ele/src/views/mall/home/modules/trade-trend-card.vue b/apps/web-ele/src/views/mall/home/modules/trade-trend-card.vue index 0f63f3a9c..70bca614e 100644 --- a/apps/web-ele/src/views/mall/home/modules/trade-trend-card.vue +++ b/apps/web-ele/src/views/mall/home/modules/trade-trend-card.vue @@ -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(), diff --git a/apps/web-ele/src/views/mall/product/category/components/product-category-select.vue b/apps/web-ele/src/views/mall/product/category/components/product-category-select.vue index 441542b5d..23169691e 100644 --- a/apps/web-ele/src/views/mall/product/category/components/product-category-select.vue +++ b/apps/web-ele/src/views/mall/product/category/components/product-category-select.vue @@ -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([]); // 分类树 onMounted(async () => { - // 获得分类树 - const data = await ProductCategoryApi.getCategoryList({ + const data = await getCategoryList({ parentId: props.parentId, }); categoryList.value = handleTree(data, 'id', 'parentId'); diff --git a/apps/web-ele/src/views/mall/statistics/member/index.vue b/apps/web-ele/src/views/mall/statistics/member/index.vue index 8b99dbde2..5a1a9221a 100644 --- a/apps/web-ele/src/views/mall/statistics/member/index.vue +++ b/apps/web-ele/src/views/mall/statistics/member/index.vue @@ -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(); // 会员统计数据 /** 查询会员统计 */ -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; } diff --git a/apps/web-ele/src/views/mall/statistics/member/modules/area-card.vue b/apps/web-ele/src/views/mall/statistics/member/modules/area-card.vue index 43d41aac7..9e2c820ed 100644 --- a/apps/web-ele/src/views/mall/statistics/member/modules/area-card.vue +++ b/apps/web-ele/src/views/mall/statistics/member/modules/area-card.vue @@ -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(); }); diff --git a/apps/web-ele/src/views/mall/statistics/member/modules/funnel-card.vue b/apps/web-ele/src/views/mall/statistics/member/modules/funnel-card.vue index e2d3252e2..845fd8502 100644 --- a/apps/web-ele/src/views/mall/statistics/member/modules/funnel-card.vue +++ b/apps/web-ele/src/views/mall/statistics/member/modules/funnel-card.vue @@ -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 { diff --git a/apps/web-ele/src/views/mall/statistics/member/modules/sex-card.vue b/apps/web-ele/src/views/mall/statistics/member/modules/sex-card.vue index 54a254dee..a41d8b469 100644 --- a/apps/web-ele/src/views/mall/statistics/member/modules/sex-card.vue +++ b/apps/web-ele/src/views/mall/statistics/member/modules/sex-card.vue @@ -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(); 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(); }); diff --git a/apps/web-ele/src/views/mall/statistics/member/modules/terminal-card.vue b/apps/web-ele/src/views/mall/statistics/member/modules/terminal-card.vue index 624dcf25c..50c088c19 100644 --- a/apps/web-ele/src/views/mall/statistics/member/modules/terminal-card.vue +++ b/apps/web-ele/src/views/mall/statistics/member/modules/terminal-card.vue @@ -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(); 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(); }); diff --git a/apps/web-ele/src/views/mall/statistics/product/modules/rank-card.vue b/apps/web-ele/src/views/mall/statistics/product/modules/rank-card.vue index 2c6fbca6a..0a7e34e74 100644 --- a/apps/web-ele/src/views/mall/statistics/product/modules/rank-card.vue +++ b/apps/web-ele/src/views/mall/statistics/product/modules/rank-card.vue @@ -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, diff --git a/apps/web-ele/src/views/mall/statistics/product/modules/summary-card.vue b/apps/web-ele/src/views/mall/statistics/product/modules/summary-card.vue index 38b174e81..156aace69 100644 --- a/apps/web-ele/src/views/mall/statistics/product/modules/summary-card.vue +++ b/apps/web-ele/src/views/mall/statistics/product/modules/summary-card.vue @@ -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; } diff --git a/apps/web-ele/src/views/mall/statistics/trade/index.vue b/apps/web-ele/src/views/mall/statistics/trade/index.vue index 153de4d0c..334c95b95 100644 --- a/apps/web-ele/src/views/mall/statistics/trade/index.vue +++ b/apps/web-ele/src/views/mall/statistics/trade/index.vue @@ -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; }); diff --git a/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue b/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue index 0e5df93a5..3173e0bdd 100644 --- a/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue +++ b/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue @@ -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, }); // 处理下载