200 lines
3.6 KiB
Vue
200 lines
3.6 KiB
Vue
<template>
|
|
<div class="zonglan-container">
|
|
<!-- 循环生成统计卡片 -->
|
|
<div v-for="card in statCards" :key="card.id" class="stat-card">
|
|
<div class="card-header">
|
|
<span class="card-title">{{ card.title }}</span>
|
|
<el-tooltip content="查看详情" placement="top">
|
|
<el-icon>
|
|
<Warning />
|
|
</el-icon>
|
|
</el-tooltip>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="stat-value">{{ card.value }}</div>
|
|
<div class="stat-footer">
|
|
<span class="trend-indicator up">
|
|
<img src="/src/assets/demo/up.png" alt="up" class="trend-icon"> {{ card.trendChange }}
|
|
</span>
|
|
<el-select v-model="card.selectedTimeRange" placeholder="选择时间范围" style="width: 120px; font-size: 12px;">
|
|
<el-option label="Today" value="today"></el-option>
|
|
<el-option label="This Week" value="week"></el-option>
|
|
<el-option label="This Month" value="month"></el-option>
|
|
<el-option label="This Year" value="year"></el-option>
|
|
</el-select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
|
|
// 统计卡片数据
|
|
interface StatCard {
|
|
id: string;
|
|
title: string;
|
|
value: string;
|
|
trendChange: string;
|
|
selectedTimeRange: string;
|
|
}
|
|
|
|
const statCards = ref<StatCard[]>([
|
|
{
|
|
id: 'power-total',
|
|
title: '总发电量',
|
|
value: '2,456.8',
|
|
trendChange: '4.2%',
|
|
selectedTimeRange: 'today'
|
|
},
|
|
{
|
|
id: 'year-on-year',
|
|
title: '同比增长率',
|
|
value: '3.8%',
|
|
trendChange: '0.5%',
|
|
selectedTimeRange: 'today'
|
|
},
|
|
{
|
|
id: 'month-on-month',
|
|
title: '环比增长率',
|
|
value: '2.1%',
|
|
trendChange: '0.3%',
|
|
selectedTimeRange: 'today'
|
|
},
|
|
{
|
|
id: 'efficiency',
|
|
title: '运行效率',
|
|
value: '98.6%',
|
|
trendChange: '1.2%',
|
|
selectedTimeRange: 'today'
|
|
}
|
|
]);
|
|
</script>
|
|
|
|
<style scoped>
|
|
.zonglan-container {
|
|
display: flex;
|
|
gap: 20px;
|
|
width: 100%;
|
|
padding: 10px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.stat-card {
|
|
flex: 1;
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.stat-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 14px;
|
|
color: #666;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.info-icon {
|
|
color: #c0c4cc;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
transition: color 0.3s;
|
|
}
|
|
|
|
.info-icon:hover {
|
|
color: #409eff;
|
|
}
|
|
|
|
.card-content {
|
|
position: relative;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 28px;
|
|
font-weight: 600;
|
|
color: #303133;
|
|
margin-bottom: 10px;
|
|
line-height: 1.2;
|
|
padding-bottom: 10px;
|
|
border-bottom: 1px solid #ebeef5;
|
|
}
|
|
|
|
.stat-footer {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.trend-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.trend-indicator.up {
|
|
color: #67c23a;
|
|
}
|
|
|
|
.trend-indicator.down {
|
|
color: #f56c6c;
|
|
}
|
|
|
|
.trend-indicator i {
|
|
margin-right: 4px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.trend-icon {
|
|
margin-right: 4px;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.time-range {
|
|
font-size: 12px;
|
|
color: #909399;
|
|
}
|
|
|
|
/* 响应式设计 */
|
|
@media (max-width: 1200px) {
|
|
.zonglan-container {
|
|
gap: 15px;
|
|
}
|
|
|
|
.stat-card {
|
|
padding: 15px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 24px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.zonglan-container {
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
|
|
.stat-card {
|
|
padding: 15px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 22px;
|
|
}
|
|
}
|
|
</style> |