feat:
This commit is contained in:
@@ -11,6 +11,7 @@ export * from './json-viewer';
|
||||
export * from './loading';
|
||||
export * from './page';
|
||||
export * from './resize';
|
||||
export * from './statistic-card';
|
||||
export * from './summary-card';
|
||||
export * from './tippy';
|
||||
export * from './tree';
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// add by 芋艿:统计卡片,目前 mall 模块在使用
|
||||
export { default as StatisticCard } from './statistic-card.vue';
|
||||
export * from './types';
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<script lang="ts" setup>
|
||||
import type { StatisticCardProps } from './types';
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
VbenCountToAnimator,
|
||||
VbenIcon,
|
||||
} from '@vben-core/shadcn-ui';
|
||||
|
||||
/** 统计卡片 */
|
||||
defineOptions({ name: 'StatisticCard' });
|
||||
|
||||
withDefaults(defineProps<StatisticCardProps>(), {
|
||||
percentLabel: '环比',
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card class="h-full">
|
||||
<CardContent class="flex flex-col gap-2 p-6">
|
||||
<div class="text-muted-foreground flex items-center justify-between">
|
||||
<span class="text-sm">{{ title }}</span>
|
||||
<TooltipProvider v-if="tooltip">
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<VbenIcon
|
||||
icon="lucide:circle-alert"
|
||||
class="text-muted-foreground size-4 cursor-help"
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>{{ tooltip }}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
</div>
|
||||
<div class="mb-4 text-3xl font-medium">
|
||||
<VbenCountToAnimator
|
||||
:prefix="prefix"
|
||||
:end-val="value ?? 0"
|
||||
:decimals="decimals ?? 0"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-row gap-1 text-sm">
|
||||
<span class="text-muted-foreground">{{ percentLabel }}</span>
|
||||
<span
|
||||
:class="
|
||||
Number(percent) > 0
|
||||
? 'text-destructive'
|
||||
: 'text-emerald-600 dark:text-emerald-400'
|
||||
"
|
||||
class="flex items-center gap-0.5"
|
||||
>
|
||||
{{ Math.abs(Number(percent ?? 0)).toFixed(2) }}%
|
||||
<VbenIcon
|
||||
:icon="
|
||||
Number(percent) > 0 ? 'lucide:trending-up' : 'lucide:trending-down'
|
||||
"
|
||||
class="size-3"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export interface StatisticCardProps {
|
||||
/** 标题 */
|
||||
title: string;
|
||||
/** 提示信息 */
|
||||
tooltip?: string;
|
||||
/** 前缀 */
|
||||
prefix?: string;
|
||||
/** 数值 */
|
||||
value?: number;
|
||||
/** 小数位数 */
|
||||
decimals?: number;
|
||||
/** 环比百分比 */
|
||||
percent?: number | string;
|
||||
/** 环比标签文本 */
|
||||
percentLabel?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user