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 d2261fe71..dd3a70b88 100644 --- a/apps/web-antd/src/views/mall/statistics/trade/index.vue +++ b/apps/web-antd/src/views/mall/statistics/trade/index.vue @@ -4,14 +4,13 @@ import type { MallTradeStatisticsApi } from '#/api/mall/statistics/trade'; import { onMounted, ref } from 'vue'; -import { DocAlert, Page } from '@vben/common-ui'; +import { DocAlert, Page, StatisticCard } from '@vben/common-ui'; import { fenToYuan } from '@vben/utils'; import { Col, Row } from 'ant-design-vue'; import * as TradeStatisticsApi from '#/api/mall/statistics/trade'; -import TradeStatisticCard from './modules/trade-statistic-card.vue'; import TradeTrendCard from './modules/trade-trend-card.vue'; /** 交易统计 */ @@ -22,17 +21,19 @@ const summary = ref>(); // 交易统计数据 /** 计算环比百分比 */ -const calculateRelativeRate = (value?: number, reference?: number): string => { +function calculateRelativeRate(value?: number, reference?: number): string { const refValue = Number(reference || 0); const curValue = Number(value || 0); - if (!refValue || refValue === 0) return '0.00'; + if (!refValue || refValue === 0) { + return '0.00'; + } return (((curValue - refValue) / refValue) * 100).toFixed(2); -}; +} /** 查询交易统计 */ -const getTradeStatisticsSummary = async () => { +async function getTradeStatisticsSummary() { summary.value = await TradeStatisticsApi.getTradeStatisticsSummary(); -}; +} /** 初始化 */ onMounted(async () => { @@ -51,11 +52,11 @@ onMounted(async () => { /> +
- - { /> - { /> - { /> - -import { computed } from 'vue'; - -import { VbenCountToAnimator } from '@vben/common-ui'; -import { IconifyIcon } from '@vben/icons'; - -import { Card, Tooltip } from 'ant-design-vue'; - -/** 交易统计值组件 */ -defineOptions({ name: 'TradeStatisticCard' }); - -const props = withDefaults(defineProps(), { - tooltip: '', - title: '', - prefix: '', - value: 0, - decimals: 0, - percent: 0, -}); - -interface Props { - tooltip?: string; - title?: string; - prefix?: string; - value?: number | string; - decimals?: number; - percent?: number | string; -} - -/** 计算环比百分比 */ -const percentValue = computed(() => { - return Number(props.percent); -}); - -/** 格式化数值 */ -const formattedValue = computed(() => { - return Number(props.value); -}); - - - diff --git a/apps/web-antd/src/views/mall/statistics/trade/modules/trade-trend-card.vue b/apps/web-antd/src/views/mall/statistics/trade/modules/trade-trend-card.vue index 113ceabfc..572a46176 100644 --- a/apps/web-antd/src/views/mall/statistics/trade/modules/trade-trend-card.vue +++ b/apps/web-antd/src/views/mall/statistics/trade/modules/trade-trend-card.vue @@ -103,6 +103,7 @@ const getTradeStatisticsList = async (times?: [Dayjs, Dayjs]) => { await renderEcharts(getTradeTrendChartOptions(processedList)); }; +// TODO @AI:导出 /** 导出按钮操作 */ const handleExport = async () => { try { @@ -222,7 +223,6 @@ onMounted(async () => { " /> - { " /> - { " /> - +import type { StatisticCardProps } from './types'; + +import { + Card, + CardContent, + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, + VbenCountToAnimator, + VbenIcon, +} from '@vben-core/shadcn-ui'; + +/** 统计卡片 */ +defineOptions({ name: 'StatisticCard' }); + +withDefaults(defineProps(), { + percentLabel: '环比', +}); + + + + diff --git a/packages/effects/common-ui/src/components/statistic-card/types.ts b/packages/effects/common-ui/src/components/statistic-card/types.ts new file mode 100644 index 000000000..2fe168151 --- /dev/null +++ b/packages/effects/common-ui/src/components/statistic-card/types.ts @@ -0,0 +1,17 @@ +export interface StatisticCardProps { + /** 标题 */ + title: string; + /** 提示信息 */ + tooltip?: string; + /** 前缀 */ + prefix?: string; + /** 数值 */ + value?: number; + /** 小数位数 */ + decimals?: number; + /** 环比百分比 */ + percent?: number | string; + /** 环比标签文本 */ + percentLabel?: string; +} +