gaoluyang
2026-06-29 27cd042df9aca0383a49f3514bc21958dd890912
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<script lang="ts" setup>
import type { SummaryCardProps } from './types';
 
import {
  Card,
  CardContent,
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger,
  VbenCountToAnimator,
  VbenIcon,
} from '../../../../../../@core/ui-kit/shadcn-ui/src';
 
/** 统计卡片 */
defineOptions({ name: 'SummaryCard' });
 
defineProps<SummaryCardProps>();
</script>
 
<template>
  <Card class="h-full">
    <CardContent class="flex items-center gap-3 p-6">
      <div
        v-if="icon"
        class="flex h-12 w-12 flex-shrink-0 items-center justify-center rounded"
        :class="`${iconColor} ${iconBgColor}`"
      >
        <VbenIcon :icon="icon" class="size-6" />
      </div>
      <div class="flex flex-col gap-1">
        <div class="flex items-center gap-1">
          <span class="text-muted-foreground text-sm">{{ title }}</span>
          <TooltipProvider v-if="tooltip">
            <Tooltip>
              <TooltipTrigger>
                <VbenIcon
                  icon="lucide:circle-alert"
                  class="text-muted-foreground size-3"
                />
              </TooltipTrigger>
              <TooltipContent>
                <p>{{ tooltip }}</p>
              </TooltipContent>
            </Tooltip>
          </TooltipProvider>
        </div>
        <div class="flex flex-row items-baseline gap-2">
          <div class="text-2xl">
            <VbenCountToAnimator
              :prefix="prefix"
              :end-val="value ?? 0"
              :decimals="decimals ?? 0"
            />
          </div>
          <span
            v-if="percent !== undefined"
            :class="
              Number(percent) > 0
                ? 'text-destructive'
                : 'text-emerald-600 dark:text-emerald-400'
            "
            class="flex items-center"
          >
            <span class="text-sm">{{ Math.abs(Number(percent)) }}%</span>
            <VbenIcon
              :icon="
                Number(percent) > 0
                  ? 'lucide:chevron-up'
                  : 'lucide:chevron-down'
              "
              class="ml-0.5 size-3"
            />
          </span>
        </div>
      </div>
    </CardContent>
  </Card>
</template>