You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.4 KiB
Vue
118 lines
2.4 KiB
Vue
<template>
|
|
<div class="data-card fade-in-up" @click="$emit('click')">
|
|
<div class="card-header">
|
|
<div class="card-icon" :style="{ background: iconBg }">
|
|
<el-icon :size="20" :color="iconColor"><component :is="icon" /></el-icon>
|
|
</div>
|
|
<span class="card-label">{{ label }}</span>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="card-value">
|
|
<span class="value-num">{{ value }}</span>
|
|
<span v-if="unit" class="value-unit">{{ unit }}</span>
|
|
</div>
|
|
<div v-if="trend !== undefined" class="card-trend" :class="trend >= 0 ? 'up' : 'down'">
|
|
<el-icon :size="14">
|
|
<CaretTop v-if="trend >= 0" />
|
|
<CaretBottom v-else />
|
|
</el-icon>
|
|
<span>{{ Math.abs(trend) }}%</span>
|
|
<span class="trend-label">较昨日</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
defineProps({
|
|
label: { type: String, required: true },
|
|
value: { type: [String, Number], required: true },
|
|
unit: { type: String, default: '' },
|
|
icon: { type: [String, Object], required: true },
|
|
iconColor: { type: String, default: '#52c41a' },
|
|
iconBg: { type: String, default: '#e8f9e0' },
|
|
trend: { type: Number, default: undefined }
|
|
})
|
|
|
|
defineEmits(['click'])
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.data-card {
|
|
background: #ffffff;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
border: 1px solid #f0f0f0;
|
|
|
|
&:hover {
|
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
|
transform: translateY(-2px);
|
|
}
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.card-icon {
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.card-label {
|
|
font-size: 14px;
|
|
color: #525252;
|
|
}
|
|
|
|
.card-body {
|
|
display: flex;
|
|
align-items: flex-end;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.value-num {
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
color: #262626;
|
|
line-height: 1;
|
|
}
|
|
|
|
.value-unit {
|
|
font-size: 14px;
|
|
color: #525252;
|
|
margin-left: 4px;
|
|
}
|
|
|
|
.card-trend {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
gap: 2px;
|
|
|
|
&.up {
|
|
color: #52c41a;
|
|
}
|
|
&.down {
|
|
color: #f5222d;
|
|
}
|
|
|
|
.trend-label {
|
|
font-size: 12px;
|
|
color: #bfbfbf;
|
|
font-weight: 400;
|
|
margin-left: 4px;
|
|
}
|
|
}
|
|
</style>
|