<template>
|
<div class="kpi-card" :class="{ 'is-alert': alert }">
|
<div class="kpi-card__label" :title="label">{{ label }}</div>
|
<div class="kpi-card__value">
|
<cl-number :value="numeric" :fixed="fixed" type="amount" :suffix="suffix" />
|
</div>
|
<div class="kpi-card__hint" :title="hint || ''">{{ hint || '\u00A0' }}</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;
|
/** @deprecated 首页不再展示演示标识,保留 prop 以免调用方报错 */
|
demo?: boolean;
|
}>();
|
|
const numeric = computed(() => Number(props.value) || 0);
|
</script>
|
|
<style lang="scss" scoped>
|
.kpi-card {
|
box-sizing: border-box;
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
height: 112px;
|
padding: 12px 14px;
|
border-radius: 12px;
|
border: 1px solid var(--el-border-color-extra-light);
|
background: var(--el-bg-color);
|
color: var(--el-text-color-primary);
|
overflow: hidden;
|
|
&__label {
|
flex-shrink: 0;
|
height: 20px;
|
line-height: 20px;
|
font-size: 13px;
|
color: var(--el-text-color-secondary);
|
white-space: nowrap;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
}
|
|
&__value {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
min-height: 0;
|
margin: 4px 0;
|
font-size: 24px;
|
font-weight: 700;
|
line-height: 1.15;
|
color: var(--el-text-color-primary);
|
overflow: hidden;
|
|
:deep(.cl-number) {
|
width: 100%;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
white-space: nowrap;
|
}
|
|
:deep(.cl-number__suffix) {
|
margin-left: 4px;
|
font-size: 13px;
|
font-weight: 500;
|
color: var(--el-text-color-secondary);
|
}
|
}
|
|
&__hint {
|
flex-shrink: 0;
|
height: 18px;
|
line-height: 18px;
|
font-size: 12px;
|
color: var(--el-text-color-secondary);
|
white-space: nowrap;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
}
|
|
&.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);
|
}
|
}
|
}
|
</style>
|