Forráskód Böngészése

style(water): align monitoring pages with statistics design

Kazerin 2 napja
szülő
commit
e8bf55045e

+ 238 - 63
src/views/subSystem/waterSupply/components/WaterMonitoringPage.vue

@@ -8,10 +8,16 @@
                     <span class="muted">按时间与数值范围查询实时点位,并查看趋势明细</span>
                 </div>
             </div>
-            <el-button :icon="Refresh" :loading="loading" @click="loadData">刷新</el-button>
+            <el-button class="heading-refresh" :icon="Refresh" :loading="loading" @click="loadData">刷新</el-button>
         </div>
 
         <el-card shadow="never" class="filter-card">
+            <template #header>
+                <div class="card-title">
+                    <el-icon><Search/></el-icon>
+                    <span>监测数据筛选</span>
+                </div>
+            </template>
             <el-form :inline="true" :model="query" @submit.prevent="loadData">
                 <el-form-item label="设备名称">
                     <el-input v-model="query.equipmentName" clearable placeholder="请输入设备名称"/>
@@ -40,8 +46,8 @@
                     <el-input-number v-model="query[maxKey]" :min="0" controls-position="right"/>
                 </el-form-item>
                 <el-form-item>
-                    <el-button type="primary" :loading="loading" @click="loadData">查询</el-button>
-                    <el-button @click="resetQuery">重置</el-button>
+                    <el-button type="primary" :icon="Search" :loading="loading" @click="loadData">查询</el-button>
+                    <el-button :icon="RefreshLeft" @click="resetQuery">重置</el-button>
                 </el-form-item>
             </el-form>
         </el-card>
@@ -60,36 +66,52 @@
 
         <div class="metric-grid">
             <div class="metric">
-                <el-icon class="metric-icon">
-                    <Monitor/>
-                </el-icon>
-                <span>监测点位</span><strong>{{ page.total }}</strong><small>个</small>
+                <div class="metric-icon metric-icon--blue"><el-icon><Monitor/></el-icon></div>
+                <div class="metric-body">
+                    <span>监测点位</span>
+                    <div class="metric-value"><strong>{{ page.total }}</strong><small>个</small></div>
+                </div>
             </div>
             <div class="metric">
-                <el-icon class="metric-icon">
-                    <DataAnalysis/>
-                </el-icon>
-                <span>当前均值</span><strong>{{ averageValue }}</strong><small>{{ unit }}</small>
+                <div class="metric-icon metric-icon--cyan"><el-icon><DataAnalysis/></el-icon></div>
+                <div class="metric-body">
+                    <span>当前均值</span>
+                    <div class="metric-value"><strong>{{ averageValue }}</strong><small>{{ unit }}</small></div>
+                </div>
             </div>
             <div class="metric">
-                <el-icon class="metric-icon">
-                    <Warning/>
-                </el-icon>
-                <span>异常点位</span><strong class="danger">{{ abnormalCount }}</strong><small>个</small>
+                <div class="metric-icon metric-icon--orange"><el-icon><Warning/></el-icon></div>
+                <div class="metric-body">
+                    <span>异常点位</span>
+                    <div class="metric-value"><strong class="danger">{{ abnormalCount }}</strong><small>个</small></div>
+                </div>
             </div>
             <div class="metric">
-                <el-icon class="metric-icon">
-                    <Clock/>
-                </el-icon>
-                <span>数据更新时间</span><strong class="time">{{ latestTime }}</strong>
+                <div class="metric-icon metric-icon--slate"><el-icon><Clock/></el-icon></div>
+                <div class="metric-body">
+                    <span>数据更新时间</span>
+                    <div class="metric-value"><strong class="time">{{ latestTime }}</strong></div>
+                </div>
             </div>
         </div>
 
         <el-card shadow="never" class="table-card">
-            <div class="card-title">
-                <span>{{ title }}点位清单</span>
-                <el-button v-hasPermi="[exportPermission]" link type="primary" :loading="exportLoading" @click="exportData">批量导出</el-button>
-            </div>
+            <template #header>
+                <div class="table-toolbar">
+                    <div class="card-title">
+                        <el-icon><DataLine/></el-icon>
+                        <span>{{ title }}点位清单</span>
+                    </div>
+                    <el-button
+                            v-hasPermi="[exportPermission]"
+                            type="success"
+                            plain
+                            :icon="Download"
+                            :loading="exportLoading"
+                            @click="exportData"
+                    >批量导出</el-button>
+                </div>
+            </template>
             <el-table :data="page.records" stripe border v-loading="loading" @row-click="showTrend">
                 <template #empty>
                     <el-empty :description="loadError ? '暂无法获取监测数据' : '暂无符合条件的监测数据'"/>
@@ -114,7 +136,10 @@
                 <el-table-column prop="updateTime" label="采集时间" min-width="165"/>
                 <el-table-column label="操作" width="90" fixed="right">
                     <template #default="{ row }">
-                        <el-button link type="primary" @click.stop="showTrend(row)">趋势</el-button>
+                        <el-button class="trend-button" link type="primary" @click.stop="showTrend(row)">
+                            <el-icon><TrendCharts/></el-icon>
+                            <span>趋势</span>
+                        </el-button>
                     </template>
                 </el-table-column>
             </el-table>
@@ -161,7 +186,18 @@
 </template>
 <script setup>
     import {computed, nextTick, onBeforeUnmount, onMounted, ref} from 'vue'
-    import {DataAnalysis, Monitor, Refresh, Warning} from '@element-plus/icons-vue'
+    import {
+        Clock,
+        DataAnalysis,
+        DataLine,
+        Download,
+        Monitor,
+        Refresh,
+        RefreshLeft,
+        Search,
+        TrendCharts,
+        Warning
+    } from '@element-plus/icons-vue'
     import {ElMessage} from 'element-plus'
     import {saveAs} from 'file-saver'
     import * as echarts from 'echarts'
@@ -184,6 +220,7 @@
     })
 
     const pageIcon = computed(() => props.metric === 'pressure' ? Warning : props.metric === 'power' ? DataAnalysis : Monitor)
+    const metricColor = computed(() => props.metric === 'pressure' ? '#f97316' : props.metric === 'power' ? '#06b6d4' : '#2563eb')
     const query = ref(createQuery())
     const page = ref({records: [], total: 0})
     const loading = ref(false)
@@ -294,17 +331,42 @@
         chart = echarts.init(chartRef.value)
         const labels = trendRecords.value.map(item => item.updateTime)
         const values = trendRecords.value.map(item => item.value ?? 0)
+        const color = metricColor.value
         chart.setOption({
-            tooltip: {trigger: 'axis'},
-            grid: {left: 40, right: 18, top: 20, bottom: 35},
-            xAxis: {type: 'category', data: labels},
-            yAxis: {type: 'value', name: props.unit},
+            tooltip: {
+                trigger: 'axis',
+                axisPointer: {type: 'line', lineStyle: {color: 'rgba(37, 99, 235, 0.25)'}}
+            },
+            grid: {left: 48, right: 20, top: 34, bottom: 38},
+            xAxis: {
+                type: 'category',
+                data: labels,
+                axisLine: {lineStyle: {color: '#cbd5e1'}},
+                axisLabel: {color: '#64748b'},
+                axisTick: {show: false}
+            },
+            yAxis: {
+                type: 'value',
+                name: props.unit,
+                nameTextStyle: {color: '#64748b'},
+                axisLine: {show: false},
+                axisLabel: {color: '#64748b'},
+                splitLine: {lineStyle: {color: '#e2e8f0', type: 'dashed'}}
+            },
             series: [{
                 type: 'line',
                 smooth: true,
                 data: values,
-                areaStyle: {opacity: 0.12},
-                itemStyle: {color: '#2563eb'}
+                symbol: 'circle',
+                symbolSize: 7,
+                lineStyle: {width: 3, color},
+                itemStyle: {color, borderColor: '#fff', borderWidth: 2},
+                areaStyle: {
+                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
+                        {offset: 0, color: `${color}33`},
+                        {offset: 1, color: `${color}05`}
+                    ])
+                }
             }]
         })
     }
@@ -346,7 +408,7 @@
 <style scoped>
     .water-page {
         padding: 20px;
-        background: #f5f7fa;
+        background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 45%, #eef2f7 100%);
         min-height: calc(100vh - 84px)
     }
 
@@ -354,31 +416,63 @@
         display: flex;
         justify-content: space-between;
         align-items: center;
+        gap: 16px;
         margin-bottom: 16px
     }
 
+    .page-title {
+        display: flex;
+        align-items: center;
+        gap: 12px;
+        min-width: 0;
+    }
+
+    .page-title-icon {
+        display: grid;
+        place-items: center;
+        width: 42px;
+        height: 42px;
+        border-radius: 8px;
+        color: #fff;
+        background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
+        box-shadow: 0 8px 16px rgba(37, 99, 235, 0.2);
+    }
+
     .page-heading h2 {
-        margin: 0 0 5px;
+        margin: 0 0 4px;
         font-size: 20px;
-        color: #1f2937
+        color: #1e293b
     }
 
     .muted {
         font-size: 13px;
-        color: #909399
+        color: #64748b
+    }
+
+    .heading-refresh {
+        border-color: #bfdbfe;
+        color: #2563eb;
+        background: #fff;
     }
 
     .filter-card {
-        margin-bottom: 16px
+        margin-bottom: 16px;
+        border: 1px solid #e2e8f0;
+        border-radius: 8px;
+        box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04)
     }
 
     .filter-card :deep(.el-form-item) {
-        margin-bottom: 0
+        margin-bottom: 0;
+    }
+
+    .filter-card :deep(.el-form-item__label) {
+        color: #475569
     }
 
     .range-sep {
         margin: 0 8px;
-        color: #909399
+        color: #94a3b8
     }
 
     .page-error {
@@ -387,64 +481,140 @@
 
     .metric-grid {
         display: grid;
-        grid-template-columns:repeat(4, minmax(0, 1fr));
-        gap: 12px;
+        grid-template-columns: repeat(4, minmax(0, 1fr));
+        gap: 14px;
         margin-bottom: 16px
     }
 
     .metric {
         display: flex;
-        flex-direction: column;
         align-items: center;
-        justify-content: center;
-        text-align: center;
-        background: #fff;
-        border: 1px solid #ebeef5;
+        gap: 14px;
+        min-width: 0;
         padding: 16px 18px;
-        min-height: 70px;
+        background: #fff;
+        border: 1px solid #e2e8f0;
+        border-radius: 8px;
+        box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04)
     }
 
-    /* 图标大小与下边距,确保与文字分离 */
     .metric-icon {
-        font-size: 28px;
-        margin-bottom: 6px;
+        flex: 0 0 42px;
+        display: grid;
+        place-items: center;
+        width: 42px;
+        height: 42px;
+        border-radius: 8px;
+    }
+
+    .metric-icon .el-icon {
+        font-size: 22px;
+    }
+
+    .metric-icon--blue {
+        color: #2563eb;
+        background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
+    }
+
+    .metric-icon--cyan {
+        color: #0891b2;
+        background: linear-gradient(135deg, #cffafe 0%, #ecfeff 100%);
+    }
+
+    .metric-icon--orange {
+        color: #ea580c;
+        background: linear-gradient(135deg, #ffedd5 0%, #fff7ed 100%);
+    }
+
+    .metric-icon--slate {
+        color: #475569;
+        background: linear-gradient(135deg, #e2e8f0 0%, #f8fafc 100%);
     }
 
-    .metric span {
+    .metric-body {
+        min-width: 0;
+        text-align: left;
+    }
+
+    .metric-body span {
         display: block;
-        color: #909399;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        margin-bottom: 3px;
+        color: #64748b;
         font-size: 13px
     }
 
-    .metric strong {
+    .metric-value {
+        display: flex;
+        align-items: baseline;
+        gap: 5px;
+        min-width: 0;
+    }
+
+    .metric-value strong {
         font-size: 24px;
         line-height: 1.2;
-        color: #1f2937
+        color: #1e293b;
     }
 
-    .metric small {
-        margin-left: 5px;
-        color: #909399
+    .metric-value small {
+        color: #94a3b8
     }
 
     .metric .time {
-        font-size: 16px
+        overflow: hidden;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        font-size: 16px;
     }
 
     .danger {
-        color: #e45656 !important
+        color: #ef4444 !important
     }
 
     .table-card {
-        min-height: 420px
+        min-height: 420px;
+        border: 1px solid #e2e8f0;
+        border-radius: 8px;
+        box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04)
     }
 
     .card-title {
         display: flex;
         align-items: center;
-        justify-content: space-between;
+        gap: 8px;
+        color: #1e293b;
         font-weight: 600;
-        margin-bottom: 14px
+    }
+
+    .card-title .el-icon {
+        color: #2563eb;
+        font-size: 18px;
+    }
+
+    .table-toolbar {
+        justify-content: space-between;
+        display: flex;
+        align-items: center;
+    }
+
+    .table-card :deep(.el-table) {
+        --el-table-border-color: #e2e8f0;
+        --el-table-header-bg-color: #f8fafc;
+        --el-table-header-text-color: #475569;
+        --el-table-row-hover-bg-color: #eff6ff;
+    }
+
+    .table-card :deep(.el-table__row) {
+        cursor: pointer;
+    }
+
+    .trend-button {
+        display: inline-flex;
+        align-items: center;
+        gap: 4px;
     }
 
     .table-card :deep(.el-pagination) {
@@ -453,12 +623,17 @@
     }
 
     .trend-body {
-        min-height: 340px
+        min-height: 340px;
+        padding-right: 4px
     }
 
     .trend-chart {
         height: 300px;
-        margin-bottom: 20px
+        margin-bottom: 20px;
+        padding: 12px;
+        border: 1px solid #e2e8f0;
+        border-radius: 8px;
+        background: #fff
     }
 
     .trend-body :deep(.el-empty) {