wangrong
2026-08-28 17b92e9b60dda6dcc20c748046a5ff3c3958d52e
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
80
81
82
83
84
85
<template>
    <div class="kpi-card" :class="{ 'is-alert': alert, 'is-demo': demo }">
        <div class="kpi-card__label">
            <span>{{ label }}</span>
            <el-tag v-if="demo" class="kpi-card__badge" type="info" effect="plain" size="small">演示</el-tag>
        </div>
        <div class="kpi-card__value">
            <cl-number :value="numeric" :fixed="fixed" type="amount" :suffix="suffix" />
        </div>
        <div v-if="hint" class="kpi-card__hint">{{ hint }}</div>
    </div>
</template>
 
<script lang="ts" setup>
import { computed } from 'vue';
 
const props = defineProps<{
    label: string;
    value: number | string;
    suffix?: string;
    fixed?: number;
    hint?: string;
    alert?: boolean;
    demo?: boolean;
}>();
 
const numeric = computed(() => Number(props.value) || 0);
</script>
 
<style lang="scss" scoped>
.kpi-card {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--el-border-color-extra-light);
    background: var(--el-bg-color);
    color: var(--el-text-color-primary);
    min-height: 96px;
 
    &__label {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        color: var(--el-text-color-secondary);
    }
 
    &__badge {
        transform: scale(0.92);
    }
 
    &__value {
        margin-top: 8px;
        font-size: 26px;
        font-weight: 700;
        line-height: 1.2;
        color: var(--el-text-color-primary);
 
        :deep(.cl-number__suffix) {
            margin-left: 4px;
            font-size: 13px;
            font-weight: 500;
            color: var(--el-text-color-secondary);
        }
    }
 
    &__hint {
        margin-top: 8px;
        font-size: 12px;
        color: var(--el-text-color-secondary);
    }
 
    &.is-alert {
        border-color: var(--el-color-danger-light-5);
        background: var(--el-color-danger-light-9);
 
        .kpi-card__value {
            color: var(--el-color-danger);
        }
    }
 
    &.is-demo:not(.is-alert) {
        border-style: dashed;
    }
}
</style>