From e1673170d6a44bc67f978b815d15df67114377bb Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期六, 07 十一月 2026 14:13:01 +0800
Subject: [PATCH] feat: 能耗管理
---
src/views/energyManagement/waterElectricMeter/components/DeviceSidePanel.vue | 453 +++
src/views/energyManagement/waterElectricMeter/components/DeviceFormDialog.vue | 287 ++
src/views/energyManagement/analysis/index.vue | 654 ++++
src/views/energyManagement/collection/index.vue | 744 +++++
src/router/index.js | 49
src/views/energyManagement/waterElectricMeter/index.vue | 998 +++++++
/dev/null | 118
src/views/energyManagement/realtime/index.vue | 847 ++++++
src/views/energyManagement/meterLedger/index.vue | 1426 ++++++++++
src/api/energyManagement/energyMeter.js | 187 +
src/views/energyManagement/meterData/electric/index.vue | 1298 +++++++++
src/views/energyManagement/meterData/gas/index.vue | 43
src/views/energyManagement/meterData/components/MeterOverview.vue | 786 +++++
src/views/energyManagement/meterData/water/index.vue | 41
14 files changed, 7,813 insertions(+), 118 deletions(-)
diff --git a/src/api/energyManagement/energyMeter.js b/src/api/energyManagement/energyMeter.js
new file mode 100644
index 0000000..bbdc23f
--- /dev/null
+++ b/src/api/energyManagement/energyMeter.js
@@ -0,0 +1,187 @@
+// 姘寸數琛ㄧ洃娴嬶紙闆嗙ぞ浜戣兘婧愮洃鎺ф帴鍏ワ級
+import request, { download } from '@/utils/request'
+
+// 璁惧鍒楄〃-鍒嗛〉鏌ヨ
+export function listMeterDevices(query) {
+ return request({
+ url: '/energyMeter/devices',
+ method: 'get',
+ params: query
+ })
+}
+
+// 璁惧涓嬫媺閫夐」锛堜粎鍚敤璁惧锛�
+export function listMeterDeviceOptions(query) {
+ return request({
+ url: '/energyMeter/devices/options',
+ method: 'get',
+ params: query
+ })
+}
+
+// 楠岃瘉骞惰鍙栫涓夋柟妗f
+export function verifyMeterDevice(data) {
+ return request({
+ url: '/energyMeter/devices/verify',
+ method: 'post',
+ data
+ })
+}
+
+// 鏂板鏈湴缁戝畾
+export function addMeterDevice(data) {
+ return request({
+ url: '/energyMeter/devices',
+ method: 'post',
+ data
+ })
+}
+
+// 淇敼璁惧鏈湴瀛楁 / 鍚仠鐢�
+export function updateMeterDevice(id, data) {
+ return request({
+ url: '/energyMeter/devices/' + id,
+ method: 'put',
+ data
+ })
+}
+
+// 鍗曞彴璁惧鎵嬪姩鏌ヨ〃
+export function collectMeterDevice(id, data) {
+ return request({
+ url: '/energyMeter/devices/' + id + '/collect',
+ method: 'post',
+ data
+ })
+}
+
+// 鎵归噺鎵嬪姩鏌ヨ〃
+export function collectMeterDevices(data) {
+ return request({
+ url: '/energyMeter/devices/collect',
+ method: 'post',
+ data
+ })
+}
+
+// 璁惧璇绘暟/鐢ㄩ噺鏄庣粏
+export function listMeterMeasurements(id, query) {
+ return request({
+ url: '/energyMeter/devices/' + id + '/measurements',
+ method: 'get',
+ params: query
+ })
+}
+
+// 鐢ㄨ兘姒傝
+export function getMeterOverview(query) {
+ return request({
+ url: '/energyMeter/overview',
+ method: 'get',
+ params: query
+ })
+}
+
+// 鐢佃〃瀹炴椂鐪嬫澘锛氫粖鏃� 15 鍒嗛挓鏇茬嚎 + 杩戜竴鍛�/涓婁竴鍛ㄧ數鑳借川閲�
+export function getElectricMeterDashboard(query) {
+ return request({
+ url: '/energyMeter/electric/dashboard',
+ method: 'get',
+ params: query
+ })
+}
+
+// 绗笁鏂规帴鍏ユā寮忥紙鏄惁婕旂ず鏁版嵁锛�
+export function getMeterProviderStatus() {
+ return request({
+ url: '/energyMeter/providerStatus',
+ method: 'get'
+ })
+}
+
+// 钂告苯琛ㄦ紨绀鸿澶囨寜澶╄嚜鍔ㄧ敓鎴愭暟鎹紙榛樿鏄ㄥぉ锛屽箓绛夛紝鍙噸澶嶆墽琛岋級
+export function simulateGasMeters(date) {
+ return request({
+ url: '/energyMeter/sync/gasSimulate',
+ method: 'post',
+ params: { date }
+ })
+}
+
+/* ---------------------- 閲囬泦 / 瀹炴椂鐩戞帶 / 缁熻鍒嗘瀽 ---------------------- */
+
+// 鑳借�楁暟鎹噰闆嗘瑙堬細涓夌被浠嬭川鎺ュ叆璁惧銆佸綊闆嗚繘搴︿笌鏈�杩戦噰闆嗘壒娆�
+export function getEnergyCollectionOverview() {
+ return request({
+ url: '/energyMeter/collection/overview',
+ method: 'get'
+ })
+}
+
+// 鑳借�楀疄鏃剁洃鎺э細涓夌被浠嬭川鏈�鏂扮敤閲忋�佽繎 7 鏃ヨ秼鍔夸笌鐢佃〃瀹炴椂鏇茬嚎
+export function getEnergyRealtimeOverview(params) {
+ return request({
+ url: '/energyMeter/realtime/overview',
+ method: 'get',
+ params
+ })
+}
+
+// 鑳借�楃粺璁″垎鏋愶細鎸夋棩/鏈堛�佹寜浠嬭川/璁惧姹囨��
+export function getEnergyReport(params) {
+ return request({
+ url: '/energyMeter/report/summary',
+ method: 'get',
+ params
+ })
+}
+
+// 鑳借�楃粺璁℃姤琛ㄥ鍑� Excel
+export function exportEnergyReport(params, filename) {
+ return download('/energyMeter/report/export', params, filename)
+}
+
+/* ------------------------- 琛ㄥ叿鍙拌处锛堟墜宸ユ妱琛級 ------------------------- */
+
+// 鏂板鎵嬪伐鎶勮〃璁惧锛堟按琛�/鐢佃〃/姘旇〃锛�
+export function addManualMeterDevice(data) {
+ return request({
+ url: '/energyMeter/devices/manual',
+ method: 'post',
+ data
+ })
+}
+
+// 鍒犻櫎璁惧锛堝垵濮嬪寲璁惧涓庣涓夋柟鎺ュ叆璁惧鐢卞悗绔嫆缁濆苟杩斿洖閿欒娑堟伅锛�
+export function deleteMeterDevice(id) {
+ return request({
+ url: '/energyMeter/devices/' + id,
+ method: 'delete'
+ })
+}
+
+// 鎵嬪伐鎶勮〃璁板綍-鍒嗛〉鏌ヨ
+export function listMeterReadings(id, query) {
+ return request({
+ url: '/energyMeter/devices/' + id + '/readings',
+ method: 'get',
+ params: query
+ })
+}
+
+// 鎵嬪伐褰曡〃锛堣繑鍥炴湰鏈熺敤閲忕瓑淇℃伅锛�
+export function addMeterReading(id, data) {
+ return request({
+ url: '/energyMeter/devices/' + id + '/readings',
+ method: 'post',
+ data
+ })
+}
+
+// 鍒犻櫎涓�鏉℃墜宸ユ妱琛ㄨ褰�
+export function deleteMeterReading(id, readingId) {
+ return request({
+ url: '/energyMeter/devices/' + id + '/readings/' + readingId,
+ method: 'delete'
+ })
+}
diff --git a/src/router/index.js b/src/router/index.js
index 7be3668..faaac3e 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -97,6 +97,55 @@
},
],
},
+ // 鑳借�楃鐞�
+ {
+ path: "/energyManagement",
+ component: Layout,
+ redirect: "/energyManagement/meterLedger",
+ name: "EnergyManagement",
+ meta: { title: "鑳借�楃鐞�", icon: "chart" },
+ children: [
+ {
+ path: "meterLedger",
+ component: () => import("@/views/energyManagement/meterLedger/index"),
+ name: "MeterLedger",
+ meta: { title: "琛ㄥ叿鍙拌处", icon: "list" },
+ },
+ {
+ path: "dataCollection",
+ component: () => import("@/views/energyManagement/collection/index"),
+ name: "EnergyDataCollection",
+ meta: { title: "鑳借�楁暟鎹噰闆�", icon: "download" },
+ },
+ {
+ path: "realtimeMonitor",
+ component: () => import("@/views/energyManagement/realtime/index"),
+ name: "EnergyRealtimeMonitor",
+ meta: { title: "鑳借�楀疄鏃剁洃鎺�", icon: "monitor" },
+ },
+ {
+ path: "energyAnalysis",
+ component: () => import("@/views/energyManagement/analysis/index"),
+ name: "EnergyAnalysis",
+ meta: { title: "鑳借�楃粺璁″垎鏋�", icon: "chart" },
+ },
+ {
+ path: "waterMeterData",
+ redirect: (to) => ({ path: "/energyManagement/realtimeMonitor", query: to.query }),
+ hidden: true,
+ },
+ {
+ path: "electricMeterData",
+ redirect: (to) => ({ path: "/energyManagement/realtimeMonitor", query: to.query }),
+ hidden: true,
+ },
+ {
+ path: "gasMeterData",
+ redirect: (to) => ({ path: "/energyManagement/realtimeMonitor", query: to.query }),
+ hidden: true,
+ },
+ ],
+ },
{
path: "/user",
component: Layout,
diff --git a/src/views/energyManagement/analysis/index.vue b/src/views/energyManagement/analysis/index.vue
new file mode 100644
index 0000000..c52f6c1
--- /dev/null
+++ b/src/views/energyManagement/analysis/index.vue
@@ -0,0 +1,654 @@
+<template>
+ <div class="app-container energy-analysis">
+ <div class="page-head">
+ <div class="head-text">
+ <h2>鑳借�楃粺璁″垎鏋�</h2>
+ <p>鎸夋椂娈点�佺淮搴﹁嚜鍔ㄦ眹鎬绘按銆佺數銆佽捀姹界敤閲忥紝鐢熸垚缁熻鎶ヨ〃骞舵敮鎸佸鍑烘煡闃咃紝涓鸿妭鑳藉垎鏋愭彁渚涙暟鎹敮鎾戙��</p>
+ </div>
+ </div>
+
+ <el-alert
+ v-if="report.mockMode"
+ class="mock-alert"
+ type="info"
+ :closable="false"
+ show-icon
+ title="褰撳墠涓烘紨绀烘暟鎹ā寮忥細鏈厤缃涓夋柟鎺堟潈鐮侊紝缁熻鏁版嵁鐢辨湰鍦版ā鎷熺敓鎴愶紝浠呯敤浜庤仈璋冧笌椤甸潰婕旂ず銆�"
+ />
+
+ <section class="panel filter-panel">
+ <div class="filters">
+ <div class="filter-item">
+ <span class="filter-label">缁熻鏃舵</span>
+ <el-date-picker
+ v-model="dateRange"
+ type="daterange"
+ value-format="YYYY-MM-DD"
+ range-separator="鑷�"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ :shortcuts="shortcuts"
+ style="width: 260px"
+ />
+ </div>
+ <div class="filter-item">
+ <span class="filter-label">缁熻绮掑害</span>
+ <el-radio-group v-model="query.granularity" size="small">
+ <el-radio-button label="DAY">鎸夋棩</el-radio-button>
+ <el-radio-button label="MONTH">鎸夋湀</el-radio-button>
+ </el-radio-group>
+ </div>
+ <div class="filter-item">
+ <span class="filter-label">缁熻缁村害</span>
+ <el-radio-group v-model="query.dimension" size="small">
+ <el-radio-button label="MEDIUM">鎸変粙璐�</el-radio-button>
+ <el-radio-button label="DEVICE">鎸夎澶�</el-radio-button>
+ </el-radio-group>
+ </div>
+ <div class="filter-item">
+ <span class="filter-label">浠嬭川</span>
+ <el-select v-model="query.meterType" style="width: 120px">
+ <el-option label="鍏ㄩ儴浠嬭川" value="ALL" />
+ <el-option label="姘磋〃" value="WATER" />
+ <el-option label="鐢佃〃" value="ELECTRIC" />
+ <el-option label="钂告苯琛�" value="GAS" />
+ </el-select>
+ </div>
+ <div class="filter-actions">
+ <el-button type="primary" :loading="loading" @click="load">鏌ヨ</el-button>
+ <el-button :loading="exporting" @click="handleExport">瀵煎嚭鎶ヨ〃</el-button>
+ </div>
+ </div>
+ </section>
+
+ <div class="summary-grid">
+ <div v-for="item in summaryCards" :key="item.key" class="summary-card" :class="'summary-' + item.key">
+ <span class="summary-label">{{ item.label }}</span>
+ <div class="summary-value">
+ <b>{{ formatNumber(item.value) }}</b>
+ <i v-if="item.unit">{{ item.unit }}</i>
+ </div>
+ <span class="summary-sub">{{ item.sub }}</span>
+ </div>
+ </div>
+
+ <section class="panel">
+ <div class="panel-head">
+ <div class="panel-title">鑳借�楄秼鍔�</div>
+ <div class="legend">
+ <span><i class="dot water"></i>姘� m鲁</span>
+ <span><i class="dot gas"></i>钂告苯 m鲁</span>
+ <span><i class="dot electric"></i>鐢� 搴�</span>
+ </div>
+ </div>
+ <div ref="trendRef" class="chart chart-trend"></div>
+ </section>
+
+ <section class="panel">
+ <div class="panel-head">
+ <div class="panel-title">
+ {{ query.dimension === 'MEDIUM' ? '鍒嗗懆鏈熺粺璁℃槑缁�' : '鍒嗚澶囩粺璁℃槑缁�' }}
+ <span class="panel-sub">{{ periodsText }}</span>
+ </div>
+ <span class="panel-range">鏁版嵁瑕嗙洊 {{ report.coveredPeriods || 0 }}/{{ report.totalPeriods || 0 }} 涓懆鏈�</span>
+ </div>
+
+ <el-table
+ v-if="query.dimension === 'MEDIUM'"
+ v-loading="loading"
+ :data="report.rows || []"
+ border
+ stripe
+ size="small"
+ show-summary
+ :summary-method="mediumSummary"
+ max-height="460"
+ >
+ <el-table-column prop="period" label="缁熻鍛ㄦ湡" min-width="130" fixed />
+ <el-table-column label="姘磋〃鐢ㄩ噺锛坢鲁锛�" min-width="140" align="right">
+ <template #default="{ row }">{{ formatNumber(row.water) }}</template>
+ </el-table-column>
+ <el-table-column label="鐢佃〃鐢ㄩ噺锛堝害锛�" min-width="140" align="right">
+ <template #default="{ row }">{{ formatNumber(row.electric) }}</template>
+ </el-table-column>
+ <el-table-column label="钂告苯琛ㄧ敤閲忥紙m鲁锛�" min-width="150" align="right">
+ <template #default="{ row }">{{ formatNumber(row.gas) }}</template>
+ </el-table-column>
+ <template #empty>
+ <el-empty description="鎵�閫夋椂娈垫殏鏃犵粺璁℃暟鎹�" :image-size="60" />
+ </template>
+ </el-table>
+
+ <el-table
+ v-else
+ v-loading="loading"
+ :data="report.devices || []"
+ border
+ stripe
+ size="small"
+ max-height="460"
+ >
+ <el-table-column label="璁惧鍚嶇О" min-width="180">
+ <template #default="{ row }">
+ <b class="device-name">{{ row.meterName }}</b>
+ </template>
+ </el-table-column>
+ <el-table-column prop="meterAddress" label="琛ㄥ彿" min-width="150" />
+ <el-table-column label="浠嬭川" width="90" align="center">
+ <template #default="{ row }">
+ <el-tag size="small" :type="mediumTagType(row.meterType)" effect="plain">{{ row.meterTypeName }}</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="sourceTypeName" label="閲囬泦鏂瑰紡" width="110" align="center" />
+ <el-table-column label="鏈熼棿鐢ㄩ噺" width="150" align="right">
+ <template #default="{ row }">
+ <span class="usage-value">{{ formatNumber(row.total) }}</span>
+ <span class="usage-unit">{{ displayUnit(row.unit) }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鍗犱粙璐ㄦ瘮渚�" width="130" align="right">
+ <template #default="{ row }">{{ row.share == null ? '--' : Number(row.share).toFixed(1) + '%' }}</template>
+ </el-table-column>
+ <template #empty>
+ <el-empty description="鎵�閫夋椂娈垫殏鏃犺澶囨暟鎹�" :image-size="60" />
+ </template>
+ </el-table>
+
+ <p class="report-note">{{ report.note || '缁熻鍙e緞锛氫粎姹囨�绘棩绮掑害鐢ㄩ噺锛岃〃鐮佷笉鍙備笌绱姞銆�' }}</p>
+ </section>
+ </div>
+</template>
+
+<script setup>
+import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
+import dayjs from 'dayjs'
+import * as echarts from 'echarts'
+import { exportEnergyReport, getEnergyReport } from '@/api/energyManagement/energyMeter'
+
+defineOptions({ name: 'EnergyAnalysis' })
+
+const COLOR_WATER = '#409eff'
+const COLOR_ELECTRIC = '#e6a23c'
+const COLOR_GAS = '#21a675'
+const UNIT_MAP = { WATER: 'm鲁', ELECTRIC: '搴�', GAS: 'm鲁' }
+
+const loading = ref(false)
+const exporting = ref(false)
+const report = ref({ rows: [], devices: [], totals: [], periods: [] })
+const dateRange = ref([
+ dayjs().startOf('month').format('YYYY-MM-DD'),
+ dayjs().format('YYYY-MM-DD')
+])
+const query = reactive({ granularity: 'DAY', dimension: 'MEDIUM', meterType: 'ALL' })
+
+const trendRef = ref(null)
+let trendChart = null
+
+const shortcuts = [
+ {
+ text: '鏈湀',
+ value: () => [dayjs().startOf('month').toDate(), dayjs().toDate()]
+ },
+ {
+ text: '涓婃湀',
+ value: () => [dayjs().subtract(1, 'month').startOf('month').toDate(),
+ dayjs().subtract(1, 'month').endOf('month').toDate()]
+ },
+ {
+ text: '杩� 7 澶�',
+ value: () => [dayjs().subtract(6, 'day').toDate(), dayjs().toDate()]
+ },
+ {
+ text: '杩� 30 澶�',
+ value: () => [dayjs().subtract(29, 'day').toDate(), dayjs().toDate()]
+ },
+ {
+ text: '鏈勾',
+ value: () => [dayjs().startOf('year').toDate(), dayjs().toDate()]
+ }
+]
+
+const totalsMap = computed(() => {
+ const map = {}
+ ;(report.value.totals || []).forEach((item) => {
+ map[item.meterType] = item
+ })
+ return map
+})
+
+const summaryCards = computed(() => [
+ {
+ key: 'water',
+ label: '姘磋〃鍚堣',
+ unit: 'm鲁',
+ value: totalsMap.value.WATER ? totalsMap.value.WATER.total : null,
+ sub: deviceCountText('WATER')
+ },
+ {
+ key: 'electric',
+ label: '鐢佃〃鍚堣',
+ unit: '搴�',
+ value: totalsMap.value.ELECTRIC ? totalsMap.value.ELECTRIC.total : null,
+ sub: deviceCountText('ELECTRIC')
+ },
+ {
+ key: 'gas',
+ label: '钂告苯琛ㄥ悎璁�',
+ unit: 'm鲁',
+ value: totalsMap.value.GAS ? totalsMap.value.GAS.total : null,
+ sub: deviceCountText('GAS')
+ },
+ {
+ key: 'period',
+ label: '鏈夋暟鎹懆鏈�',
+ unit: '涓懆鏈�',
+ value: report.value.coveredPeriods || 0,
+ sub: `鍏� ${report.value.totalPeriods || 0} 涓懆鏈焋
+ }
+])
+
+const periodsText = computed(() => {
+ if (!report.value.start) {
+ return ''
+ }
+ return `${report.value.start} ~ ${report.value.end} 路 鍏� ${report.value.totalPeriods || 0} 涓懆鏈焋
+})
+
+onMounted(() => {
+ load()
+ window.addEventListener('resize', handleResize)
+})
+
+onBeforeUnmount(() => {
+ window.removeEventListener('resize', handleResize)
+ if (trendChart) {
+ trendChart.dispose()
+ trendChart = null
+ }
+})
+
+async function load() {
+ if (!dateRange.value || dateRange.value.length !== 2) {
+ return
+ }
+ loading.value = true
+ try {
+ const res = await getEnergyReport(buildParams())
+ report.value = res.data || { rows: [], devices: [], totals: [], periods: [] }
+ await nextTick()
+ renderTrend()
+ } catch (e) {
+ report.value = { rows: [], devices: [], totals: [], periods: [] }
+ } finally {
+ loading.value = false
+ }
+}
+
+function buildParams() {
+ return {
+ startDate: dateRange.value[0],
+ endDate: dateRange.value[1],
+ granularity: query.granularity,
+ meterType: query.meterType,
+ dimension: query.dimension
+ }
+}
+
+async function handleExport() {
+ if (!dateRange.value || dateRange.value.length !== 2) {
+ return
+ }
+ exporting.value = true
+ try {
+ const fileName = `鑳借�楃粺璁℃姤琛╛${dateRange.value[0]}_${dateRange.value[1]}.xlsx`
+ await exportEnergyReport(buildParams(), fileName)
+ } finally {
+ exporting.value = false
+ }
+}
+
+function deviceCountText(meterType) {
+ const total = totalsMap.value[meterType]
+ return total ? `${total.deviceCount || 0} 鍙拌澶嘸 : '鏈帴鍏ヨ澶�'
+}
+
+function handleResize() {
+ trendChart && trendChart.resize()
+}
+
+function renderTrend() {
+ if (!trendRef.value) {
+ return
+ }
+ if (!trendChart) {
+ trendChart = echarts.init(trendRef.value)
+ }
+ const rows = report.value.rows || []
+ const hasData = rows.some((row) => row.water != null || row.electric != null || row.gas != null)
+ trendChart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ valueFormatter: (value) => (value == null ? '鏆傛棤鏁版嵁' : Number(value).toFixed(3).replace(/\.?0+$/, ''))
+ },
+ grid: { left: 52, right: 56, top: 26, bottom: 30 },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: rows.map((row) => row.period),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: {
+ color: '#909399',
+ fontSize: 11,
+ hideOverlap: true,
+ formatter: (value) => (value && value.length === 10 ? value.slice(5) : value)
+ }
+ },
+ yAxis: [
+ {
+ type: 'value',
+ name: 'm鲁',
+ nameTextStyle: { color: '#909399', fontSize: 11 },
+ axisLabel: { color: '#909399', fontSize: 11 },
+ splitLine: { lineStyle: { type: 'dashed', color: '#f0f2f5' } }
+ },
+ {
+ type: 'value',
+ name: '搴�',
+ nameTextStyle: { color: '#909399', fontSize: 11 },
+ axisLabel: { color: '#909399', fontSize: 11 },
+ splitLine: { show: false }
+ }
+ ],
+ series: [
+ lineSeries('姘�', rows.map((row) => row.water), COLOR_WATER, 0),
+ lineSeries('钂告苯', rows.map((row) => row.gas), COLOR_GAS, 0),
+ lineSeries('鐢�', rows.map((row) => row.electric), COLOR_ELECTRIC, 1)
+ ],
+ graphic: hasData ? [] : [{ type: 'text', left: 'center', top: 'middle', style: { text: '鎵�閫夋椂娈垫殏鏃犳暟鎹�', fill: '#c0c4cc', fontSize: 13 } }]
+ },
+ true
+ )
+ trendChart.resize()
+}
+
+function lineSeries(name, data, color, yAxisIndex) {
+ return {
+ name,
+ type: 'line',
+ smooth: true,
+ symbol: 'circle',
+ symbolSize: 4,
+ connectNulls: false,
+ yAxisIndex,
+ data,
+ lineStyle: { width: 2, color },
+ itemStyle: { color }
+ }
+}
+
+function mediumSummary({ columns }) {
+ const water = totalsMap.value.WATER ? totalsMap.value.WATER.total : null
+ const electric = totalsMap.value.ELECTRIC ? totalsMap.value.ELECTRIC.total : null
+ const gas = totalsMap.value.GAS ? totalsMap.value.GAS.total : null
+ return columns.map((column, index) => {
+ if (index === 0) {
+ return '鍚堣'
+ }
+ if (index === 1) {
+ return formatNumber(water)
+ }
+ if (index === 2) {
+ return formatNumber(electric)
+ }
+ if (index === 3) {
+ return formatNumber(gas)
+ }
+ return ''
+ })
+}
+
+function mediumTagType(meterType) {
+ return { WATER: 'primary', ELECTRIC: 'warning', GAS: 'success' }[meterType] || 'info'
+}
+
+function displayUnit(unit) {
+ if (!unit) {
+ return ''
+ }
+ if (unit === 'm3') {
+ return 'm鲁'
+ }
+ if (unit === 'kWh') {
+ return '搴�'
+ }
+ return unit
+}
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num.toFixed(3).replace(/\.?0+$/, '')
+}
+</script>
+
+<style lang="scss" scoped>
+.energy-analysis {
+ padding-bottom: 24px;
+}
+
+.page-head {
+ margin-bottom: 14px;
+
+ h2 {
+ margin: 0 0 4px;
+ font-size: 18px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ p {
+ margin: 0;
+ font-size: 12px;
+ color: #909399;
+ }
+}
+
+.mock-alert {
+ margin-bottom: 12px;
+}
+
+.panel {
+ padding: 14px 16px;
+ margin-bottom: 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 8px;
+ background: #fff;
+}
+
+.filter-panel {
+ padding: 12px 16px;
+}
+
+.filters {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 14px 20px;
+}
+
+.filter-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.filter-label {
+ font-size: 13px;
+ color: #606266;
+ white-space: nowrap;
+}
+
+.filter-actions {
+ display: flex;
+ gap: 8px;
+ margin-left: auto;
+}
+
+.summary-grid {
+ display: grid;
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ gap: 12px;
+ margin-bottom: 12px;
+
+ @media (max-width: 1100px) {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+}
+
+.summary-card {
+ padding: 14px 16px;
+ border: 1px solid #ebeef5;
+ border-radius: 8px;
+ background: #fff;
+
+ .summary-label {
+ font-size: 13px;
+ color: #909399;
+ }
+
+ .summary-value {
+ display: flex;
+ align-items: baseline;
+ gap: 4px;
+ margin: 6px 0 2px;
+
+ b {
+ font-size: 24px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ i {
+ font-size: 12px;
+ font-style: normal;
+ color: #909399;
+ }
+ }
+
+ .summary-sub {
+ font-size: 12px;
+ color: #a8abb2;
+ }
+
+ &.summary-water {
+ border-left: 3px solid #409eff;
+ }
+
+ &.summary-electric {
+ border-left: 3px solid #e6a23c;
+ }
+
+ &.summary-gas {
+ border-left: 3px solid #21a675;
+ }
+
+ &.summary-period {
+ border-left: 3px solid #909399;
+
+ .summary-value b {
+ font-size: 20px;
+ }
+ }
+}
+
+.panel-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ margin-bottom: 10px;
+}
+
+.panel-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+}
+
+.panel-sub {
+ margin-left: 8px;
+ font-size: 12px;
+ font-weight: 400;
+ color: #a8abb2;
+}
+
+.panel-range {
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.legend {
+ display: flex;
+ gap: 14px;
+ font-size: 12px;
+ color: #606266;
+
+ .dot {
+ display: inline-block;
+ width: 8px;
+ height: 8px;
+ margin-right: 4px;
+ border-radius: 50%;
+
+ &.water {
+ background: #409eff;
+ }
+
+ &.electric {
+ background: #e6a23c;
+ }
+
+ &.gas {
+ background: #21a675;
+ }
+ }
+}
+
+.chart {
+ width: 100%;
+}
+
+.chart-trend {
+ height: 300px;
+}
+
+.device-name {
+ font-weight: 500;
+ color: #303133;
+}
+
+.usage-value {
+ font-weight: 600;
+ color: #303133;
+}
+
+.usage-unit {
+ margin-left: 3px;
+ font-size: 12px;
+ color: #909399;
+}
+
+.report-note {
+ margin: 12px 0 0;
+ font-size: 12px;
+ color: #a8abb2;
+}
+</style>
diff --git a/src/views/energyManagement/collection/index.vue b/src/views/energyManagement/collection/index.vue
new file mode 100644
index 0000000..bfaf6a2
--- /dev/null
+++ b/src/views/energyManagement/collection/index.vue
@@ -0,0 +1,744 @@
+<template>
+ <div class="app-container energy-collection">
+ <div class="page-head">
+ <div class="head-text">
+ <h2>鑳借�楁暟鎹噰闆�</h2>
+ <p>瀵规帴鏅鸿兘姘磋〃銆佺數琛ㄣ�佽捀姹借〃锛屾瘡鏃� 08:00 鑷姩褰掗泦姘淬�佺數銆佽捀姹界敤閲忥紱鎵嬪伐鎶勮〃璁惧璇峰湪銆岃〃鍏峰彴璐︺�嶅綍琛ㄣ��</p>
+ </div>
+ <div class="head-actions">
+ <el-button :loading="loading" @click="loadAll">鍒锋柊</el-button>
+ <el-button
+ type="primary"
+ :loading="collecting"
+ :disabled="!canCollectAny"
+ @click="handleCollectAll"
+ >
+ 绔嬪嵆閲囬泦鍏ㄩ儴
+ </el-button>
+ </div>
+ </div>
+
+ <el-alert
+ v-if="overview.mockMode"
+ class="mock-alert"
+ type="info"
+ :closable="false"
+ show-icon
+ title="褰撳墠涓烘紨绀烘暟鎹ā寮忥細鏈厤缃涓夋柟鎺堟潈鐮侊紝閲囬泦缁撴灉鐢辨湰鍦版ā鎷熺敓鎴愶紝浠呯敤浜庤仈璋冧笌椤甸潰婕旂ず銆�"
+ />
+
+ <div class="media-grid">
+ <div
+ v-for="item in mediaList"
+ :key="item.meterType"
+ class="media-card"
+ :class="'media-' + item.meterType.toLowerCase()"
+ >
+ <div class="media-head">
+ <span class="media-badge">{{ mediumShort(item.meterType) }}</span>
+ <div class="media-title">
+ <h3>{{ item.meterName }}</h3>
+ <span>{{ item.deviceCount }} 鍙拌澶� 路 {{ item.providerCount }} 鍙拌嚜鍔� / {{ item.manualCount }} 鍙版墜宸�</span>
+ </div>
+ </div>
+
+ <div class="media-metrics">
+ <div class="metric">
+ <span>宸插綊闆嗚澶�</span>
+ <b>{{ item.latestDayMeters }}<i>/{{ item.deviceCount }}</i></b>
+ </div>
+ <div class="metric">
+ <span>杩� 7 鏃ヨ鐩�</span>
+ <b>{{ formatRate(item.coverageRate) }}</b>
+ </div>
+ </div>
+
+ <div class="media-foot">
+ <span>鏈�杩戦噰闆嗭細{{ shortTime(item.lastSuccessAt) }}</span>
+ <span>鏁版嵁鎴嚦锛歿{ item.dataEnd || '--' }}</span>
+ </div>
+ </div>
+ </div>
+
+ <section class="panel">
+ <div class="panel-head">
+ <div class="panel-title">
+ 琛ㄥ叿閲囬泦鏄庣粏
+ <span class="panel-sub">{{ filteredDevices.length }} 鍙�</span>
+ </div>
+ <div class="filters">
+ <el-select v-model="filters.meterType" placeholder="鍏ㄩ儴浠嬭川" style="width: 120px" clearable>
+ <el-option label="姘磋〃" value="WATER" />
+ <el-option label="鐢佃〃" value="ELECTRIC" />
+ <el-option label="钂告苯琛�" value="GAS" />
+ </el-select>
+ <el-select v-model="filters.collectionMode" placeholder="鍏ㄩ儴閲囬泦鏂瑰紡" style="width: 140px" clearable>
+ <el-option label="鑷姩閲囬泦" value="AUTO" />
+ <el-option label="鎵嬪伐鎶勮〃" value="MANUAL" />
+ </el-select>
+ <el-input
+ v-model="filters.keyword"
+ placeholder="璁惧鍚嶇О / 琛ㄥ彿"
+ clearable
+ style="width: 200px"
+ @keyup.enter="handleQuery"
+ />
+ <el-button type="primary" @click="handleQuery">鏌ヨ</el-button>
+ <el-button @click="handleReset">閲嶇疆</el-button>
+ </div>
+ </div>
+
+ <el-table v-loading="loading" :data="pagedDevices" border stripe class="device-table">
+ <el-table-column label="璁惧鍚嶇О" min-width="180">
+ <template #default="{ row }">
+ <div class="device-name">
+ <b>{{ row.displayName || row.providerName || ('璁惧 #' + row.id) }}</b>
+ <span v-if="row.providerName && row.providerName !== row.displayName">{{ row.providerName }}</span>
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column label="琛ㄥ彿" min-width="150">
+ <template #default="{ row }">{{ row.meterAddress || '--' }}</template>
+ </el-table-column>
+ <el-table-column label="浠嬭川" width="88" align="center">
+ <template #default="{ row }">
+ <el-tag size="small" :type="mediumTagType(row.meterType)" effect="plain">
+ {{ mediumShort(row.meterType) }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column label="閲囬泦鏂瑰紡" width="110" align="center">
+ <template #default="{ row }">
+ {{ isAutoRow(row) ? '鑷姩閲囬泦' : '鎵嬪伐鎶勮〃' }}
+ </template>
+ </el-table-column>
+ <el-table-column label="鏈�杩戣〃鐮�" width="120" align="right">
+ <template #default="{ row }">
+ {{ formatNumber(row.latestReading) }}
+ </template>
+ </el-table-column>
+ <el-table-column label="鏈�杩戠敤閲�" width="150" align="right">
+ <template #default="{ row }">
+ <span class="usage-value">{{ formatNumber(row.lastDayUsage) }}</span>
+ <span class="usage-unit">{{ unitOf(row.meterType) }}</span>
+ <div v-if="row.lastDayUsageDate" class="usage-date">{{ row.lastDayUsageDate }}</div>
+ </template>
+ </el-table-column>
+ <el-table-column label="閲囬泦鐘舵��" width="120" align="center">
+ <template #default="{ row }">
+ <span :class="['state-dot', stateClass(row)]"></span>
+ {{ row.collectStateText || '灏氭湭閲囬泦' }}
+ </template>
+ </el-table-column>
+ <el-table-column label="鏈�杩戦噰闆嗘椂闂�" width="170">
+ <template #default="{ row }">{{ row.lastSuccessAt || row.lastTaskTime || '--' }}</template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" width="150" fixed="right" align="center">
+ <template #default="{ row }">
+ <el-button
+ v-if="isAutoRow(row)"
+ link
+ type="primary"
+ :loading="collectingId === row.id"
+ @click="handleCollect(row)"
+ >
+ 閲囬泦
+ </el-button>
+ <el-button link type="primary" @click="goMonitor(row)">鏌ョ湅鐩戞帶</el-button>
+ </template>
+ </el-table-column>
+ <template #empty>
+ <el-empty description="鏆傛棤琛ㄥ叿鏁版嵁" :image-size="60" />
+ </template>
+ </el-table>
+
+ <div class="pagination">
+ <el-pagination
+ v-model:current-page="page.current"
+ v-model:page-size="page.size"
+ :page-sizes="[10, 20, 50]"
+ :total="filteredDevices.length"
+ layout="total, sizes, prev, pager, next"
+ background
+ small
+ />
+ </div>
+ </section>
+
+ <section class="panel">
+ <div class="panel-head">
+ <div class="panel-title">鏈�杩戦噰闆嗘壒娆�</div>
+ <div class="panel-extra">
+ <span>澶辫触浠诲姟 <b class="danger">{{ overview.failedTaskCount || 0 }}</b></span>
+ <span>寰呮墽琛屼换鍔� <b>{{ overview.pendingTaskCount || 0 }}</b></span>
+ </div>
+ </div>
+ <el-table :data="overview.runs" border stripe size="small">
+ <el-table-column label="鎵规" min-width="180">
+ <template #default="{ row }">{{ row.runKey || ('鎵规 #' + row.id) }}</template>
+ </el-table-column>
+ <el-table-column label="绫诲瀷" width="100">
+ <template #default="{ row }">{{ row.triggerTypeName }}</template>
+ </el-table-column>
+ <el-table-column label="鍚屾鑼冨洿" width="200">
+ <template #default="{ row }">{{ row.rangeStart || '--' }} ~ {{ row.rangeEnd || '--' }}</template>
+ </el-table-column>
+ <el-table-column label="鐘舵��" width="100" align="center">
+ <template #default="{ row }">
+ <el-tag size="small" :type="runTagType(row.status)" effect="light">{{ row.statusText }}</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column label="鎴愬姛 / 绌� / 澶辫触 / 鎬绘暟" width="180" align="center">
+ <template #default="{ row }">
+ {{ row.successTasks }} / {{ row.emptyTasks }} / {{ row.failedTasks }} / {{ row.totalTasks }}
+ </template>
+ </el-table-column>
+ <el-table-column label="寮�濮嬫椂闂�" width="170">
+ <template #default="{ row }">{{ row.startedAt || '--' }}</template>
+ </el-table-column>
+ <el-table-column label="缁撴潫鏃堕棿" width="170">
+ <template #default="{ row }">{{ row.finishedAt || '--' }}</template>
+ </el-table-column>
+ <template #empty>
+ <el-empty description="鏆傛棤閲囬泦鎵规" :image-size="60" />
+ </template>
+ </el-table>
+ </section>
+ </div>
+</template>
+
+<script setup>
+import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
+import { useRouter } from 'vue-router'
+import dayjs from 'dayjs'
+import { ElMessage } from 'element-plus'
+import {
+ collectMeterDevice,
+ collectMeterDevices,
+ getEnergyCollectionOverview,
+ listMeterDevices,
+ simulateGasMeters
+} from '@/api/energyManagement/energyMeter'
+
+defineOptions({ name: 'EnergyDataCollection' })
+
+const router = useRouter()
+
+const UNIT_MAP = { WATER: 'm鲁', ELECTRIC: '搴�', GAS: 'm鲁' }
+const MEDIA_ORDER = { WATER: 0, ELECTRIC: 1, GAS: 2 }
+
+const loading = ref(false)
+const collecting = ref(false)
+const collectingId = ref(null)
+const overview = ref({ media: [], runs: [], mockMode: false })
+const devices = ref([])
+
+const filters = reactive({ meterType: '', collectionMode: '', keyword: '' })
+const applied = reactive({ meterType: '', collectionMode: '', keyword: '' })
+const page = reactive({ current: 1, size: 20 })
+
+let reloadTimer = null
+
+const mediaList = computed(() => [...(overview.value.media || [])]
+ .sort((a, b) => (MEDIA_ORDER[a.meterType] ?? 9) - (MEDIA_ORDER[b.meterType] ?? 9)))
+
+const filteredDevices = computed(() => devices.value
+ .filter((row) => {
+ if (applied.meterType && row.meterType !== applied.meterType) {
+ return false
+ }
+ const auto = isAutoRow(row)
+ if (applied.collectionMode === 'MANUAL' && auto) {
+ return false
+ }
+ if (applied.collectionMode === 'AUTO' && !auto) {
+ return false
+ }
+ if (applied.keyword) {
+ const keyword = applied.keyword.toLowerCase()
+ const text = [row.displayName, row.providerName, row.meterAddress].filter(Boolean).join(' ').toLowerCase()
+ if (!text.includes(keyword)) {
+ return false
+ }
+ }
+ return true
+ })
+ .sort((a, b) => (MEDIA_ORDER[a.meterType] ?? 9) - (MEDIA_ORDER[b.meterType] ?? 9)))
+
+const pagedDevices = computed(() => {
+ const start = (page.current - 1) * page.size
+ return filteredDevices.value.slice(start, start + page.size)
+})
+
+// 鍙湁鐪熸鐨勭涓夋柟鎺ュ叆璁惧璧扳�滄煡琛ㄢ�濇帴鍙�
+const collectableIds = computed(() => devices.value
+ .filter((row) => row.sourceType === 'PROVIDER' && row.enabled === 1)
+ .map((row) => row.id))
+
+// 钂告苯琛ㄦ紨绀鸿澶囨寜鑷姩閲囬泦澶勭悊锛氭墜鍔ㄥ埛鏂版椂閲嶆柊鐢熸垚鏄ㄥぉ鏁版嵁
+const gasSimulatedRows = computed(() => devices.value.filter((row) => isGasSimulated(row)))
+
+const canCollectAny = computed(() => collectableIds.value.length > 0 || gasSimulatedRows.value.length > 0)
+
+function isAutoRow(row) {
+ return row.sourceType === 'PROVIDER' || row.simulated === 1
+}
+
+function isGasSimulated(row) {
+ return row.simulated === 1 && row.meterType === 'GAS'
+}
+
+onMounted(loadAll)
+
+onBeforeUnmount(() => {
+ if (reloadTimer) {
+ clearTimeout(reloadTimer)
+ reloadTimer = null
+ }
+})
+
+async function loadAll() {
+ loading.value = true
+ try {
+ const [summary, devicePage] = await Promise.all([
+ getEnergyCollectionOverview(),
+ listMeterDevices({ current: 1, size: 500 })
+ ])
+ overview.value = summary.data || { media: [], runs: [] }
+ devices.value = (devicePage.data && devicePage.data.records) || []
+ } catch (e) {
+ overview.value = { media: [], runs: [], mockMode: false }
+ devices.value = []
+ } finally {
+ loading.value = false
+ }
+}
+
+function handleQuery() {
+ applied.meterType = filters.meterType
+ applied.collectionMode = filters.collectionMode
+ applied.keyword = filters.keyword.trim()
+ page.current = 1
+}
+
+function handleReset() {
+ filters.meterType = ''
+ filters.collectionMode = ''
+ filters.keyword = ''
+ handleQuery()
+}
+
+function collectPayload(ids) {
+ return {
+ meterIds: ids,
+ startDate: dayjs().subtract(3, 'day').format('YYYY-MM-DD'),
+ endDate: dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
+ includeReadings: true
+ }
+}
+
+async function handleCollectAll() {
+ const providerIds = collectableIds.value
+ const gasRows = gasSimulatedRows.value
+ if (!providerIds.length && !gasRows.length) {
+ ElMessage.warning('褰撳墠娌℃湁鍙嚜鍔ㄩ噰闆嗙殑琛ㄥ叿')
+ return
+ }
+ collecting.value = true
+ try {
+ const yesterday = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
+ if (gasRows.length) {
+ await simulateGasMeters(yesterday)
+ }
+ if (providerIds.length) {
+ await collectMeterDevices(collectPayload(providerIds))
+ }
+ const parts = []
+ if (providerIds.length) {
+ parts.push(`${providerIds.length} 鍙版按/鐢佃〃`)
+ }
+ if (gasRows.length) {
+ parts.push(`${gasRows.length} 鍙拌捀姹借〃`)
+ }
+ ElMessage.success(`宸茶Е鍙戣嚜鍔ㄩ噰闆嗭細${parts.join('銆�')}`)
+ scheduleReload()
+ } catch (e) {
+ // 閿欒鎻愮ず鐢辫姹傛嫤鎴櫒缁熶竴灞曠ず
+ } finally {
+ collecting.value = false
+ }
+}
+
+async function handleCollect(row) {
+ collectingId.value = row.id
+ const yesterday = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
+ try {
+ if (isGasSimulated(row)) {
+ // 钂告苯琛ㄦ紨绀鸿澶囷細鎸夊ぉ鑷姩鐢熸垚鏄ㄥぉ鐢ㄩ噺锛岄噸澶嶆墽琛屼笉浼氶噸澶嶅啓鍏�
+ await simulateGasMeters(yesterday)
+ ElMessage.success('钂告苯琛ㄦ暟鎹凡鍚屾锛堣嚜鍔ㄧ敓鎴愭槰鏃ョ敤閲忥級')
+ } else {
+ await collectMeterDevice(row.id, {
+ startDate: dayjs().subtract(3, 'day').format('YYYY-MM-DD'),
+ endDate: yesterday,
+ includeReadings: true
+ })
+ ElMessage.success(`銆�${row.displayName || row.meterAddress}銆嶉噰闆嗕换鍔″凡鎻愪氦`)
+ }
+ scheduleReload()
+ } catch (e) {
+ // 閿欒鎻愮ず鐢辫姹傛嫤鎴櫒缁熶竴灞曠ず
+ } finally {
+ collectingId.value = null
+ }
+}
+
+function scheduleReload() {
+ if (reloadTimer) {
+ clearTimeout(reloadTimer)
+ }
+ reloadTimer = setTimeout(() => {
+ loadAll()
+ reloadTimer = null
+ }, 4000)
+}
+
+function goMonitor(row) {
+ router.push({ path: '/energyManagement/realtimeMonitor', query: { meterId: row.id } })
+}
+
+function mediumShort(meterType) {
+ return { WATER: '姘�', ELECTRIC: '鐢�', GAS: '钂告苯' }[meterType] || meterType
+}
+
+function mediumTagType(meterType) {
+ return { WATER: 'primary', ELECTRIC: 'warning', GAS: 'success' }[meterType] || 'info'
+}
+
+function unitOf(meterType) {
+ return UNIT_MAP[meterType] || ''
+}
+
+function runTagType(status) {
+ if (status === 'SUCCESS') {
+ return 'success'
+ }
+ if (status === 'PARTIAL' || status === 'RUNNING') {
+ return 'warning'
+ }
+ if (status === 'FAILED') {
+ return 'danger'
+ }
+ return 'info'
+}
+
+function stateClass(row) {
+ if (row.simulated === 1) {
+ return 'is-ok'
+ }
+ if (row.lastTaskStatus === 'FAILED') {
+ return 'is-error'
+ }
+ if (row.sourceType === 'MANUAL') {
+ return 'is-manual'
+ }
+ if (row.lastTaskStatus === 'SUCCESS' || row.lastTaskStatus === 'EMPTY') {
+ return 'is-ok'
+ }
+ return 'is-idle'
+}
+
+function formatRate(value) {
+ if (value == null) {
+ return '--'
+ }
+ return `${Number(value).toFixed(1)}%`
+}
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num.toFixed(3).replace(/\.?0+$/, '')
+}
+
+function shortTime(value) {
+ if (!value) {
+ return '--'
+ }
+ return String(value).length > 16 ? String(value).slice(0, 16) : value
+}
+</script>
+
+<style lang="scss" scoped>
+.energy-collection {
+ padding-bottom: 24px;
+}
+
+.page-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+ margin-bottom: 14px;
+
+ h2 {
+ margin: 0 0 4px;
+ font-size: 18px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ p {
+ margin: 0;
+ font-size: 12px;
+ color: #909399;
+ }
+}
+
+.head-actions {
+ display: flex;
+ gap: 8px;
+}
+
+.mock-alert {
+ margin-bottom: 12px;
+}
+
+.media-grid {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 12px;
+
+ @media (max-width: 1100px) {
+ grid-template-columns: 1fr;
+ }
+}
+
+.media-card {
+ padding: 14px 16px 12px;
+ border: 1px solid #ebeef5;
+ border-top: 3px solid #409eff;
+ border-radius: 8px;
+ background: #fff;
+
+ &.media-water {
+ border-top-color: #409eff;
+ }
+
+ &.media-electric {
+ border-top-color: #e6a23c;
+ }
+
+ &.media-gas {
+ border-top-color: #21a675;
+ }
+}
+
+.media-head {
+ display: flex;
+ align-items: flex-start;
+ gap: 10px;
+}
+
+.media-badge {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 34px;
+ height: 34px;
+ flex: 0 0 34px;
+ border-radius: 9px;
+ background: #eef5ff;
+ color: #2f7fd8;
+ font-size: 15px;
+ font-weight: 600;
+
+ .media-electric & {
+ background: #fdf6ec;
+ color: #c98a24;
+ }
+
+ .media-gas & {
+ background: #ecf8f2;
+ color: #1d8f66;
+ }
+}
+
+.media-title {
+ flex: 1;
+ min-width: 0;
+
+ h3 {
+ margin: 0 0 3px;
+ font-size: 15px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ span {
+ font-size: 12px;
+ color: #909399;
+ }
+}
+
+.media-metrics {
+ display: flex;
+ gap: 8px;
+ margin: 14px 0 10px;
+
+ .metric {
+ flex: 1;
+ padding: 8px 10px;
+ border-radius: 6px;
+ background: #f7f9fc;
+
+ span {
+ display: block;
+ font-size: 12px;
+ color: #909399;
+ }
+
+ b {
+ font-size: 18px;
+ color: #303133;
+
+ i {
+ margin-left: 2px;
+ font-size: 12px;
+ font-style: normal;
+ font-weight: 400;
+ color: #a8abb2;
+ }
+ }
+ }
+}
+
+.media-foot {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: space-between;
+ gap: 6px;
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.panel {
+ padding: 14px 16px;
+ margin-top: 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 8px;
+ background: #fff;
+}
+
+.panel-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ margin-bottom: 12px;
+}
+
+.panel-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+}
+
+.panel-sub {
+ margin-left: 6px;
+ font-size: 12px;
+ font-weight: 400;
+ color: #a8abb2;
+}
+
+.filters {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.panel-extra {
+ display: flex;
+ gap: 16px;
+ font-size: 12px;
+ color: #909399;
+
+ b {
+ color: #303133;
+ }
+
+ .danger {
+ color: #f56c6c;
+ }
+}
+
+.device-name {
+ display: flex;
+ flex-direction: column;
+ line-height: 1.4;
+
+ b {
+ font-weight: 500;
+ color: #303133;
+ }
+
+ span {
+ font-size: 12px;
+ color: #a8abb2;
+ }
+}
+
+.usage-value {
+ font-weight: 600;
+ color: #303133;
+}
+
+.usage-unit {
+ margin-left: 3px;
+ font-size: 12px;
+ color: #909399;
+}
+
+.usage-date {
+ font-size: 11px;
+ color: #c0c4cc;
+}
+
+.state-dot {
+ display: inline-block;
+ width: 6px;
+ height: 6px;
+ margin-right: 5px;
+ border-radius: 50%;
+ vertical-align: middle;
+
+ &.is-ok {
+ background: #21a675;
+ }
+
+ &.is-error {
+ background: #f56c6c;
+ }
+
+ &.is-manual {
+ background: #909399;
+ }
+
+ &.is-idle {
+ background: #e6a23c;
+ }
+}
+
+.pagination {
+ display: flex;
+ justify-content: flex-end;
+ padding-top: 12px;
+}
+</style>
diff --git a/src/views/energyManagement/energyArea/index.vue b/src/views/energyManagement/energyArea/index.vue
deleted file mode 100644
index 63feff8..0000000
--- a/src/views/energyManagement/energyArea/index.vue
+++ /dev/null
@@ -1,511 +0,0 @@
-<template>
- <div class="app-container product-view">
- <div class="left">
- <div>
- <el-input
- v-model="search"
- style="width: 210px"
- placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
- @change="searchFilter"
- @clear="searchFilter"
- clearable
- prefix-icon="Search"
- />
- <el-button
- type="primary"
- @click="openProDia('addOne')"
- style="margin-left: 10px"
- >鏂板鐖跺尯鍩�</el-button
- >
- </div>
- <div ref="containerRef">
- <el-tree
- ref="tree"
- v-loading="treeLoad"
- :data="list"
- @node-click="handleNodeClick"
- :expand-on-click-node="false"
- default-expand-all
- :default-expanded-keys="expandedKeys"
- :draggable="true"
- :filter-node-method="filterNode"
- :props="{ children: 'children', label: 'label' }"
- highlight-current
- node-key="id"
- style="
- height: calc(100vh - 190px);
- overflow-y: scroll;
- scrollbar-width: none;
- margin-top: 10px;
- "
- >
- <template #default="{ node, data }">
- <div class="custom-tree-node">
- <span class="tree-node-content">
- <el-icon class="orange-icon">
- <component :is="data.children && data.children.length > 0
- ? node.expanded ? 'FolderOpened' : 'Folder' : 'Tickets'" />
- </el-icon>
- {{ data.label }}
- </span>
- <div>
- <el-button
- type="primary"
- link
- @click="openProDia('edit', data)"
- >
- 缂栬緫
- </el-button>
- <el-button type="primary" link @click="openModelDia('add','', data.id)">
- 娣诲姞瀛愬尯鍩�
- </el-button>
- <el-button
- v-if="!node.childNodes.length"
- style="margin-left: 4px"
- type="danger"
- link
- @click="remove(node, data)"
- >
- 鍒犻櫎
- </el-button>
- </div>
- </div>
- </template>
- </el-tree>
- </div>
- </div>
- <div class="right">
- <div style="margin-bottom: 10px" v-if="isShowButton">
- <el-button type="primary" @click="openModelDia('add')">
- 鏂板瀛愬尯鍩�
- </el-button>
- <el-button
- type="danger"
- @click="handleDelete"
- style="margin-left: 10px"
- plain
- >
- 鍒犻櫎
- </el-button>
- </div>
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
- <el-dialog v-model="productDia" title="鍖哄煙" width="400px" @keydown.enter.prevent>
- <el-form
- :model="form"
- label-width="140px"
- label-position="top"
- :rules="rules"
- ref="formRef"
- >
- <el-row :gutter="30">
- <el-col :span="24">
- <el-form-item label="鍖哄煙鍚嶇О锛�" prop="areaName">
- <el-input
- v-model="form.areaName"
- placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
- clearable
- @keydown.enter.prevent
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeProDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
- <el-dialog
- v-model="modelDia"
- title="瀛愬尯鍩�"
- width="400px"
- @close="closeModelDia"
- @keydown.enter.prevent
- >
- <el-form
- :model="modelForm"
- label-width="140px"
- label-position="top"
- :rules="modelRules"
- ref="modelFormRef"
- >
- <el-form-item label="鐖跺尯鍩燂細" prop="fuId">
- <el-cascader v-model="modelForm.fuId" :options="list" :props="{
- value: 'id',
- label: 'label',
- children: 'children',
- checkStrictly: true,
- }" />
- </el-form-item>
- <el-form-item label="鍖哄煙绫诲瀷锛�" prop="areaType">
- <el-select v-model="modelForm.areaType" placeholder="璇烽�夋嫨">
- <el-option v-for="item in area_type" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- <el-form-item label="鍖哄煙鍚嶇О锛�" prop="areaName">
- <el-input
- v-model="modelForm.areaName"
- placeholder="璇疯緭鍏ュ崟浣�"
- clearable
- @keydown.enter.prevent
- />
- </el-form-item>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitModelForm">纭</el-button>
- <el-button @click="closeModelDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
-</template>
-
-<script setup>
-import { ref } from "vue";
-import { ElMessageBox } from "element-plus";
-import {
- areaAdd,
- areaDelete,
- areaListPage,
- areaListTree,
-} from "@/api/energyManagement/index.js";
-
-const { proxy } = getCurrentInstance();
-const tree = ref(null);
-const containerRef = ref(null);
-
-const productDia = ref(false);
-const modelDia = ref(false);
-const modelOperationType = ref("");
-const search = ref("");
-const currentId = ref("");
-const currentParentId = ref("");
-const operationType = ref("");
-const treeLoad = ref(false);
-const list = ref([]);
-const expandedKeys = ref([]);
-const {area_type} = proxy.useDict("area_type")
-const tableColumn = ref([
- {
- label: "鍖哄煙鍚嶇О",
- prop: "areaName",
- },
- {
- label: "鍖哄煙绫诲瀷",
- prop: "areaType",
- dataType: "tag",
- formatData: (row) => {
- return area_type.value.find(item => item.value == row)?.label;
- }
- },
- {
- dataType: "action",
- label: "鎿嶄綔",
- align: "center",
- operation: [
- {
- name: "缂栬緫",
- type: "text",
- clickFun: (row) => {
- openModelDia("edit", row);
- },
- },
- ],
- },
-]);
-const tableData = ref([]);
-const tableLoading = ref(false);
-const isShowButton = ref(false);
-const selectedRows = ref([]);
-const page = reactive({
- current: 1,
- size: 10,
- total: 0,
-});
-const data = reactive({
- form: {
- areaName: "",
- },
- rules: {
- areaName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- },
- modelForm: {
- areaName: "",
- fuId: "",
- },
- modelRules: {
- areaName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- fuId: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
- },
-});
-const { form, rules, modelForm, modelRules } = toRefs(data);
-
-// 鏌ヨ浜у搧鏍�
-const getProductTreeList = () => {
- treeLoad.value = true;
- areaListTree()
- .then((res) => {
- list.value = res;
- list.value.forEach((a) => {
- expandedKeys.value.push(a.label);
- });
- treeLoad.value = false;
- })
- .catch((err) => {
- treeLoad.value = false;
- });
-};
-// 杩囨护浜у搧鏍�
-const searchFilter = () => {
- proxy.$refs.tree.filter(search.value);
-};
-// 鎵撳紑浜у搧寮规
-const openProDia = (type, data) => {
- operationType.value = type;
- productDia.value = true;
- form.value.areaName = "";
- if (type === "edit") {
- form.value.areaName = data.areaName;
- }
-};
-// 鎵撳紑瑙勬牸鍨嬪彿寮规
-const openModelDia = (type, data,fatherId) => {
- modelOperationType.value = type;
- modelDia.value = true;
- modelForm.value.fuId = "";
- modelForm.value.areaType = "";
- modelForm.value.areaName = "";
- modelForm.value.id = "";
- modelForm.value.fuId = fatherId;
- if (type === "edit") {
- modelForm.value = { ...data };
- }
-};
-// 鎻愪氦浜у搧鍚嶇О淇敼
-const submitForm = () => {
- proxy.$refs.formRef.validate((valid) => {
- if (valid) {
- if (operationType.value === "add") {
- form.value.parentId = currentId.value;
- form.value.id = "";
- } else if (operationType.value === "addOne") {
- form.value.id = "";
- form.value.parentId = "";
- } else {
- form.value.id = currentId.value;
- form.value.parentId = "";
- }
- areaAdd(form.value).then((res) => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeProDia();
- getProductTreeList();
- });
- }
- });
-};
-// 鍏抽棴浜у搧寮规
-const closeProDia = () => {
- proxy.$refs.formRef.resetFields();
- productDia.value = false;
-};
-
-// 鍒犻櫎浜у搧
-const remove = (node, data) => {
- let ids = [];
- ids.push(data.id);
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- tableLoading.value = true;
- areaDelete(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getProductTreeList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-// 閫夋嫨浜у搧
-const handleNodeClick = (val, node, el) => {
- // 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�
- isShowButton.value = !(val.children && val.children.length > 0);
- // 鍙湁鍙跺瓙鑺傜偣鎵嶆墽琛屼互涓嬮�昏緫
- currentId.value = val.id;
- currentParentId.value = val.parentId;
- getModelList(true);
-};
-
-// 鎻愪氦瑙勬牸鍨嬪彿淇敼
-const submitModelForm = () => {
- proxy.$refs.modelFormRef.validate((valid) => {
- if (valid) {
- modelForm.value.fuId = currentId.value;
- areaAdd(modelForm.value).then((res) => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeModelDia();
- getModelList();
- getProductTreeList();
- });
- }
- });
-};
-// 鍏抽棴鍨嬪彿寮规
-const closeModelDia = () => {
- proxy.$refs.modelFormRef.resetFields();
- modelDia.value = false;
-};
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-
-// 鏌ヨ瑙勬牸鍨嬪彿
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getModelList();
-};
-const getModelList = (val = false) => {
- tableLoading.value = true;
- let obj = {
- id: currentId.value,
- fuId:currentId.value,
- current: page.current,
- size: page.size
- }
- if(val){
- delete obj.id;
- }else{
- delete obj.fuId
- }
- areaListPage(obj).then((res) => {
- console.log("res", res);
- tableData.value = res.data.records;
- page.total = res.data.total;
- tableLoading.value = false;
- });
-};
-// 鍒犻櫎瑙勬牸鍨嬪彿
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- tableLoading.value = true;
- areaDelete(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getModelList();
- getProductTreeList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-// 璋冪敤tree杩囨护鏂规硶 涓枃鑻辫繃婊�
-const filterNode = (value, data, node) => {
- if (!value) {
- //濡傛灉鏁版嵁涓虹┖锛屽垯杩斿洖true,鏄剧ず鎵�鏈夌殑鏁版嵁椤�
- return true;
- }
- // 鏌ヨ鍒楄〃鏄惁鏈夊尮閰嶆暟鎹紝灏嗗�煎皬鍐欙紝鍖归厤鑻辨枃鏁版嵁
- let val = value.toLowerCase();
- return chooseNode(val, data, node); // 璋冪敤杩囨护浜屽眰鏂规硶
-};
-// 杩囨护鐖惰妭鐐� / 瀛愯妭鐐� (濡傛灉杈撳叆鐨勫弬鏁版槸鐖惰妭鐐逛笖鑳藉尮閰嶏紝鍒欒繑鍥炶鑺傜偣浠ュ強鍏朵笅鐨勬墍鏈夊瓙鑺傜偣锛涘鏋滃弬鏁版槸瀛愯妭鐐癸紝鍒欒繑鍥炶鑺傜偣鐨勭埗鑺傜偣銆俷ame鏄腑鏂囧瓧绗︼紝enName鏄嫳鏂囧瓧绗�.
-const chooseNode = (value, data, node) => {
- if (data.label.indexOf(value) !== -1) {
- return true;
- }
- const level = node.level;
- // 濡傛灉浼犲叆鐨勮妭鐐规湰韬氨鏄竴绾ц妭鐐瑰氨涓嶇敤鏍¢獙浜�
- if (level === 1) {
- return false;
- }
- // 鍏堝彇褰撳墠鑺傜偣鐨勭埗鑺傜偣
- let parentData = node.parent;
- // 閬嶅巻褰撳墠鑺傜偣鐨勭埗鑺傜偣
- let index = 0;
- while (index < level - 1) {
- // 濡傛灉鍖归厤鍒扮洿鎺ヨ繑鍥烇紝姝ゅname鍊兼槸涓枃瀛楃锛宔nName鏄嫳鏂囧瓧绗︺�傚垽鏂尮閰嶄腑鑻辨枃杩囨护
- if (parentData.data.label.indexOf(value) !== -1) {
- return true;
- }
- // 鍚﹀垯鐨勮瘽鍐嶅線涓婁竴灞傚仛鍖归厤
- parentData = parentData.parent;
- index++;
- }
- // 娌″尮閰嶅埌杩斿洖false
- return false;
-};
-getProductTreeList();
-</script>
-
-<style scoped>
-.product-view {
- display: flex;
-}
-.left {
- width: 380px;
- padding: 16px;
- background: #ffffff;
-}
-.right {
- width: calc(100% - 380px);
- padding: 16px;
- margin-left: 20px;
- background: #ffffff;
-}
-.custom-tree-node {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: 14px;
- padding-right: 8px;
-}
-.tree-node-content {
- display: flex;
- align-items: center; /* 鍨傜洿灞呬腑 */
- height: 100%;
-}
-.orange-icon {
- color: orange;
- font-size: 18px;
- margin-right: 8px; /* 鍥炬爣涓庢枃瀛椾箣闂村姞鐐归棿璺� */
-}
-</style>
diff --git a/src/views/energyManagement/energyPeriodTime/index.vue b/src/views/energyManagement/energyPeriodTime/index.vue
deleted file mode 100644
index 49bb226..0000000
--- a/src/views/energyManagement/energyPeriodTime/index.vue
+++ /dev/null
@@ -1,462 +0,0 @@
-<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">鏃ユ湡锛�</span>
- <!-- <el-time-picker
- style="width: 240px;margin-right: 10px"
- v-model="searchForm.startTime"
- value-format="HH:mm:ss"
- format="HH:mm:ss"
- type="time"
- placeholder="璇烽�夋嫨寮�濮嬫椂闂�"
- clearable
- /> -->
- <el-date-picker
- v-model="searchForm.date"
- type="date"
- placeholder="璇烽�夋嫨鏃ユ湡"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- />
- <!-- <el-time-picker
- v-model="searchForm.timeRange"
- is-range
- arrow-control
- range-separator="To"
- start-placeholder="閫夋嫨缁撴潫鏃堕棿"
- end-placeholder="閫夋嫨缁撴潫鏃堕棿"
- /> -->
- <span class="search_title">鐢典环锛堝厓/搴︼級锛�</span>
- <el-input
- v-model="searchForm.price"
- style="width: 240px"
- placeholder="璇疯緭鍏ョ數浠�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button>
- <el-button @click="resetFilters">閲嶇疆</el-button>
- </div>
- <div>
- <el-button type="primary" @click="openForm('add')">鏂板</el-button>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
- </div>
- </div>
- <div class="table_list">
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
- <el-dialog
- v-model="dialogFormVisible"
- title="鐢ㄧ數鏃舵绠$悊"
- width="70%"
- @close="closeDia"
- >
- <el-form
- :model="form"
- label-width="140px"
- label-position="top"
- :rules="rules"
- ref="formRef"
- >
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="鏃ユ湡锛�" prop="date">
- <el-date-picker
- style="width: 100%"
- v-model="form.date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨鏃ユ湡"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鐢典环锛堝厓/搴︼級锛�" prop="price">
- <el-input
- v-model="form.price"
- placeholder="璇疯緭鍏ョ數浠�"
- clearable
- type="number"
- step="0.01"
- min="0"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="宄版锛�" prop="peak">
- <el-input
- v-model="form.peak"
- placeholder="璇疯緭鍏ュ嘲娈�"
- clearable
- type="number"
- step="0.01"
- min="0"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="璋锋锛�" prop="valley">
- <el-input
- v-model="form.valley"
- placeholder="璇疯緭鍏ヨ胺娈�"
- clearable
- type="number"
- step="0.01"
- min="0"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="骞虫锛�" prop="flat">
- <el-input
- v-model="form.flat"
- placeholder="璇疯緭鍏ュ钩娈�"
- clearable
- type="number"
- step="0.01"
- min="0"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="灏栨锛�" prop="sharp">
- <el-input
- v-model="form.sharp"
- placeholder="璇疯緭鍏ュ皷娈�"
- clearable
- type="number"
- step="0.01"
- min="0"
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
-</template>
-<script setup>
-import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref, getCurrentInstance} from "vue";
-import {ElMessageBox} from "element-plus";
-import {getToken} from "@/utils/auth.js";
-import {periodListPage,periodDelete,periodAdd,periodUpdate} from "@/api/energyManagement/index.js";
-const { proxy } = getCurrentInstance();
-
-const data = reactive({
- searchForm: {
- date: "",
- price: ""
- },
- form: {
- date: "",
- price: "",
- peak: "",
- valley: "",
- flat: "",
- sharp: ""
- }
-});
-const { searchForm,form } = toRefs(data);
-const page = ref({
- current: 1,
- size: 100,
- total: 0
-});
-const dialogFormVisible = ref(false);
-const selectedRows = ref([]);
-const operationType = ref('');
-const tableData = ref([]);
-const emit = defineEmits(['close'])
-const tableLoading = ref(false);
-const tableColumn = ref([
- // {
- // label: "鏃舵鍚嶇О",
- // prop: "timeName",
- // width: 200,
- // },
- {
- label: "鏃ユ湡",
- prop: "date",
- width: 200,
- },
- {
- label: "鐢典环锛堝厓/搴︼級",
- prop: "price",
- width: 200,
- },
- {
- label: "宄版",
- prop: "peak",
- },
- {
- label: "璋锋",
- prop: "valley",
- },
- {
- label: "骞虫",
- prop: "flat",
- },
- {
- label: "灏栨",
- prop: "sharp",
- },
- {
- dataType: "action",
- label: "鎿嶄綔",
- align: "center",
- fixed: 'right',
- operation: [
- {
- name: "缂栬緫",
- type: "text",
- clickFun: (row) => {
- openForm("edit", row);
- },
- },
- ],
- },
-]);
-
-
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-const formDia = ref()
-const upload = reactive({
- // 鏄惁鏄剧ず寮瑰嚭灞傦紙瀹㈡埛瀵煎叆锛�
- open: false,
- // 寮瑰嚭灞傛爣棰橈紙瀹㈡埛瀵煎叆锛�
- title: "",
- // 鏄惁绂佺敤涓婁紶
- isUploading: false,
- // 璁剧疆涓婁紶鐨勮姹傚ご閮�
- headers: { Authorization: "Bearer " + getToken() },
- // 涓婁紶鐨勫湴鍧�
- url: import.meta.env.VITE_APP_BASE_API + "/equipmentEnergyConsumption/importData",
- // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
- beforeUpload: (file) => {
- console.log('鏂囦欢鍗冲皢涓婁紶', file);
- // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠�
- const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls');
- if (!isValid) {
- proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢");
- }
- return isValid;
- },
- // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋�
- onChange: (file, fileList) => {
- console.log('鏂囦欢鐘舵�佹敼鍙�', file, fileList);
- },
- // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟
- onSuccess: (response, file, fileList) => {
- console.log('涓婁紶鎴愬姛', response, file, fileList);
- if(response.code === 200){
- proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
- }else if(response.code === 500){
- ElMessageBox.error(response.msg);
- }else{
- ElMessageBox.warning(response.msg);
- }
- },
- // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟
- onError: (error, file, fileList) => {
- console.error('涓婁紶澶辫触', error, file, fileList);
- ElMessageBox.error("鏂囦欢涓婁紶澶辫触");
- },
- // 鏂囦欢涓婁紶杩涘害鍥炶皟
- onProgress: (event, file, fileList) => {
- console.log('涓婁紶涓�...', event.percent);
- }
-});
-
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-//閲嶇疆
-const resetFilters = () => {
- searchForm.value = {
- date: "",
- price: ""
- };
- getList();
-
-};
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-const getList = () => {
- tableLoading.value = true;
- periodListPage({ ...searchForm.value, ...page.value }).then((res) => {
- tableLoading.value = false;
- if (res && res.data) {
- tableData.value = res.data.records || [];
- page.value.total = res.data.total || 0;
- } else {
- tableData.value = [];
- page.value.total = 0;
- ElMessageBox.warning('鏈幏鍙栧埌鏁版嵁');
- }
- })
- .catch((err) => {
- tableLoading.value = false;
- console.error('鏁版嵁鍔犺浇澶辫触:', err);
- ElMessageBox.error('鏁版嵁鍔犺浇澶辫触锛岃閲嶈瘯');
- });
-};
-// 鎵撳紑寮规
-const openDialog = (type, row) => {
- operationType.value = type;
- dialogFormVisible.value = true;
- // form.value.maintainer = userStore.nickName;
- // form.value.maintenanceTime = getCurrentDate();
- form.value = {}
- proxy.resetForm("formRef");
- periodListPage().then((res) => {
- codeList.value = res.data;
- });
- if (type === "edit") {
- form.value = {...row}
- }
-}
-// 鎵撳紑寮规
-const openForm = (type, row) => {
- openDialog(type, row)
-};
-// 鎻愪氦琛ㄥ崟
-const submitForm = () => {
- proxy.$refs["formRef"].validate(valid => {
- if (valid) {
- if (operationType.value === "add") {
- periodAdd(form.value).then(response => {
- proxy.$modal.msgSuccess("鏂板鎴愬姛")
- closeDia()
- getList()
- })
- } else {
- periodUpdate(form.value).then(response => {
- proxy.$modal.msgSuccess("淇敼鎴愬姛")
- closeDia()
- getList()
- })
- }
- }
- })
-}
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- dialogFormVisible.value = false;
- emit('close')
-};
-/** 瀵煎叆鎸夐挳鎿嶄綔 */
-function handleImport() {
- upload.title = "璁惧鑳借��";
- upload.open = true;
- // 娓呯┖涓婃涓婁紶鐨勬枃浠跺垪琛�
- nextTick(() => {
- proxy.$refs["uploadRef"]?.clearFiles();
- });
-}
-function importTemplate() {
- proxy.download(
- "/equipmentEnergyConsumption/export",
- {},
- '璁惧鑳借�楀鍏ユā鐗�.xlsx'
- );
-}
-/** 鎻愪氦涓婁紶鏂囦欢 */
-function submitFileForm() {
- proxy.$refs["uploadRef"].submit();
-}
-
-/** 寮规鍏抽棴鏃舵竻绌烘枃浠跺垪琛� */
-function handleDialogClose() {
- nextTick(() => {
- proxy.$refs["uploadRef"]?.clearFiles();
- });
-}
-
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- tableLoading.value = true;
- periodDelete(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- proxy.download("/energyPeriod/export", {}, "鐢ㄧ數鏃舵绠$悊.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-onMounted(() => {
- getList();
-});
-</script>
-
-<style scoped>
-
-</style>
diff --git a/src/views/energyManagement/energyPower/components/formDia.vue b/src/views/energyManagement/energyPower/components/formDia.vue
deleted file mode 100644
index 3cb4455..0000000
--- a/src/views/energyManagement/energyPower/components/formDia.vue
+++ /dev/null
@@ -1,228 +0,0 @@
-<template>
- <div>
- <el-dialog
- v-model="dialogFormVisible"
- title="璁惧鑳借��"
- width="70%"
- @close="closeDia"
- >
- <el-form
- :model="form"
- label-width="140px"
- label-position="top"
- :rules="rules"
- ref="formRef"
- >
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="璁惧锛�" prop="code">
- <el-select
- v-model="form.code"
- placeholder="璇烽�夋嫨"
- clearable
- @change="setName"
- :disabled="operationType !== 'add'"
- >
- <el-option
- v-for="item in codeList"
- :key="item.deviceModel"
- :label="item.deviceName"
- :value="item.deviceModel"
- >
- {{item.deviceName + '--' + item.deviceModel}}
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鐢ㄧ數娑堣�楀尯鍩燂細" prop="electricityConsumptionAreaId">
- <el-cascader
- v-model="form.electricityConsumptionAreaId"
- :options="areaList"
- :props="{
- value: 'id',
- label: 'label',
- children: 'children',
- checkStrictly: true,
- }"
- placeholder="璇烽�夋嫨鍖哄煙"
- clearable
- style="width: 100%"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="姣忔棩闄愬埗鐢甸噺锛�" prop="everyNum">
- <el-input
- v-model="form.everyNum"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="棰濆畾鍔熺巼锛�" prop="powerRating">
- <el-input
- v-model="form.powerRating"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="瀹為檯鍔熺巼锛�" prop="powerActual">
- <el-input
- v-model="form.powerActual"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="杩愯鏃堕棿锛�" prop="runDate">
- <el-date-picker
- style="width: 100%"
- v-model="form.runDate"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="褰撴棩鐢ㄧ數閲忥細" prop="dayNum">
- <el-input
- v-model="form.dayNum"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
-</template>
-
-<script setup>
-import {ref} from "vue";
-import useUserStore from "@/store/modules/user.js";
-import {deviceList, equipmentEnergyAdd, equipmentEnergyUpdate, areaListTree} from "@/api/energyManagement/index.js";
-import { getCurrentDate } from "@/utils/index.js";
-const { proxy } = getCurrentInstance()
-const emit = defineEmits(['close'])
-const dialogFormVisible = ref(false);
-const operationType = ref('')
-const userStore = useUserStore();
-
-const data = reactive({
- form: {
- name: "",
- code: "",
- everyNum: "",
- powerRating: "",
- powerActual: "",
- runDate: "",
- dayNum: "",
- electricityConsumptionAreaId: "",
- },
- rules: {
- code: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- runDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- everyNum: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- powerRating: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- powerActual: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- dayNum: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- electricityConsumptionAreaId: [{ required: true, message: "璇烽�夋嫨鍖哄煙", trigger: "change" }],
- },
-})
-const { form, rules } = toRefs(data);
-const codeList = ref([])
-const areaList = ref([])
-
-// 鎵撳紑寮规
-const openDialog = (type, row) => {
- operationType.value = type;
- dialogFormVisible.value = true;
- // form.value.maintainer = userStore.nickName;
- // form.value.maintenanceTime = getCurrentDate();
- form.value = {}
- proxy.resetForm("formRef");
-
- // 鑾峰彇璁惧鍒楄〃
- deviceList().then((res) => {
- codeList.value = res.data;
- });
-
- // 鑾峰彇鍖哄煙鍒楄〃
- areaListTree().then((res) => {
- areaList.value = res;
- console.log("areaList", res);
- });
-
- if (type === "edit") {
- form.value = {...row}
- // 缂栬緫鏃讹紝灏嗗崟涓狪D杞崲涓烘暟缁勬牸寮忕敤浜庡洖鏄�
- if (row.electricityConsumptionAreaId) {
- form.value.electricityConsumptionAreaId = [row.electricityConsumptionAreaId];
- }
- }
-}
-const setName = (code) => {
- const index = codeList.value.findIndex(item => item.deviceModel === code);
- if (index > -1) {
- console.log(codeList)
- form.value.name = codeList.value[index].deviceName;
- }
-}
-const submitForm = () => {
- proxy.$refs["formRef"].validate(valid => {
- if (valid) {
- // 鎻愪氦鍓嶅鐞� electricityConsumptionAreaId锛屽彇鏁扮粍鐨勬渶鍚庝竴涓��
- const submitData = { ...form.value };
- if (Array.isArray(submitData.electricityConsumptionAreaId) && submitData.electricityConsumptionAreaId.length > 0) {
- submitData.electricityConsumptionAreaId = submitData.electricityConsumptionAreaId[submitData.electricityConsumptionAreaId.length - 1];
- }
-
- if (operationType.value === "add") {
- equipmentEnergyAdd(submitData).then(response => {
- proxy.$modal.msgSuccess("鏂板鎴愬姛")
- closeDia()
- })
- } else {
- equipmentEnergyUpdate(submitData).then(response => {
- proxy.$modal.msgSuccess("淇敼鎴愬姛")
- closeDia()
- })
- }
- }
- })
-}
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- dialogFormVisible.value = false;
- emit('close')
-};
-defineExpose({
- openDialog,
-});
-</script>
-
-<style scoped>
-
-</style>
\ No newline at end of file
diff --git a/src/views/energyManagement/energyPower/index.vue b/src/views/energyManagement/energyPower/index.vue
deleted file mode 100644
index 6311019..0000000
--- a/src/views/energyManagement/energyPower/index.vue
+++ /dev/null
@@ -1,322 +0,0 @@
-<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">璁惧鍚嶇О锛�</span>
- <el-input
- v-model="searchForm.name"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button
- >
- </div>
- <div>
- <el-button type="primary" @click="openForm('add')">鏂板</el-button>
- <el-button type="info" plain icon="Upload" @click="handleImport">瀵煎叆</el-button>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
- </div>
- </div>
- <div class="table_list">
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
- <form-dia ref="formDia" @close="handleQuery"></form-dia>
- <el-dialog
- :title="upload.title"
- v-model="upload.open"
- width="400px"
- append-to-body
- @close="handleDialogClose"
- >
- <el-upload
- ref="uploadRef"
- :limit="1"
- accept=".xlsx, .xls"
- :headers="upload.headers"
- :action="upload.url"
- :disabled="upload.isUploading"
- :before-upload="upload.beforeUpload"
- :on-progress="upload.onProgress"
- :on-success="upload.onSuccess"
- :on-error="upload.onError"
- :on-change="upload.onChange"
- :auto-upload="false"
- drag
- >
- <el-icon class="el-icon--upload"><upload-filled /></el-icon>
- <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
- <template #tip>
- <div class="el-upload__tip text-center">
- <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
- <el-link
- type="primary"
- :underline="false"
- style="font-size: 12px; vertical-align: baseline"
- @click="importTemplate"
- >涓嬭浇妯℃澘</el-link
- >
- </div>
- </template>
- </el-upload>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
- <el-button @click="upload.open = false">鍙� 娑�</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
-</template>
-
-<script setup>
-import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref, getCurrentInstance} from "vue";
-import FormDia from "@/views/energyManagement/energyPower/components/formDia.vue";
-import {ElMessageBox} from "element-plus";
-import {getToken} from "@/utils/auth.js";
-import {equipmentEnergyDelete, equipmentEnergyListPage} from "@/api/energyManagement/index.js";
-const { proxy } = getCurrentInstance();
-
-const data = reactive({
- searchForm: {
- name: "",
- },
-});
-const { searchForm } = toRefs(data);
-
-const selectedRows = ref([]);
-const tableColumn = ref([
- {
- label: "璁惧鍚嶇О",
- prop: "name",
- width: 200,
- },
- {
- label: "瑙勬牸鍨嬪彿",
- prop: "code",
- width: 200,
- },
- {
- label: "棰濆畾鍔熺巼",
- prop: "powerRating",
- },
- {
- label: "瀹為檯鍔熺巼",
- prop: "powerActual",
- },
- {
- label: "杩愯鏃堕棿",
- prop: "runDate",
- width:150
- },
- {
- label: "褰撴棩鐢ㄧ數閲�",
- prop: "dayNum",
- width: 150,
- },
- // {
- // label: "绱鐢ㄧ數閲�",
- // prop: "sumNum",
- // width: 150,
- // },
- {
- label: "姣忔棩闄愬埗鐢甸噺",
- prop: "everyNum",
- width:220
- },
- {
- dataType: "action",
- label: "鎿嶄綔",
- align: "center",
- fixed: 'right',
- operation: [
- {
- name: "缂栬緫",
- type: "text",
- clickFun: (row) => {
- openForm("edit", row);
- },
- },
- ],
- },
-]);
-const tableData = ref([]);
-const tableLoading = ref(false);
-const page = reactive({
- current: 1,
- size: 100,
- total: 0,
-});
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-const formDia = ref()
-const upload = reactive({
- // 鏄惁鏄剧ず寮瑰嚭灞傦紙瀹㈡埛瀵煎叆锛�
- open: false,
- // 寮瑰嚭灞傛爣棰橈紙瀹㈡埛瀵煎叆锛�
- title: "",
- // 鏄惁绂佺敤涓婁紶
- isUploading: false,
- // 璁剧疆涓婁紶鐨勮姹傚ご閮�
- headers: { Authorization: "Bearer " + getToken() },
- // 涓婁紶鐨勫湴鍧�
- url: import.meta.env.VITE_APP_BASE_API + "/equipmentEnergyConsumption/importData",
- // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
- beforeUpload: (file) => {
- console.log('鏂囦欢鍗冲皢涓婁紶', file);
- // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠�
- const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls');
- if (!isValid) {
- proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢");
- }
- return isValid;
- },
- // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋�
- onChange: (file, fileList) => {
- console.log('鏂囦欢鐘舵�佹敼鍙�', file, fileList);
- },
- // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟
- onSuccess: (response, file, fileList) => {
- console.log('涓婁紶鎴愬姛', response, file, fileList);
- if(response.code === 200){
- proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
- }else if(response.code === 500){
- proxy.$modal.msgError(response.msg);
- }else{
- proxy.$modal.msgWarning(response.msg);
- }
- },
- // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟
- onError: (error, file, fileList) => {
- console.error('涓婁紶澶辫触', error, file, fileList);
- proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
- },
- // 鏂囦欢涓婁紶杩涘害鍥炶皟
- onProgress: (event, file, fileList) => {
- console.log('涓婁紶涓�...', event.percent);
- }
-});
-
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-const getList = () => {
- tableLoading.value = true;
- equipmentEnergyListPage({ ...searchForm.value, ...page }).then((res) => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- page.total = res.data.total;
- });
-};
-
-// 鎵撳紑寮规
-const openForm = (type, row) => {
- nextTick(() => {
- formDia.value?.openDialog(type, row)
- })
-};
-
-/** 瀵煎叆鎸夐挳鎿嶄綔 */
-function handleImport() {
- upload.title = "璁惧鑳借��";
- upload.open = true;
- // 娓呯┖涓婃涓婁紶鐨勬枃浠跺垪琛�
- nextTick(() => {
- proxy.$refs["uploadRef"]?.clearFiles();
- });
-}
-function importTemplate() {
- proxy.download(
- "/equipmentEnergyConsumption/export",
- {},
- '璁惧鑳借�楀鍏ユā鐗�.xlsx'
- );
-}
-/** 鎻愪氦涓婁紶鏂囦欢 */
-function submitFileForm() {
- proxy.$refs["uploadRef"].submit();
-}
-
-/** 寮规鍏抽棴鏃舵竻绌烘枃浠跺垪琛� */
-function handleDialogClose() {
- nextTick(() => {
- proxy.$refs["uploadRef"]?.clearFiles();
- });
-}
-
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- tableLoading.value = true;
- equipmentEnergyDelete(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- proxy.download("/equipmentEnergyConsumption/export", {}, "鑳芥簮鍔熺巼.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-onMounted(() => {
- getList();
-});
-</script>
-
-<style scoped>
-
-</style>
\ No newline at end of file
diff --git a/src/views/energyManagement/energyTrends/index.vue b/src/views/energyManagement/energyTrends/index.vue
deleted file mode 100644
index 7f67be7..0000000
--- a/src/views/energyManagement/energyTrends/index.vue
+++ /dev/null
@@ -1,137 +0,0 @@
-<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">璁惧鍚嶇О锛�</span>
- <el-input
- v-model="searchForm.name"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button
- >
- <el-button @click="handleOut" style="margin-left: 10px">瀵煎嚭</el-button>
- </div>
- </div>
- <div class="table_list">
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
-
- </div>
-</template>
-
-<script setup>
-import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref, getCurrentInstance} from "vue";
-import {listPageByTrend} from "@/api/energyManagement/index.js";
-import { ElMessageBox } from "element-plus";
-
-const { proxy } = getCurrentInstance();
-
-const data = reactive({
- searchForm: {
- name: "",
- },
-});
-const { searchForm } = toRefs(data);
-
-const tableColumn = ref([
- {
- label: "璁惧鍚嶇О",
- prop: "name",
- width: 220,
- },
- {
- label: "瑙勬牸鍨嬪彿",
- prop: "code",
- width: 220,
- },
- {
- label: "杩愯鏃堕棿",
- prop: "runDate",
- width: 250,
- },
- {
- label: "鏄ㄦ棩鐢ㄧ數閲�",
- prop: "toDayNum",
- },
- {
- label: "鏈湀骞冲潎鐢甸噺",
- prop: "avgNum",
- width:150
- },
- {
- label: "瓒嬪娍",
- prop: "trend",
- width: 220,
- },
-]);
-const tableData = ref([]);
-const selectedRows = ref([]);
-const tableLoading = ref(false);
-const page = reactive({
- current: 1,
- size: 100,
- total: 0,
-});
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-const getList = () => {
- tableLoading.value = true;
- listPageByTrend({ ...searchForm.value, ...page }).then((res) => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- page.total = res.data.total;
- });
-};
-
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- proxy.download("/equipmentEnergyConsumption/exportTwo", {}, "鑳芥簮瓒嬪娍.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-onMounted(() => {
- getList();
-});
-</script>
-
-<style scoped>
-
-</style>
\ No newline at end of file
diff --git a/src/views/energyManagement/meterData/components/MeterOverview.vue b/src/views/energyManagement/meterData/components/MeterOverview.vue
new file mode 100644
index 0000000..ad7d07e
--- /dev/null
+++ b/src/views/energyManagement/meterData/components/MeterOverview.vue
@@ -0,0 +1,786 @@
+<template>
+ <div class="meter-overview">
+ <!-- 椤堕儴宸ュ叿鏍� -->
+ <el-card shadow="never" class="toolbar-card">
+ <div class="toolbar">
+ <div class="toolbar-item">
+ <span class="label">璁惧鑼冨洿</span>
+ <el-select v-model="query.scope" style="width: 130px" @change="handleScopeChange">
+ <el-option label="鍏ㄩ儴璁惧" value="ALL" />
+ <el-option label="鍗曞彴璁惧" value="SINGLE" />
+ </el-select>
+ </div>
+ <div v-if="query.scope === 'SINGLE'" class="toolbar-item">
+ <el-select
+ v-model="query.meterId"
+ filterable
+ clearable
+ placeholder="鎼滅储璁惧鍚嶇О/琛ㄥ彿"
+ style="width: 260px"
+ @change="loadOverview"
+ >
+ <el-option
+ v-for="item in deviceOptions"
+ :key="item.id"
+ :label="optionLabel(item)"
+ :value="item.id"
+ />
+ </el-select>
+ </div>
+ <div class="toolbar-item meta">
+ 鏁版嵁鎴嚦 <b>{{ overview.dataThrough || '--' }}</b>
+ <span class="dot">路</span>
+ 鏈�杩戦噰闆� <b>{{ overview.lastSuccessAt || '--' }}</b>
+ <span class="dot">路</span>
+ {{ overview.scopeLabel || '--' }}
+ </div>
+ <div class="toolbar-actions">
+ <el-button type="primary" @click="loadAll">鏌ヨ</el-button>
+ <el-button v-if="canRefresh" :loading="refreshing" @click="handleRefreshData">鍒锋柊鏁版嵁</el-button>
+ </div>
+ </div>
+ </el-card>
+
+ <el-alert
+ v-if="overview.mockMode"
+ class="mock-alert"
+ type="info"
+ :closable="false"
+ show-icon
+ title="褰撳墠涓烘紨绀烘暟鎹ā寮忥細鏈厤缃涓夋柟鎺堟潈鐮侊紝鏌ヨ〃缁撴灉鐢辨湰鍦版ā鎷熺敓鎴愶紝浠呯敤浜庤仈璋冧笌椤甸潰婕旂ず銆�"
+ />
+
+ <!-- 椤堕儴涓ゅ潡锛氭湰鏈堢疮璁� / 鏈勾绱 -->
+ <el-row :gutter="12" class="top-row">
+ <el-col :xs="24" :lg="12">
+ <div class="panel">
+ <div class="panel-head">
+ <div>
+ <div class="panel-title">鏈湀绱{{ usageName }}閲�</div>
+ <div class="panel-range">{{ monthRangeText }}</div>
+ </div>
+ </div>
+ <div class="big-value">
+ <span class="big-number">{{ overview.monthHasData ? formatNumber(overview.monthTotal) : '--' }}</span>
+ <span class="big-unit">{{ unit }}</span>
+ </div>
+ <div ref="monthCompareRef" class="chart chart-sm"></div>
+ </div>
+ </el-col>
+ <el-col :xs="24" :lg="12">
+ <div class="panel">
+ <div class="panel-head">
+ <div>
+ <div class="panel-title">鏈勾绱{{ usageName }}閲�</div>
+ <div class="panel-range">{{ yearRangeText }}</div>
+ </div>
+ </div>
+ <div class="big-value">
+ <span class="big-number">{{ overview.yearHasData ? formatNumber(overview.yearTotal) : '--' }}</span>
+ <span class="big-unit">{{ unit }}</span>
+ </div>
+ <div ref="yearCompareRef" class="chart chart-sm"></div>
+ </div>
+ </el-col>
+ </el-row>
+
+ <!-- 鏈堝害鐢ㄦ按鏁版嵁 -->
+ <div class="panel">
+ <div class="panel-head">
+ <div class="panel-title">鏈堝害{{ usageName }}鏁版嵁</div>
+ <div class="panel-tools">
+ <span class="label">鏃堕棿锛�</span>
+ <el-date-picker
+ v-model="query.month"
+ type="month"
+ value-format="YYYY-MM"
+ :clearable="false"
+ style="width: 140px"
+ @change="handleMonthChange"
+ />
+ </div>
+ </div>
+ <div class="summary-row">
+ <span class="summary-item">
+ 褰撴湀鎬粄{ usageName }}閲�
+ <b>{{ overview.monthHasData ? formatNumber(overview.monthTotal) : '--' }}{{ unit }}</b>
+ </span>
+ <span class="summary-item">
+ 涓婃湀鎬粄{ usageName }}閲�
+ <b>{{ previousMonthTotal == null ? '--' : formatNumber(previousMonthTotal) + unit }}</b>
+ </span>
+ </div>
+ <div ref="monthDailyRef" class="chart chart-md"></div>
+ </div>
+
+ <!-- 骞村害鐢ㄦ按鏁版嵁 -->
+ <div class="panel">
+ <div class="panel-head">
+ <div class="panel-title">骞村害{{ usageName }}鏁版嵁</div>
+ <div class="panel-tools">
+ <span class="label">鏃堕棿锛�</span>
+ <el-date-picker
+ v-model="query.year"
+ type="year"
+ value-format="YYYY"
+ :clearable="false"
+ style="width: 110px"
+ @change="handleYearChange"
+ />
+ </div>
+ </div>
+ <div class="summary-row">
+ <span class="summary-item">
+ 鏈勾鎬粄{ usageName }}閲�
+ <b>{{ overview.yearHasData ? formatNumber(overview.yearTotal) : '--' }}{{ unit }}</b>
+ </span>
+ <span class="summary-item">
+ 鍘诲勾鎬粄{ usageName }}閲�
+ <b>{{ previousYearTotal == null ? '--' : formatNumber(previousYearTotal) + unit }}</b>
+ </span>
+ </div>
+ <div ref="yearDailyRef" class="chart chart-md"></div>
+ </div>
+
+ <el-empty
+ v-if="overviewReady && !overview.deviceCount"
+ class="empty-tip"
+ :description="`褰撳墠杩樻病鏈�${typeName}璁惧锛岃鍏堝埌琛ㄥ叿鍙拌处鏂板`"
+ :image-size="70"
+ />
+ </div>
+</template>
+
+<script setup>
+import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
+import { useRoute } from 'vue-router'
+import * as echarts from 'echarts'
+import dayjs from 'dayjs'
+import { ElMessage } from 'element-plus'
+import {
+ collectMeterDevices,
+ getMeterOverview,
+ listMeterDeviceOptions
+} from '@/api/energyManagement/energyMeter'
+
+const props = defineProps({
+ meterType: {
+ type: String,
+ required: true
+ }
+})
+
+defineOptions({ name: 'MeterOverview' })
+
+const route = useRoute()
+
+const unitFallback = { WATER: 'm鲁', ELECTRIC: '搴�', GAS: 'm鲁' }
+const usageNameMap = { WATER: '鐢ㄦ按', ELECTRIC: '鐢ㄧ數', GAS: '鐢ㄦ皵' }
+const COLOR_PREVIOUS = '#2f5f96'
+const COLOR_CURRENT = '#f08c2e'
+
+const query = reactive({
+ scope: 'ALL',
+ meterId: null,
+ month: dayjs().format('YYYY-MM'),
+ year: dayjs().format('YYYY')
+})
+
+const overview = ref({})
+const overviewReady = ref(false)
+const deviceOptions = ref([])
+const unit = ref(unitFallback[props.meterType] || 'm鲁')
+const refreshing = ref(false)
+
+const monthCompareRef = ref(null)
+const yearCompareRef = ref(null)
+const monthDailyRef = ref(null)
+const yearDailyRef = ref(null)
+const charts = {}
+
+let reloadTimer = null
+
+// 璺敱甯﹀叆鐨勮澶嘔D锛堜粠琛ㄥ叿鍙拌处鈥滄煡鐪嬫暟鎹�濊烦杞�屾潵锛�
+const requestedMeterId = ref(route.query.meterId ? Number(route.query.meterId) : null)
+
+const typeName = computed(() => {
+ const map = { WATER: '姘磋〃', ELECTRIC: '鐢佃〃', GAS: '姘旇〃' }
+ return map[props.meterType] || '璁惧'
+})
+
+// 姣忎釜鏁版嵁椤靛彧澶勭悊鑷繁璺敱涓婄殑 meterId锛岄伩鍏嶉〉绛剧紦瀛樺悗浜掔浉涓茬被鍨�
+const dataPathMap = {
+ WATER: '/energyManagement/waterMeterData',
+ ELECTRIC: '/energyManagement/electricMeterData',
+ GAS: '/energyManagement/gasMeterData'
+}
+const dataPath = computed(() => dataPathMap[props.meterType] || '')
+
+const usageName = computed(() => usageNameMap[props.meterType] || '鐢ㄩ噺')
+
+const monthRangeText = computed(() => {
+ const month = overview.value.selectedMonth || query.month
+ const days = dayjs(`${month}-01`).daysInMonth()
+ return `${month}-01 鑷� ${month}-${String(days).padStart(2, '0')}`
+})
+
+const yearRangeText = computed(() => {
+ const year = overview.value.selectedYear || query.year
+ return `${year}-01 鑷� ${year}-12`
+})
+
+// 涓婃湀/鍘诲勾鍏ㄧ▼鍚堣锛氭帴鍙h繑鍥炵殑鏄�愭棩/閫愭湀鍚屽彛寰勬暟鎹紝杩欓噷鐩存帴绱姞
+const previousMonthTotal = computed(() => sumValues(overview.value.monthSeries, 'previous'))
+const previousYearTotal = computed(() => sumValues(overview.value.yearSeries, 'previous'))
+
+// 鍙湁绗笁鏂规帴鍏ヨ澶囨敮鎸佹煡琛紝鎵嬪伐鎶勮〃璁惧鏌ュ埌浼氭姤閿�
+const refreshableIds = computed(() => {
+ const providerIds = deviceOptions.value
+ .filter((item) => item.sourceType === 'PROVIDER')
+ .map((item) => item.id)
+ if (query.scope === 'SINGLE' && query.meterId) {
+ return providerIds.filter((id) => id === query.meterId)
+ }
+ return providerIds
+})
+
+const canRefresh = computed(() => refreshableIds.value.length > 0)
+
+// 璺敱 query 涓殑璁惧鍙兘涓嶅湪鍚敤璁惧涓嬫媺閲岋紙渚嬪宸插仠鐢級锛岃ˉ涓�鏉″崰浣嶉」
+function ensureMeterOption(id) {
+ if (!id || deviceOptions.value.some((item) => item.id === id)) {
+ return
+ }
+ deviceOptions.value = [{ id, displayName: `璁惧 #${id}`, meterAddress: '' }, ...deviceOptions.value]
+}
+
+function applyRequestedMeter(id) {
+ // 缂撳瓨鐨勯潪褰撳墠椤电涔熶細鏀跺埌鍏ㄥ眬 query 鍙樺寲锛岃繖閲屽繀椤绘寜璺敱璺緞鎷︽埅
+ if (!id || route.path !== dataPath.value) {
+ return
+ }
+ requestedMeterId.value = id
+ query.scope = 'SINGLE'
+ query.meterId = id
+ ensureMeterOption(id)
+ loadOverview()
+}
+
+onMounted(() => {
+ if (requestedMeterId.value && route.path === dataPath.value) {
+ query.scope = 'SINGLE'
+ query.meterId = requestedMeterId.value
+ }
+ loadOptions()
+ loadOverview()
+ window.addEventListener('resize', handleResize)
+})
+
+// 鍚屼竴鏁版嵁椤靛湪璺敱 query 鍙樺寲鏃跺悓姝ヨ澶囪寖鍥�
+watch(
+ () => route.query.meterId,
+ (value) => {
+ if (value && route.path === dataPath.value) {
+ applyRequestedMeter(Number(value))
+ }
+ }
+)
+
+onBeforeUnmount(() => {
+ window.removeEventListener('resize', handleResize)
+ if (reloadTimer) {
+ clearTimeout(reloadTimer)
+ reloadTimer = null
+ }
+ Object.keys(charts).forEach((key) => {
+ charts[key] && charts[key].dispose()
+ delete charts[key]
+ })
+})
+
+function handleResize() {
+ Object.keys(charts).forEach((key) => charts[key] && charts[key].resize())
+}
+
+function loadAll() {
+ loadOptions()
+ loadOverview()
+}
+
+async function loadOptions() {
+ try {
+ const res = await listMeterDeviceOptions({ meterType: props.meterType })
+ deviceOptions.value = res.data || []
+ ensureMeterOption(requestedMeterId.value)
+ if (query.scope === 'SINGLE' && !query.meterId && deviceOptions.value.length) {
+ query.meterId = deviceOptions.value[0].id
+ }
+ } catch (e) {
+ deviceOptions.value = []
+ }
+}
+
+async function loadOverview() {
+ const params = {
+ meterType: props.meterType,
+ month: query.month,
+ year: Number(query.year)
+ }
+ if (query.scope === 'SINGLE' && query.meterId) {
+ params.meterId = query.meterId
+ }
+ try {
+ const res = await getMeterOverview(params)
+ overview.value = res.data || {}
+ const apiUnit = overview.value.unit
+ // 搴撻噷浠嶆寜 kWh 瀛樺偍锛岄〉闈㈢粺涓�鏄剧ず涓衡�滃害鈥�
+ unit.value = apiUnit === 'kWh' ? '搴�' : (apiUnit === 'm3' ? 'm鲁' : apiUnit || unitFallback[props.meterType] || 'm鲁')
+ await nextTick()
+ renderAll()
+ } catch (e) {
+ overview.value = {}
+ } finally {
+ overviewReady.value = true
+ }
+}
+
+function handleScopeChange(value) {
+ if (value === 'ALL') {
+ query.meterId = null
+ } else if (!query.meterId && deviceOptions.value.length) {
+ query.meterId = deviceOptions.value[0].id
+ }
+ loadOverview()
+}
+
+function handleMonthChange(value) {
+ if (value) {
+ query.year = value.slice(0, 4)
+ }
+ loadOverview()
+}
+
+function handleYearChange(value) {
+ if (value) {
+ const monthPart = (query.month || dayjs().format('YYYY-MM')).slice(5, 7)
+ query.month = `${value}-${monthPart}`
+ }
+ loadOverview()
+}
+
+// 鍒锋柊鏁版嵁 = 瑙﹀彂绗笁鏂规煡琛紝鎵嬪伐鎶勮〃璁惧涓嶅弬涓�
+async function handleRefreshData() {
+ const meterIds = refreshableIds.value
+ if (!meterIds.length) {
+ ElMessage.warning('褰撳墠鑼冨洿娌℃湁鍙煡琛ㄧ殑绗笁鏂规帴鍏ヨ澶�')
+ return
+ }
+ refreshing.value = true
+ try {
+ await collectMeterDevices({
+ meterIds,
+ startDate: dayjs().subtract(3, 'day').format('YYYY-MM-DD'),
+ endDate: dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
+ includeReadings: true
+ })
+ ElMessage.success('鏌ヨ〃浠诲姟宸叉彁浜わ紝姝e湪鍚庡彴閲囬泦')
+ if (reloadTimer) {
+ clearTimeout(reloadTimer)
+ }
+ reloadTimer = setTimeout(() => {
+ loadOverview()
+ loadOptions()
+ }, 4000)
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ } finally {
+ refreshing.value = false
+ }
+}
+
+function optionLabel(item) {
+ if (!item.meterAddress) {
+ return item.displayName
+ }
+ return `${item.displayName}锛�${item.meterAddress}锛塦
+}
+
+/* ------------------------------ 鍥捐〃 ------------------------------ */
+
+function initChart(refEl, key) {
+ if (!refEl) {
+ return null
+ }
+ if (!charts[key]) {
+ charts[key] = echarts.init(refEl)
+ }
+ return charts[key]
+}
+
+function baseGrid() {
+ return { left: 46, right: 12, top: 30, bottom: 26, containLabel: false }
+}
+
+function axisY() {
+ return {
+ type: 'value',
+ name: unit.value,
+ nameTextStyle: { fontSize: 11, color: '#909399' },
+ axisLabel: { fontSize: 11, color: '#909399' },
+ splitLine: { lineStyle: { type: 'dashed', color: '#ebeef5' } }
+ }
+}
+
+function tooltipFormatter(params) {
+ const list = Array.isArray(params) ? params : [params]
+ const head = list.length ? list[0].axisValueLabel : ''
+ const rows = list
+ .map((item) => {
+ const value = item.value == null ? '鏆傛棤鏁版嵁' : `${formatNumber(item.value)} ${unit.value}`
+ return `${item.marker}${item.seriesName}锛�${value}`
+ })
+ .join('<br/>')
+ return `${head}<br/>${rows}`
+}
+
+function barSeries(name, data, color) {
+ return {
+ name,
+ type: 'bar',
+ barMaxWidth: 14,
+ barGap: '10%',
+ data,
+ itemStyle: { color, borderRadius: [2, 2, 0, 0] }
+ }
+}
+
+function renderAll() {
+ renderMonthCompare()
+ renderYearCompare()
+ renderMonthDaily()
+ renderYearDaily()
+}
+
+// 鏈湀 vs 涓婃湀锛堟寜鏃ワ級
+function renderMonthCompare() {
+ const chart = initChart(monthCompareRef.value, 'monthCompare')
+ if (!chart) {
+ return
+ }
+ const series = overview.value.monthSeries || []
+ chart.setOption(
+ {
+ tooltip: { trigger: 'axis', formatter: tooltipFormatter },
+ legend: {
+ data: [`涓婃湀${usageName.value}閲廯, `鏈湀${usageName.value}閲廯],
+ top: 0,
+ right: 8,
+ itemWidth: 10,
+ itemHeight: 8,
+ textStyle: { fontSize: 11, color: '#606266' }
+ },
+ grid: baseGrid(),
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => String(Number(item.day ? item.day.slice(8) : 0))),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: { fontSize: 10, color: '#909399', interval: series.length > 22 ? 1 : 0 }
+ },
+ yAxis: axisY(),
+ series: [
+ barSeries(`涓婃湀${usageName.value}閲廯, series.map((item) => item.previous), COLOR_PREVIOUS),
+ barSeries(`鏈湀${usageName.value}閲廯, series.map((item) => item.current), COLOR_CURRENT)
+ ],
+ graphic: overview.value.monthHasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+// 鏈勾 vs 鍘诲勾锛堟寜鏈堬級
+function renderYearCompare() {
+ const chart = initChart(yearCompareRef.value, 'yearCompare')
+ if (!chart) {
+ return
+ }
+ const series = overview.value.yearSeries || []
+ chart.setOption(
+ {
+ tooltip: { trigger: 'axis', formatter: tooltipFormatter },
+ legend: {
+ data: [`鍘诲勾${usageName.value}閲廯, `鏈勾${usageName.value}閲廯],
+ top: 0,
+ right: 8,
+ itemWidth: 10,
+ itemHeight: 8,
+ textStyle: { fontSize: 11, color: '#606266' }
+ },
+ grid: baseGrid(),
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => String(Number(item.month ? item.month.slice(5) : 0))),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: { fontSize: 10, color: '#909399' }
+ },
+ yAxis: axisY(),
+ series: [
+ barSeries(`鍘诲勾${usageName.value}閲廯, series.map((item) => item.previous), COLOR_PREVIOUS),
+ barSeries(`鏈勾${usageName.value}閲廯, series.map((item) => item.current), COLOR_CURRENT)
+ ],
+ graphic: overview.value.yearHasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+// 鏈堝害锛氬綋鏈堟瘡鏃�
+function renderMonthDaily() {
+ const chart = initChart(monthDailyRef.value, 'monthDaily')
+ if (!chart) {
+ return
+ }
+ const series = overview.value.monthSeries || []
+ chart.setOption(
+ {
+ tooltip: { trigger: 'axis', formatter: tooltipFormatter },
+ legend: {
+ data: [`${usageName.value}閲廯],
+ top: 0,
+ right: 8,
+ itemWidth: 10,
+ itemHeight: 8,
+ textStyle: { fontSize: 11, color: '#606266' }
+ },
+ grid: { ...baseGrid(), top: 26 },
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => String(Number(item.day ? item.day.slice(8) : 0)).padStart(2, '0')),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: { fontSize: 10, color: '#909399', interval: series.length > 22 ? 1 : 0 }
+ },
+ yAxis: axisY(),
+ series: [barSeries(`${usageName.value}閲廯, series.map((item) => item.current), COLOR_CURRENT)],
+ graphic: overview.value.monthHasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+// 骞村害锛氬綋骞存瘡鏈�
+function renderYearDaily() {
+ const chart = initChart(yearDailyRef.value, 'yearDaily')
+ if (!chart) {
+ return
+ }
+ const series = overview.value.yearSeries || []
+ chart.setOption(
+ {
+ tooltip: { trigger: 'axis', formatter: tooltipFormatter },
+ legend: {
+ data: [`${usageName.value}閲廯],
+ top: 0,
+ right: 8,
+ itemWidth: 10,
+ itemHeight: 8,
+ textStyle: { fontSize: 11, color: '#606266' }
+ },
+ grid: { ...baseGrid(), top: 26 },
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => (item.month ? `${item.month.slice(5)}鏈坄 : '')),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: { fontSize: 11, color: '#909399' }
+ },
+ yAxis: axisY(),
+ series: [barSeries(`${usageName.value}閲廯, series.map((item) => item.current), COLOR_CURRENT)],
+ graphic: overview.value.yearHasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+function emptyGraphic() {
+ return [{ type: 'text', left: 'center', top: 'middle', style: { text: '鏆傛棤鏁版嵁', fill: '#c0c4cc', fontSize: 14 } }]
+}
+
+/* ------------------------------ 宸ュ叿 ------------------------------ */
+
+function sumValues(series, key) {
+ if (!Array.isArray(series) || !series.length) {
+ return null
+ }
+ let sum = 0
+ let hasValue = false
+ series.forEach((item) => {
+ const value = item ? item[key] : null
+ if (value != null && value !== '') {
+ sum += Number(value)
+ hasValue = true
+ }
+ })
+ return hasValue ? sum : null
+}
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num.toFixed(3).replace(/\.?0+$/, '')
+}
+</script>
+
+<style lang="scss" scoped>
+.meter-overview {
+ padding-bottom: 8px;
+}
+
+.toolbar-card {
+ margin-bottom: 12px;
+
+ :deep(.el-card__body) {
+ padding: 10px 14px;
+ }
+}
+
+.toolbar {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 12px 18px;
+}
+
+.toolbar-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 13px;
+ color: #606266;
+}
+
+.toolbar-item .label {
+ white-space: nowrap;
+}
+
+.toolbar-item.meta {
+ color: #909399;
+ font-size: 12px;
+}
+
+.toolbar-item.meta b {
+ color: #303133;
+ font-weight: 500;
+}
+
+.dot {
+ color: #dcdfe6;
+}
+
+.toolbar-actions {
+ display: flex;
+ gap: 8px;
+ margin-left: auto;
+}
+
+.mock-alert {
+ margin-bottom: 12px;
+}
+
+.top-row {
+ margin-bottom: 0;
+}
+
+.panel {
+ padding: 14px 16px 8px;
+ margin-bottom: 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 8px;
+ background: #fff;
+}
+
+.panel-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+}
+
+.panel-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+}
+
+.panel-range {
+ margin-top: 2px;
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.panel-tools {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 13px;
+ color: #606266;
+}
+
+.big-value {
+ margin: 6px 0 0;
+}
+
+.big-number {
+ font-size: 24px;
+ font-weight: 600;
+ color: #303133;
+ line-height: 1.2;
+}
+
+.big-unit {
+ margin-left: 4px;
+ font-size: 13px;
+ color: #909399;
+}
+
+.summary-row {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 40px;
+ padding: 10px 4px 6px;
+ font-size: 13px;
+ color: #606266;
+}
+
+.summary-item b {
+ margin-left: 6px;
+ font-weight: 600;
+ color: #303133;
+}
+
+.chart {
+ width: 100%;
+}
+
+.chart-sm {
+ height: 200px;
+}
+
+.chart-md {
+ height: 210px;
+}
+
+.empty-tip {
+ padding: 16px 0;
+}
+</style>
diff --git a/src/views/energyManagement/meterData/electric/index.vue b/src/views/energyManagement/meterData/electric/index.vue
new file mode 100644
index 0000000..3f72209
--- /dev/null
+++ b/src/views/energyManagement/meterData/electric/index.vue
@@ -0,0 +1,1298 @@
+<template>
+ <div class="app-container electric-page">
+ <div class="page-head">
+ <div class="page-title">
+ <h2>鐢佃〃鏁版嵁</h2>
+ <span class="page-desc">浠婃棩鏇茬嚎鍜岀數鑳借川閲忓湪鎵撳紑椤甸潰鏃跺疄鏃舵煡璇紙鍚庣缂撳瓨 2 鍒嗛挓锛夛紱鏈湀绱鍜屾棩鐢ㄩ噺鏉ヨ嚜姣忓ぉ 08:00 鐨勫悓姝ヤ换鍔°��</span>
+ </div>
+ <div class="page-filters">
+ <el-select v-model="query.scope" style="width: 120px" @change="handleScopeChange">
+ <el-option label="鍏ㄩ儴璁惧" value="ALL" />
+ <el-option label="鍗曞彴璁惧" value="SINGLE" />
+ </el-select>
+ <el-select
+ v-if="query.scope === 'SINGLE'"
+ v-model="query.meterId"
+ filterable
+ clearable
+ placeholder="鎼滅储璁惧鍚嶇О/琛ㄥ彿"
+ style="width: 250px"
+ @change="loadAll"
+ >
+ <el-option
+ v-for="item in deviceOptions"
+ :key="item.id"
+ :label="optionLabel(item)"
+ :value="item.id"
+ />
+ </el-select>
+ <el-date-picker
+ v-model="query.month"
+ type="month"
+ value-format="YYYY-MM"
+ :clearable="false"
+ style="width: 135px"
+ @change="handleMonthChange"
+ />
+ <el-button type="primary" :loading="loading" @click="loadAll">鏌ヨ</el-button>
+ <el-button v-if="canRefresh" :loading="refreshing" @click="handleRefreshData">鍒锋柊鏁版嵁</el-button>
+ </div>
+ </div>
+
+ <div class="status-line">
+ <span>鏁版嵁鎴嚦 <b>{{ dataThroughText }}</b></span>
+ <span class="dot">路</span>
+ <span>鏈�杩戦噰闆� <b>{{ overview.lastSuccessAt || '--' }}</b></span>
+ <span class="dot">路</span>
+ <span>{{ overview.scopeLabel || '--' }}</span>
+ </div>
+
+ <el-alert
+ v-if="overview.mockMode"
+ class="mock-alert"
+ type="info"
+ :closable="false"
+ show-icon
+ title="褰撳墠涓烘紨绀烘暟鎹ā寮忥細鏈厤缃涓夋柟鎺堟潈鐮侊紝鏌ヨ〃缁撴灉鐢辨湰鍦版ā鎷熺敓鎴愶紝浠呯敤浜庤仈璋冧笌椤甸潰婕旂ず銆�"
+ />
+
+ <!-- 椤堕儴锛氫粖鏃ョ疮璁� / 鏈湀绱 -->
+ <div class="top-grid">
+ <section class="panel today-panel" v-loading="dashboardLoading">
+ <header class="panel-head">
+ <div class="head-left">
+ <h3>浠婃棩绱鐢ㄧ數</h3>
+ <span class="panel-range">{{ today.rangeStart || '00:00' }} 鑷� {{ today.rangeEnd || '--' }}</span>
+ </div>
+ <div class="panel-legend">
+ <span><i class="dot-previous"></i>鏄ㄦ棩鐢ㄧ數閲�</span>
+ <span><i class="dot-today"></i>浠婃棩鐢ㄧ數閲�</span>
+ </div>
+ </header>
+ <div class="metric-line">
+ <span class="metric-value">{{ formatNumber(today.total) }}</span>
+ <span class="metric-unit">搴�</span>
+ </div>
+ <div class="compare-line">
+ <span>
+ 杈冩槰鏃ュ悓鏃舵
+ <em :class="todayCompare.cls">{{ todayCompare.text }}</em>
+ </span>
+ <span class="sep"></span>
+ <span>鏄ㄦ棩鍚屾椂娈电疮绉敤鐢甸噺锛�<b>{{ formatValueUnit(today.yesterdaySamePeriodTotal, '搴�') }}</b></span>
+ </div>
+ <div ref="todayChartRef" class="chart chart-today"></div>
+ </section>
+
+ <section class="panel month-panel" v-loading="overviewLoading">
+ <header class="panel-head">
+ <div class="head-left">
+ <h3>鏈湀绱鐢ㄧ數</h3>
+ <span class="panel-range">{{ monthRangeText }}</span>
+ </div>
+ <div class="panel-legend">
+ <span><i class="dot-previous-soft"></i>涓婃湀鍚屾湡</span>
+ <span><i class="dot-today"></i>鏈湀鐢ㄧ數閲�</span>
+ </div>
+ </header>
+ <div class="metric-line">
+ <span class="metric-value">{{ formatNumber(monthTotal) }}</span>
+ <span class="metric-unit">搴�</span>
+ </div>
+ <div class="compare-line">
+ <span>
+ 杈冧笂鏈堝悓鏈�
+ <em :class="monthCompare.cls">{{ monthCompare.text }}</em>
+ </span>
+ <span class="sep"></span>
+ <span>涓婃湀鍚屾湡绱Н鐢ㄧ數閲忥細<b>{{ formatValueUnit(monthPreviousTotal, '搴�') }}</b></span>
+ </div>
+ <div ref="monthChartRef" class="chart chart-month"></div>
+ </section>
+ </div>
+
+ <!-- 鐢ㄧ數鏁版嵁 -->
+ <section class="panel usage-panel" v-loading="overviewLoading">
+ <header class="panel-head">
+ <div class="head-left">
+ <h3>鐢ㄧ數鏁版嵁</h3>
+ <div class="tabs">
+ <button
+ v-for="tab in usageTabs"
+ :key="tab.value"
+ type="button"
+ :class="{ active: usageTab === tab.value }"
+ @click="switchUsageTab(tab.value)"
+ >
+ {{ tab.label }}
+ </button>
+ </div>
+ </div>
+ <span class="panel-range">{{ monthRangeText }} 路 宸查噰闆� {{ collectedDayCount }} 澶�</span>
+ </header>
+ <div ref="usageChartRef" class="chart chart-usage"></div>
+ <div v-if="collectedDayCount > 0 && collectedDayCount <= 2" class="panel-note">
+ 褰撳墠鍙噰闆嗗埌 {{ collectedDayCount }} 澶╂暟鎹紝瓒嬪娍鍥句細闅忔瘡鏃� 08:00 鍚屾閫愭瀹屾暣銆�
+ </div>
+ </section>
+
+ <!-- 鐢佃兘璐ㄩ噺 -->
+ <section class="panel quality-panel" v-loading="dashboardLoading">
+ <header class="panel-head">
+ <div class="head-left">
+ <h3>鐢佃兘璐ㄩ噺</h3>
+ <el-tooltip placement="top" effect="dark" raw-content :content="qualityTooltip">
+ <span class="info-dot">?</span>
+ </el-tooltip>
+ <div class="tabs">
+ <button type="button" :class="{ active: weekOffset === 0 }" @click="switchWeek(0)">杩戜竴鍛�</button>
+ <button type="button" :class="{ active: weekOffset === 1 }" @click="switchWeek(1)">涓婁竴鍛�</button>
+ </div>
+ </div>
+ <span class="panel-range">{{ qualityRangeText }}</span>
+ </header>
+
+ <div class="quality-summary">
+ <div class="quality-stat">
+ <span class="stat-label">鏈夊姛鍔熺巼</span>
+ <span class="stat-value">{{ formatNumber(latestQuality.activePower) }}<i>kW</i></span>
+ </div>
+ <div class="quality-stat">
+ <span class="stat-label">鏃犲姛鍔熺巼</span>
+ <span class="stat-value">{{ formatNumber(latestQuality.reactivePower) }}<i>kvar</i></span>
+ </div>
+ <div class="quality-stat">
+ <span class="stat-label">鍔熺巼鍥犳暟</span>
+ <span class="stat-value">
+ {{ powerFactorText }}
+ <em v-if="powerFactorLevel" :class="powerFactorLevel.cls">{{ powerFactorLevel.text }}</em>
+ </span>
+ </div>
+ <span class="quality-time">{{ latestQuality.time ? '鏈�杩戞暟鎹� ' + latestQuality.time : '鏆傛棤鏁版嵁' }}</span>
+ </div>
+
+ <div v-if="qualityHasData" ref="qualityChartRef" class="chart chart-quality"></div>
+ <div v-else class="quality-empty">
+ 鎵�閫夊懆鏆傛棤 15 鍒嗛挓鏁版嵁锛岃秼鍔垮浘浼氬湪鏈夋暟鎹悗鑷姩灞曠ず
+ </div>
+ </section>
+
+ <el-empty
+ v-if="overviewReady && !overview.deviceCount"
+ class="empty-tip"
+ description="褰撳墠杩樻病鏈夌數琛ㄨ澶囷紝璇峰厛鍒拌〃鍏峰彴璐︽柊澧�"
+ :image-size="70"
+ />
+ </div>
+</template>
+
+<script setup>
+import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
+import { useRoute } from 'vue-router'
+import * as echarts from 'echarts'
+import dayjs from 'dayjs'
+import { ElMessage } from 'element-plus'
+import {
+ collectMeterDevices,
+ getElectricMeterDashboard,
+ getMeterOverview,
+ listMeterDeviceOptions
+} from '@/api/energyManagement/energyMeter'
+
+defineOptions({ name: 'ElectricMeterData' })
+
+const route = useRoute()
+
+const COLOR_TODAY = '#f5822c'
+const COLOR_PREVIOUS = '#2f5f96'
+const COLOR_PREVIOUS_SOFT = '#9fb8d6'
+const COLOR_REACTIVE = '#f4b9b0'
+const COLOR_POWER_FACTOR = '#f5822c'
+
+const qualityTooltip = [
+ '<b>鏈夊姛鍔熺巼</b>锛氬疄闄呭仛鍔熺殑鍔熺巼锛坘W锛夈��',
+ '<b>鏃犲姛鍔熺巼</b>锛氱數鏈恒�佸彉鍘嬪櫒寤虹珛纾佸満鍗犵敤鐨勫姛鐜囷紙kvar锛夛紝涓嶇洿鎺ュ仛鍔熴��',
+ '<b>鍔熺巼鍥犳暟</b> = 鏈夊姛 梅 鈭�(鏈夊姛虏 + 鏃犲姛虏)锛岃秺鎺ヨ繎 1 瓒婂ソ锛涘亸浣庤鏄庢棤鍔熷崰鐢ㄥぇ銆佺嚎璺崯鑰楅珮銆�',
+ '鏁版嵁鎸夊皬鏃舵眹鎬伙紱灏忔椂鏈蛋瀹屾椂锛屾寜宸查噰闆嗙殑 15 鍒嗛挓鏁版嵁鎶樼畻骞冲潎鍔熺巼銆�'
+].join('<br/>')
+
+const usageTabs = [
+ { label: '鐢甸噺', value: 'energy' },
+ { label: '鍔熺巼', value: 'power' }
+]
+
+const query = reactive({
+ scope: 'ALL',
+ meterId: null,
+ month: dayjs().format('YYYY-MM'),
+ year: dayjs().format('YYYY')
+})
+
+const overview = ref({})
+const dashboard = ref({ today: {}, quality: {} })
+const deviceOptions = ref([])
+const overviewReady = ref(false)
+const loading = ref(false)
+const overviewLoading = ref(false)
+const dashboardLoading = ref(false)
+const refreshing = ref(false)
+const weekOffset = ref(0)
+const usageTab = ref('energy')
+
+const todayChartRef = ref(null)
+const monthChartRef = ref(null)
+const usageChartRef = ref(null)
+const qualityChartRef = ref(null)
+const charts = {}
+
+let reloadTimer = null
+
+// 鏈〉鍙鐞嗙數琛ㄨ矾鐢变笂鐨� meterId锛岄伩鍏嶉〉绛剧紦瀛樺悗鏀跺埌姘旇〃/姘磋〃鐨勮澶嘔D
+const DATA_PATH = '/energyManagement/electricMeterData'
+const requestedMeterId = ref(
+ route.path === DATA_PATH && route.query.meterId ? Number(route.query.meterId) : null
+)
+
+const today = computed(() => dashboard.value.today || {})
+const quality = computed(() => dashboard.value.quality || {})
+const qualityHasData = computed(() => (quality.value.series || []).length > 0)
+const latestQuality = computed(() => {
+ const list = quality.value.series || []
+ for (let i = list.length - 1; i >= 0; i--) {
+ const item = list[i]
+ if (item && (item.activePower != null || item.powerFactor != null)) {
+ return item
+ }
+ }
+ return {}
+})
+const powerFactorText = computed(() => {
+ const value = latestQuality.value.powerFactor
+ if (value == null || value === '') {
+ return '--'
+ }
+ return Number(value).toFixed(3)
+})
+const powerFactorLevel = computed(() => {
+ const value = latestQuality.value.powerFactor
+ if (value == null || value === '') {
+ return null
+ }
+ const num = Number(value)
+ if (!Number.isFinite(num)) {
+ return null
+ }
+ if (num >= 0.9) {
+ return { text: '鑹ソ', cls: 'pf-good' }
+ }
+ if (num >= 0.8) {
+ return { text: '涓�鑸�', cls: 'pf-normal' }
+ }
+ return { text: '鍋忎綆', cls: 'pf-low' }
+})
+const hasLiveToday = computed(() =>
+ (today.value.series || []).some((item) => item && item.active != null)
+)
+const monthSeries = computed(() => {
+ const list = overview.value.monthSeries || []
+ const liveDate = dashboard.value.today && dashboard.value.today.date
+ const liveTotal = dashboard.value.today && dashboard.value.today.total
+ if (!hasLiveToday.value || !liveDate || liveTotal == null) {
+ return list
+ }
+ // 浠婃棩 15 鍒嗛挓瀹炴椂鏁版嵁姣斾笂涓�娆¤惤搴撴洿鏂帮紝鐢ㄥ疄鏃跺�艰鐩栧綋澶╃殑鏃ョ敤閲忥紝閬垮厤鈥滄湰鏈堢疮璁� < 浠婃棩绱鈥�
+ return list.map((item) =>
+ item.day === liveDate ? { ...item, current: Number(liveTotal) } : item
+ )
+})
+const monthTotal = computed(() => {
+ let total = 0
+ let hasData = false
+ monthSeries.value.forEach((item) => {
+ if (item.current != null && item.current !== '') {
+ total += Number(item.current)
+ hasData = true
+ }
+ })
+ return hasData ? total : null
+})
+const monthPreviousTotal = computed(() =>
+ overview.value.monthHasData ? overview.value.monthPreviousTotal : null
+)
+const collectedDayCount = computed(
+ () => monthSeries.value.filter((item) => item.current != null && item.current !== '').length
+)
+
+const dataThroughText = computed(() => {
+ const liveDate = today.value.date
+ if (hasLiveToday.value && liveDate && today.value.rangeEnd && today.value.rangeEnd !== '--') {
+ return `${liveDate} ${today.value.rangeEnd}`
+ }
+ return overview.value.dataThrough || '--'
+})
+
+const monthRangeText = computed(() => {
+ const month = overview.value.selectedMonth || query.month
+ const days = dayjs(`${month}-01`).daysInMonth()
+ const isCurrentMonth = month === dayjs().format('YYYY-MM')
+ const end = isCurrentMonth
+ ? dayjs().format('MM-DD')
+ : `${month.slice(5)}-${String(days).padStart(2, '0')}`
+ return `${month.slice(5)}-01 鑷� ${end}`
+})
+
+const qualityRangeText = computed(() => {
+ if (!quality.value.weekStart || !quality.value.weekEnd) {
+ return weekOffset.value === 1 ? '涓婁竴鍛�' : '杩戜竴鍛�'
+ }
+ return `${quality.value.weekStart.slice(5)} 鑷� ${quality.value.weekEnd.slice(5)}`
+})
+
+const todayCompare = computed(() => buildCompare(today.value.compareRate))
+const monthCompare = computed(() => {
+ const current = Number(monthTotal.value)
+ const previous = Number(monthPreviousTotal.value)
+ if (monthTotal.value == null || !previous) {
+ return { text: '--', cls: '' }
+ }
+ return buildCompare(((current - previous) / previous) * 100)
+})
+
+const refreshableIds = computed(() => {
+ const providerIds = deviceOptions.value
+ .filter((item) => item.sourceType === 'PROVIDER')
+ .map((item) => item.id)
+ if (query.scope === 'SINGLE' && query.meterId) {
+ return providerIds.filter((id) => id === query.meterId)
+ }
+ return providerIds
+})
+
+const canRefresh = computed(() => refreshableIds.value.length > 0)
+
+function buildCompare(rate) {
+ if (rate == null || rate === '') {
+ return { text: '--', cls: '' }
+ }
+ const num = Number(rate)
+ if (Number.isNaN(num)) {
+ return { text: '--', cls: '' }
+ }
+ const arrow = num > 0 ? ' 鈫�' : num < 0 ? ' 鈫�' : ''
+ const cls = num > 0 ? 'up' : num < 0 ? 'down' : ''
+ return { text: `${Math.abs(num)}%${arrow}`, cls }
+}
+
+function ensureMeterOption(id) {
+ if (!id || deviceOptions.value.some((item) => item.id === id)) {
+ return
+ }
+ deviceOptions.value = [{ id, displayName: `璁惧 #${id}`, meterAddress: '' }, ...deviceOptions.value]
+}
+
+function applyRequestedMeter(id) {
+ if (!id || route.path !== DATA_PATH) {
+ return
+ }
+ requestedMeterId.value = id
+ query.scope = 'SINGLE'
+ query.meterId = id
+ ensureMeterOption(id)
+ loadAll()
+}
+
+onMounted(() => {
+ if (requestedMeterId.value && route.path === DATA_PATH) {
+ query.scope = 'SINGLE'
+ query.meterId = requestedMeterId.value
+ }
+ loadAll()
+ window.addEventListener('resize', handleResize)
+})
+
+watch(
+ () => route.query.meterId,
+ (value) => {
+ if (value && route.path === DATA_PATH) {
+ applyRequestedMeter(Number(value))
+ }
+ }
+)
+
+onBeforeUnmount(() => {
+ window.removeEventListener('resize', handleResize)
+ if (reloadTimer) {
+ clearTimeout(reloadTimer)
+ reloadTimer = null
+ }
+ Object.keys(charts).forEach((key) => {
+ charts[key] && charts[key].dispose()
+ delete charts[key]
+ })
+})
+
+function handleResize() {
+ Object.keys(charts).forEach((key) => charts[key] && charts[key].resize())
+}
+
+async function loadAll() {
+ loading.value = true
+ try {
+ await loadOptions()
+ await Promise.all([loadOverview(), loadDashboard()])
+ } finally {
+ loading.value = false
+ }
+}
+
+async function loadOptions() {
+ try {
+ const res = await listMeterDeviceOptions({ meterType: 'ELECTRIC' })
+ deviceOptions.value = res.data || []
+ ensureMeterOption(requestedMeterId.value)
+ if (query.scope === 'SINGLE' && !query.meterId && deviceOptions.value.length) {
+ query.meterId = deviceOptions.value[0].id
+ }
+ } catch (e) {
+ deviceOptions.value = []
+ }
+}
+
+async function loadOverview() {
+ const params = {
+ meterType: 'ELECTRIC',
+ month: query.month,
+ year: Number(query.year)
+ }
+ if (query.scope === 'SINGLE' && query.meterId) {
+ params.meterId = query.meterId
+ }
+ overviewLoading.value = true
+ try {
+ const res = await getMeterOverview(params)
+ overview.value = res.data || {}
+ await nextTick()
+ renderMonthChart()
+ renderUsageChart()
+ } catch (e) {
+ overview.value = {}
+ await nextTick()
+ renderMonthChart()
+ renderUsageChart()
+ } finally {
+ overviewLoading.value = false
+ overviewReady.value = true
+ }
+}
+
+async function loadDashboard() {
+ const params = { weekOffset: weekOffset.value }
+ if (query.scope === 'SINGLE' && query.meterId) {
+ params.meterId = query.meterId
+ }
+ dashboardLoading.value = true
+ try {
+ const res = await getElectricMeterDashboard(params)
+ dashboard.value = res.data || { today: {}, quality: {} }
+ } catch (e) {
+ dashboard.value = { today: {}, quality: {} }
+ } finally {
+ dashboardLoading.value = false
+ await nextTick()
+ renderTodayChart()
+ if (!qualityHasData.value) {
+ disposeChart('quality')
+ } else {
+ renderQualityChart()
+ }
+ // 浠婃棩瀹炴椂鍊间細瑕嗙洊鏈湀褰撳ぉ鐨勬棩鐢ㄩ噺锛岃繖閲屽悓姝ュ埛鏂版湀搴﹀浘琛�
+ renderMonthChart()
+ renderUsageChart()
+ }
+}
+
+function handleScopeChange(value) {
+ if (value === 'ALL') {
+ query.meterId = null
+ } else if (!query.meterId && deviceOptions.value.length) {
+ query.meterId = deviceOptions.value[0].id
+ }
+ loadAll()
+}
+
+function handleMonthChange(value) {
+ if (value) {
+ query.year = value.slice(0, 4)
+ }
+ loadOverview()
+}
+
+function switchUsageTab(value) {
+ usageTab.value = value
+ renderUsageChart()
+}
+
+function switchWeek(offset) {
+ if (weekOffset.value === offset) {
+ return
+ }
+ weekOffset.value = offset
+ loadDashboard()
+}
+
+async function handleRefreshData() {
+ const meterIds = refreshableIds.value
+ if (!meterIds.length) {
+ ElMessage.warning('褰撳墠鑼冨洿娌℃湁鍙煡琛ㄧ殑绗笁鏂规帴鍏ヨ澶�')
+ return
+ }
+ refreshing.value = true
+ try {
+ await collectMeterDevices({
+ meterIds,
+ startDate: dayjs().subtract(3, 'day').format('YYYY-MM-DD'),
+ endDate: dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
+ includeReadings: true
+ })
+ ElMessage.success('鏌ヨ〃浠诲姟宸叉彁浜わ紝姝e湪鍚庡彴閲囬泦')
+ if (reloadTimer) {
+ clearTimeout(reloadTimer)
+ }
+ reloadTimer = setTimeout(() => {
+ loadAll()
+ }, 4000)
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ } finally {
+ refreshing.value = false
+ }
+}
+
+function optionLabel(item) {
+ if (!item.meterAddress) {
+ return item.displayName
+ }
+ return `${item.displayName}锛�${item.meterAddress}锛塦
+}
+
+/* ------------------------------ 鍥捐〃 ------------------------------ */
+
+function initChart(refEl, key) {
+ if (!refEl) {
+ return null
+ }
+ if (!charts[key]) {
+ charts[key] = echarts.init(refEl)
+ }
+ return charts[key]
+}
+
+function disposeChart(key) {
+ if (charts[key]) {
+ charts[key].dispose()
+ delete charts[key]
+ }
+}
+
+function baseGrid() {
+ return { left: 46, right: 12, top: 30, bottom: 24, containLabel: false }
+}
+
+function valueAxis(name) {
+ return {
+ type: 'value',
+ name,
+ nameTextStyle: { fontSize: 11, color: '#909399' },
+ axisLabel: { fontSize: 10, color: '#909399' },
+ splitLine: { lineStyle: { type: 'dashed', color: '#ebeef5' } }
+ }
+}
+
+function emptyGraphic() {
+ return [
+ {
+ type: 'text',
+ left: 'center',
+ top: 'middle',
+ style: { text: '鏆傛棤鏁版嵁', fill: '#c0c4cc', fontSize: 13 }
+ }
+ ]
+}
+
+function hasAny(points, key) {
+ return Array.isArray(points) && points.some((item) => item && item[key] != null)
+}
+
+function barSeries(name, data, color, extra = {}) {
+ return {
+ name,
+ type: 'bar',
+ barMaxWidth: 12,
+ barGap: '12%',
+ data,
+ itemStyle: { color, borderRadius: [1, 1, 0, 0] },
+ emphasis: { focus: 'series' },
+ ...extra
+ }
+}
+
+function renderTodayChart() {
+ const chart = initChart(todayChartRef.value, 'today')
+ if (!chart) {
+ return
+ }
+ const series = today.value.series || []
+ const yesterdaySeries = today.value.yesterdaySeries || []
+ const labels = series.map((item) => item.time)
+ const hasData = hasAny(series, 'active') || hasAny(yesterdaySeries, 'active')
+ chart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: { type: 'shadow' },
+ formatter: (params) => {
+ const list = Array.isArray(params) ? params : [params]
+ const head = list.length ? list[0].axisValue : ''
+ const rows = list
+ .map((item) => {
+ const value = item.value == null ? '鏆傛棤鏁版嵁' : `${formatNumber(item.value)} 搴
+ return `${item.marker}${item.seriesName}锛�${value}`
+ })
+ .join('<br/>')
+ return `${head}<br/>${rows}`
+ }
+ },
+ legend: { show: false },
+ grid: { ...baseGrid(), top: 12, bottom: 22 },
+ xAxis: {
+ type: 'category',
+ data: labels,
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: {
+ fontSize: 10,
+ color: '#909399',
+ interval: 5,
+ formatter: (value) => value
+ }
+ },
+ yAxis: { ...valueAxis('搴�'), min: 0 },
+ series: [
+ barSeries(
+ '鏄ㄦ棩鐢ㄧ數閲�',
+ yesterdaySeries.map((item) => item.active),
+ COLOR_PREVIOUS
+ ),
+ barSeries(
+ '浠婃棩鐢ㄧ數閲�',
+ series.map((item) => item.active),
+ COLOR_TODAY
+ )
+ ],
+ graphic: hasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+function renderMonthChart() {
+ const chart = initChart(monthChartRef.value, 'month')
+ if (!chart) {
+ return
+ }
+ const series = monthSeries.value
+ const hasData = hasAny(series, 'current') || hasAny(series, 'previous')
+ chart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: { type: 'shadow' },
+ formatter: (params) => {
+ const list = Array.isArray(params) ? params : [params]
+ const head = list.length ? `${query.month}-${String(Number(list[0].axisValue)).padStart(2, '0')}` : ''
+ const rows = list
+ .map((item) => {
+ const value = item.value == null ? '鏆傛棤鏁版嵁' : `${formatNumber(item.value)} 搴
+ return `${item.marker}${item.seriesName}锛�${value}`
+ })
+ .join('<br/>')
+ return `${head}<br/>${rows}`
+ }
+ },
+ legend: { show: false },
+ grid: { ...baseGrid(), top: 12, bottom: 22 },
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => String(Number(item.day ? item.day.slice(8) : 0))),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: {
+ fontSize: 9,
+ color: '#909399',
+ interval: 0
+ }
+ },
+ yAxis: { ...valueAxis('搴�'), min: 0 },
+ series: [
+ barSeries(
+ '涓婃湀鍚屾湡',
+ series.map((item) => item.previous),
+ COLOR_PREVIOUS_SOFT
+ ),
+ barSeries(
+ '鏈湀鐢ㄧ數閲�',
+ series.map((item) => item.current),
+ COLOR_TODAY
+ )
+ ],
+ graphic: hasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+function renderUsageChart() {
+ const chart = initChart(usageChartRef.value, 'usage')
+ if (!chart) {
+ return
+ }
+ const series = monthSeries.value
+ const isEnergy = usageTab.value === 'energy'
+ const hasData = hasAny(series, 'current')
+ const toValue = (value) => {
+ if (value == null || value === '') {
+ return null
+ }
+ return isEnergy ? Number(value) : Number(value) / 24
+ }
+ const unit = isEnergy ? '搴�' : 'kW'
+
+ chart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ formatter: (params) => {
+ const list = Array.isArray(params) ? params : [params]
+ const head = list.length ? `${query.month}-${String(Number(list[0].axisValue)).padStart(2, '0')}` : ''
+ const rows = list
+ .map((item) => {
+ const value = item.value == null ? '鏆傛棤鏁版嵁' : `${formatNumber(item.value)} ${unit}`
+ return `${item.marker}${item.seriesName}锛�${value}`
+ })
+ .join('<br/>')
+ return `${head}<br/>${rows}`
+ }
+ },
+ legend: {
+ data: isEnergy ? ['涓婃湀鍚屾湡', '鏈湀鐢ㄧ數閲�'] : ['涓婃湀鏃ュ潎鍔熺巼', '鏈湀鏃ュ潎鍔熺巼'],
+ top: 0,
+ right: 0,
+ itemWidth: 9,
+ itemHeight: 8,
+ textStyle: { fontSize: 11, color: '#606266' }
+ },
+ grid: { ...baseGrid(), top: 34, bottom: 30, left: 50 },
+ xAxis: {
+ type: 'category',
+ boundaryGap: isEnergy,
+ data: series.map((item) => String(Number(item.day ? item.day.slice(8) : 0))),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: { fontSize: 10, color: '#909399' }
+ },
+ yAxis: { ...valueAxis(unit), min: 0 },
+ series: isEnergy
+ ? [
+ barSeries(
+ '涓婃湀鍚屾湡',
+ series.map((item) => toValue(item.previous)),
+ COLOR_PREVIOUS_SOFT,
+ { barMaxWidth: 14 }
+ ),
+ barSeries(
+ '鏈湀鐢ㄧ數閲�',
+ series.map((item) => toValue(item.current)),
+ COLOR_TODAY,
+ { barMaxWidth: 14 }
+ )
+ ]
+ : [
+ {
+ name: '涓婃湀鏃ュ潎鍔熺巼',
+ type: 'line',
+ smooth: true,
+ symbol: 'none',
+ data: series.map((item) => toValue(item.previous)),
+ lineStyle: { width: 1.5, color: COLOR_PREVIOUS, type: 'dashed' },
+ itemStyle: { color: COLOR_PREVIOUS }
+ },
+ {
+ name: '鏈湀鏃ュ潎鍔熺巼',
+ type: 'line',
+ smooth: true,
+ symbol: 'none',
+ data: series.map((item) => toValue(item.current)),
+ lineStyle: { width: 2, color: COLOR_TODAY },
+ itemStyle: { color: COLOR_TODAY },
+ areaStyle: { color: 'rgba(245, 130, 44, 0.10)' }
+ }
+ ],
+ graphic: hasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+function renderQualityChart() {
+ const chart = initChart(qualityChartRef.value, 'quality')
+ if (!chart) {
+ return
+ }
+ const series = quality.value.series || []
+ const hasData = series.length > 0
+ const axisInterval = series.length > 12 ? Math.ceil(series.length / 7) - 1 : 0
+
+ chart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: { type: 'shadow' },
+ formatter: (params) => {
+ const list = Array.isArray(params) ? params : [params]
+ const head = list.length ? list[0].axisValue : ''
+ const rows = list
+ .map((item) => {
+ if (item.value == null) {
+ return `${item.marker}${item.seriesName}锛氭殏鏃犳暟鎹甡
+ }
+ if (item.seriesName === '鍔熺巼鍥犳暟') {
+ return `${item.marker}${item.seriesName}锛�${Number(item.value).toFixed(3)}`
+ }
+ const unit = item.seriesName === '鏈夊姛鍔熺巼' ? 'kW' : 'kvar'
+ return `${item.marker}${item.seriesName}锛�${formatNumber(item.value)} ${unit}`
+ })
+ .join('<br/>')
+ return `${head}<br/>${rows}`
+ }
+ },
+ legend: {
+ data: ['鏈夊姛鍔熺巼', '鏃犲姛鍔熺巼', '鍔熺巼鍥犳暟'],
+ top: 0,
+ right: 0,
+ itemWidth: 9,
+ itemHeight: 8,
+ textStyle: { fontSize: 11, color: '#606266' }
+ },
+ grid: { ...baseGrid(), top: 34, right: 52, bottom: 26, left: 50 },
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => item.time),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: {
+ fontSize: 10,
+ color: '#909399',
+ interval: axisInterval,
+ formatter: (value) => value
+ }
+ },
+ yAxis: [
+ {
+ ...valueAxis(''),
+ min: 0,
+ max: (value) => (value.max <= 0 ? 1 : Math.ceil(value.max * 2) / 2)
+ },
+ {
+ type: 'value',
+ name: '',
+ min: 0,
+ max: 1,
+ interval: 0.2,
+ nameTextStyle: { fontSize: 11, color: '#909399' },
+ axisLabel: { fontSize: 10, color: '#909399' },
+ splitLine: { show: false }
+ }
+ ],
+ series: [
+ barSeries(
+ '鏈夊姛鍔熺巼',
+ series.map((item) => item.activePower),
+ COLOR_PREVIOUS,
+ { barMaxWidth: 8, barGap: '30%' }
+ ),
+ barSeries(
+ '鏃犲姛鍔熺巼',
+ series.map((item) => item.reactivePower),
+ COLOR_REACTIVE,
+ { barMaxWidth: 8 }
+ ),
+ {
+ name: '鍔熺巼鍥犳暟',
+ type: 'line',
+ yAxisIndex: 1,
+ smooth: true,
+ symbol: 'none',
+ data: series.map((item) => item.powerFactor),
+ lineStyle: { width: 1.5, color: COLOR_POWER_FACTOR },
+ itemStyle: { color: COLOR_POWER_FACTOR }
+ }
+ ],
+ graphic: hasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+/* ------------------------------ 宸ュ叿 ------------------------------ */
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num.toFixed(3).replace(/\.?0+$/, '')
+}
+
+function formatValueUnit(value, unit) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ return `${formatNumber(value)}${unit}`
+}
+</script>
+
+<style lang="scss" scoped>
+.electric-page {
+ padding-bottom: 24px;
+}
+
+.page-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-end;
+ justify-content: space-between;
+ gap: 12px;
+ margin-bottom: 8px;
+}
+
+.page-title {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: baseline;
+ gap: 10px;
+
+ h2 {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .page-desc {
+ font-size: 12px;
+ color: #909399;
+ }
+}
+
+.page-filters {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 8px;
+}
+
+.status-line {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 6px;
+ margin-bottom: 12px;
+ font-size: 12px;
+ color: #909399;
+
+ b {
+ color: #303133;
+ font-weight: 500;
+ }
+
+ .dot {
+ color: #dcdfe6;
+ }
+}
+
+.mock-alert {
+ margin-bottom: 12px;
+}
+
+.top-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 12px;
+}
+
+.panel {
+ padding: 12px 16px 6px;
+ margin-bottom: 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 6px;
+ background: #fff;
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
+}
+
+.panel-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+}
+
+.head-left {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 8px;
+}
+
+.panel-head h3 {
+ margin: 0;
+ font-size: 15px;
+ font-weight: 600;
+ color: #303133;
+ line-height: 22px;
+}
+
+.panel-range {
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.panel-legend {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 12px;
+ padding-top: 4px;
+ font-size: 11px;
+ color: #606266;
+
+ i {
+ display: inline-block;
+ width: 9px;
+ height: 8px;
+ margin-right: 4px;
+ border-radius: 1px;
+ vertical-align: middle;
+ }
+
+ .dot-previous {
+ background: #2f5f96;
+ }
+
+ .dot-previous-soft {
+ background: #9fb8d6;
+ }
+
+ .dot-today {
+ background: #f5822c;
+ }
+}
+
+.metric-line {
+ margin-top: 2px;
+}
+
+.metric-value {
+ font-size: 26px;
+ font-weight: 600;
+ color: #f5822c;
+ line-height: 1.2;
+}
+
+.metric-unit {
+ margin-left: 4px;
+ font-size: 12px;
+ color: #909399;
+}
+
+.compare-line {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 8px;
+ min-height: 18px;
+ font-size: 12px;
+ color: #909399;
+
+ em {
+ font-style: normal;
+ }
+
+ b {
+ color: #303133;
+ font-weight: 500;
+ }
+
+ .sep {
+ width: 1px;
+ height: 11px;
+ background: #e4e7ed;
+ }
+}
+
+.up {
+ color: #f56c6c;
+}
+
+.down {
+ color: #67c23a;
+}
+
+.tabs {
+ display: inline-flex;
+ gap: 6px;
+}
+
+.tabs button {
+ padding: 3px 10px;
+ border: 1px solid #dcdfe6;
+ border-radius: 3px;
+ background: #fff;
+ color: #606266;
+ font-size: 12px;
+ line-height: 18px;
+ cursor: pointer;
+ transition: all 0.15s;
+
+ &:hover {
+ color: #f5822c;
+ border-color: #f6c39b;
+ }
+
+ &.active {
+ color: #f5822c;
+ border-color: #f5822c;
+ background: #fff7f1;
+ }
+}
+
+.info-dot {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 15px;
+ height: 15px;
+ border-radius: 50%;
+ background: #f0f2f5;
+ color: #909399;
+ font-size: 10px;
+ font-weight: 600;
+ line-height: 1;
+ cursor: help;
+}
+
+.quality-summary {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-end;
+ gap: 14px 36px;
+ padding: 10px 2px 8px;
+}
+
+.quality-stat {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.stat-label {
+ font-size: 12px;
+ color: #909399;
+}
+
+.stat-value {
+ font-size: 18px;
+ font-weight: 600;
+ color: #303133;
+ line-height: 1.3;
+
+ i {
+ margin-left: 3px;
+ font-size: 11px;
+ font-style: normal;
+ font-weight: 400;
+ color: #a8abb2;
+ }
+
+ em {
+ margin-left: 6px;
+ font-size: 11px;
+ font-style: normal;
+ font-weight: 400;
+ }
+}
+
+.quality-time {
+ margin-left: auto;
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.quality-empty {
+ padding: 6px 0 22px;
+ font-size: 12px;
+ text-align: center;
+ color: #a8abb2;
+}
+
+.pf-good {
+ color: #67c23a;
+}
+
+.pf-normal {
+ color: #e6a23c;
+}
+
+.pf-low {
+ color: #f56c6c;
+}
+
+.panel-note {
+ padding: 0 4px 6px;
+ font-size: 11px;
+ color: #a8abb2;
+}
+
+.chart {
+ width: 100%;
+}
+
+.chart-today,
+.chart-month {
+ height: 208px;
+}
+
+.chart-usage {
+ height: 250px;
+}
+
+.chart-quality {
+ height: 230px;
+}
+
+.empty-tip {
+ padding: 8px 0 16px;
+}
+
+@media (max-width: 1200px) {
+ .top-grid {
+ grid-template-columns: minmax(0, 1fr);
+ }
+}
+</style>
diff --git a/src/views/energyManagement/meterData/gas/index.vue b/src/views/energyManagement/meterData/gas/index.vue
new file mode 100644
index 0000000..821bd26
--- /dev/null
+++ b/src/views/energyManagement/meterData/gas/index.vue
@@ -0,0 +1,43 @@
+<template>
+ <div class="app-container meter-data-page">
+ <div class="page-header">
+ <h2>姘旇〃鏁版嵁</h2>
+ <span class="page-desc">
+ 姘旇〃鐢ㄩ噺姒傝涓庤秼鍔匡紙鍗曚綅 m鲁锛夛紱鏀寔绗笁鏂规帴鍏ヤ笌鎵嬪伐鎶勮〃锛岃鍒般�岃〃鍏峰彴璐︺�嶆柊澧炶澶囥��
+ </span>
+ </div>
+ <MeterOverview meter-type="GAS" />
+ </div>
+</template>
+
+<script setup>
+import MeterOverview from '../components/MeterOverview.vue'
+
+defineOptions({ name: 'GasMeterData' })
+</script>
+
+<style lang="scss" scoped>
+.meter-data-page {
+ padding-bottom: 24px;
+}
+
+.page-header {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: baseline;
+ gap: 12px;
+ margin-bottom: 12px;
+
+ h2 {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .page-desc {
+ font-size: 12px;
+ color: #909399;
+ }
+}
+</style>
diff --git a/src/views/energyManagement/meterData/water/index.vue b/src/views/energyManagement/meterData/water/index.vue
new file mode 100644
index 0000000..af85e28
--- /dev/null
+++ b/src/views/energyManagement/meterData/water/index.vue
@@ -0,0 +1,41 @@
+<template>
+ <div class="app-container meter-data-page">
+ <div class="page-header">
+ <h2>姘磋〃鏁版嵁</h2>
+ <span class="page-desc">姘磋〃鐢ㄩ噺姒傝涓庤秼鍔匡紙鍗曚綅 m鲁锛夛紱璁惧鏂板銆佺紪杈戜笌褰曡〃璇峰埌銆岃〃鍏峰彴璐︺�嶃��</span>
+ </div>
+ <MeterOverview meter-type="WATER" />
+ </div>
+</template>
+
+<script setup>
+import MeterOverview from '../components/MeterOverview.vue'
+
+defineOptions({ name: 'WaterMeterData' })
+</script>
+
+<style lang="scss" scoped>
+.meter-data-page {
+ padding-bottom: 24px;
+}
+
+.page-header {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: baseline;
+ gap: 12px;
+ margin-bottom: 12px;
+
+ h2 {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .page-desc {
+ font-size: 12px;
+ color: #909399;
+ }
+}
+</style>
diff --git a/src/views/energyManagement/meterLedger/index.vue b/src/views/energyManagement/meterLedger/index.vue
new file mode 100644
index 0000000..75b1c13
--- /dev/null
+++ b/src/views/energyManagement/meterLedger/index.vue
@@ -0,0 +1,1426 @@
+<template>
+ <div class="app-container meter-ledger">
+ <!-- 椤靛ご -->
+ <div class="page-head">
+ <div class="page-head-main">
+ <div class="page-title">琛ㄥ叿鍙拌处</div>
+ </div>
+ <div class="page-head-actions">
+ <el-button :icon="Refresh" @click="refreshAll">鍒锋柊</el-button>
+ <el-popover
+ v-model:visible="addMenuVisible"
+ placement="bottom-end"
+ :width="264"
+ :teleported="false"
+ trigger="click"
+ popper-class="meter-add-popper"
+ >
+ <div class="add-menu">
+ <div v-for="group in addGroups" :key="group.type" class="add-group">
+ <div class="add-group-title">
+ <span class="add-dot" :class="group.type.toLowerCase()"></span>
+ {{ group.name }}
+ </div>
+ <button
+ v-for="option in group.options"
+ :key="option.source"
+ type="button"
+ class="add-option"
+ @click="handleAdd(group.type, option.source)"
+ >
+ <span class="add-option-label">{{ option.label }}</span>
+ <span class="add-option-hint">{{ option.hint }}</span>
+ </button>
+ </div>
+ </div>
+ <template #reference>
+ <el-button type="primary" :icon="Plus">
+ 鏂板璁惧
+ <el-icon class="el-icon--right"><ArrowDown /></el-icon>
+ </el-button>
+ </template>
+ </el-popover>
+ </div>
+ </div>
+
+ <!-- 鑳芥簮绫诲瀷鍒囨崲 -->
+ <div class="type-switch">
+ <div
+ v-for="item in meterTypes"
+ :key="item.value"
+ class="type-card"
+ :class="[item.value.toLowerCase(), { active: activeType === item.value }]"
+ @click="switchType(item.value)"
+ >
+ <div class="type-badge">{{ item.label.charAt(0) }}</div>
+ <div class="type-info">
+ <div class="type-name">{{ item.label }}</div>
+ <div class="type-count"><b>{{ counts[item.value] == null ? '-' : counts[item.value] }}</b> 鍙�</div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 绛涢�� -->
+ <div class="filter-bar">
+ <el-input
+ v-model="stateMap[activeType].keyword"
+ class="filter-keyword"
+ placeholder="鎼滅储璁惧鍚嶇О / 琛ㄥ彿"
+ clearable
+ :prefix-icon="Search"
+ @keyup.enter="handleQuery"
+ @clear="handleQuery"
+ />
+ <el-select
+ v-model="stateMap[activeType].collectionMode"
+ placeholder="鍏ㄩ儴閲囬泦鏂瑰紡"
+ clearable
+ style="width: 150px"
+ @change="handleQuery"
+ >
+ <el-option label="鑷姩閲囬泦" value="AUTO" />
+ <el-option label="鎵嬪姩鎶勮〃" value="MANUAL" />
+ </el-select>
+ <el-button type="primary" plain @click="handleQuery">鏌ヨ</el-button>
+ <el-button text @click="handleReset">閲嶇疆</el-button>
+ <div class="filter-summary">鍏� <b>{{ stateMap[activeType].total }}</b> 鍙皗{ activeTypeName }}</div>
+ </div>
+
+ <!-- 鍒楄〃 -->
+ <div class="table-card">
+ <el-table :data="devices" v-loading="tableLoading" row-key="id" class="ledger-table">
+ <el-table-column type="index" label="搴忓彿" width="70" align="center" :index="indexMethod" />
+ <el-table-column label="璁惧鍚嶇О" min-width="210" show-overflow-tooltip>
+ <template #default="scope">
+ <div class="name-cell">
+ <span class="device-name">{{ scope.row.displayName || '--' }}</span>
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column label="閲囬泦鏂瑰紡" width="110" align="center">
+ <template #default="scope">
+ <span class="collect-mode" :class="isAutoCollect(scope.row) ? 'auto' : 'manual'">
+ <i></i>{{ isAutoCollect(scope.row) ? '鑷姩閲囬泦' : '鎵嬪姩鎶勮〃' }}
+ </span>
+ </template>
+ </el-table-column>
+ <el-table-column prop="meterAddress" label="琛ㄥ彿" width="160" align="center" class-name="col-mono" show-overflow-tooltip />
+ <el-table-column label="瀹夎浣嶇疆" min-width="180" align="center" show-overflow-tooltip>
+ <template #default="scope">{{ scope.row.location || '--' }}</template>
+ </el-table-column>
+ <el-table-column label="鏈�杩戠敤閲�" width="115" align="right">
+ <template #default="scope">
+ <span v-if="scope.row.lastDayUsage != null" class="num">
+ {{ formatNumber(scope.row.lastDayUsage) }}<span class="num-unit">{{ unitText(scope.row.meterType) }}</span>
+ </span>
+ <span v-else class="device-sub">--</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="涓婃璇绘暟" width="115" align="right">
+ <template #default="scope">
+ <span v-if="scope.row.previousReading != null" class="num prev">
+ {{ formatNumber(scope.row.previousReading) }}<span class="num-unit">{{ unitText(scope.row.meterType) }}</span>
+ </span>
+ <span v-else class="device-sub">--</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏈�鏂拌鏁�" width="115" align="right">
+ <template #default="scope">
+ <span v-if="scope.row.latestReading != null" class="num">
+ {{ formatNumber(scope.row.latestReading) }}<span class="num-unit">{{ unitText(scope.row.meterType) }}</span>
+ </span>
+ <span v-else class="device-sub">--</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" width="320" fixed="right" align="center">
+ <template #default="scope">
+ <div class="cell-actions">
+ <el-button link type="primary" @click="goData(scope.row)">鏌ョ湅鏁版嵁</el-button>
+ <el-button
+ v-if="isManualRow(scope.row)"
+ link
+ type="primary"
+ @click="openReadingDialog(scope.row)"
+ >
+ 褰曡〃
+ </el-button>
+ <el-button
+ v-else-if="scope.row.simulated !== 1"
+ link
+ type="primary"
+ @click="openCollectDialog(scope.row)"
+ >
+ 鏌ヨ〃
+ </el-button>
+ <el-button
+ v-if="isManualRow(scope.row)"
+ link
+ type="primary"
+ @click="openReadingsDrawer(scope.row)"
+ >
+ 鎶勮〃璁板綍
+ </el-button>
+ <el-button link type="primary" @click="openDeviceForm('edit', scope.row)">缂栬緫</el-button>
+ <template v-if="scope.row.deletable === true">
+ <el-button link type="danger" @click="handleDelete(scope.row)">鍒犻櫎</el-button>
+ </template>
+ <el-tooltip v-else :content="deleteTip(scope.row)" placement="top">
+ <span class="btn-disabled">
+ <el-button link type="danger" disabled>鍒犻櫎</el-button>
+ </span>
+ </el-tooltip>
+ </div>
+ </template>
+ </el-table-column>
+ <template #empty>
+ <div class="empty-box">
+ <el-empty :description="`鏆傛棤${activeTypeName}璁惧`" :image-size="72">
+ <el-button type="primary" plain @click="handleAdd(activeType, 'MANUAL')">鎵嬪伐鎶勮〃鏂板</el-button>
+ </el-empty>
+ </div>
+ </template>
+ </el-table>
+
+ <div class="table-footer">
+ <el-pagination
+ layout="total, sizes, prev, pager, next, jumper"
+ :total="stateMap[activeType].total"
+ :current-page="stateMap[activeType].current"
+ :page-size="stateMap[activeType].size"
+ :page-sizes="[10, 20, 50]"
+ background
+ @current-change="handlePageChange"
+ @size-change="handleSizeChange"
+ />
+ </div>
+ </div>
+
+ <!-- 绗笁鏂规帴鍏ワ細楠岃瘉妗f 鈫� 缁戝畾 -->
+ <DeviceFormDialog
+ ref="deviceFormRef"
+ :default-meter-type="activeType"
+ @success="handleDeviceSaved"
+ />
+
+
+ <!-- 鏂板鎵嬪伐鎶勮〃璁惧 -->
+ <el-dialog v-model="manualDialog.visible" :title="manualDialogTitle" width="560px" append-to-body>
+ <el-form ref="manualFormRef" :model="manualDialog.form" :rules="manualRules" label-width="108px">
+ <el-form-item label="鑳芥簮绫诲瀷">
+ <el-tag :type="typeTag(manualDialog.meterType)" size="small" effect="plain">
+ {{ typeText(manualDialog.meterType) }}
+ </el-tag>
+ <span class="field-tip">鎸夋柊澧炲叆鍙h嚜鍔ㄥ甫鍏ワ紝涓嶅彲淇敼</span>
+ </el-form-item>
+ <el-form-item label="琛ㄥ彿" prop="meterAddress">
+ <el-input v-model="manualDialog.form.meterAddress" placeholder="璇疯緭鍏ヨ〃鍙凤紝淇濈暀鍓嶅闆�" maxlength="64" />
+ </el-form-item>
+ <el-form-item label="鏄剧ず鍚嶇О">
+ <el-input v-model="manualDialog.form.displayName" placeholder="鐣欑┖鏃朵娇鐢ㄨ〃鍙�" maxlength="128" />
+ </el-form-item>
+ <el-form-item label="瀹夎浣嶇疆">
+ <el-input v-model="manualDialog.form.location" :placeholder="locationPlaceholder(manualDialog.meterType)" maxlength="255" />
+ </el-form-item>
+ <el-form-item label="璧峰琛ㄧ爜" prop="initialReading">
+ <el-input-number
+ v-model="manualDialog.form.initialReading"
+ :min="0"
+ :precision="manualReadingPrecision"
+ :step="manualReadingStep"
+ controls-position="right"
+ style="width: 100%"
+ />
+ <div class="field-tip">璧峰琛ㄧ爜浣滀负鍩哄噯璁板綍锛屼笉璁″叆鐢ㄩ噺锛屽崟浣� {{ unitText(manualDialog.meterType) }}</div>
+ </el-form-item>
+ <el-form-item label="璧峰鏃ユ湡" prop="initialReadingDate">
+ <el-date-picker
+ v-model="manualDialog.form.initialReadingDate"
+ type="date"
+ value-format="YYYY-MM-DD"
+ :clearable="false"
+ :disabled-date="disableAfterToday"
+ placeholder="璇烽�夋嫨璧峰鏃ユ湡"
+ style="width: 100%"
+ />
+ <div class="field-tip">榛樿浠婂ぉ锛屼笉鍙櫄浜庝粖澶�</div>
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <el-button @click="manualDialog.visible = false">鍙� 娑�</el-button>
+ <el-button type="primary" :loading="manualDialog.submitting" @click="submitManualDevice">纭� 瀹�</el-button>
+ </template>
+ </el-dialog>
+
+ <!-- 褰曡〃 -->
+ <el-dialog v-model="readingDialog.visible" title="鎵嬪伐褰曡〃" width="560px" append-to-body>
+ <el-form ref="readingFormRef" :model="readingDialog.form" :rules="readingRules" label-width="108px">
+ <el-form-item label="璁惧">
+ <div class="reading-device">
+ <div class="device-name">
+ {{ readingDialog.device ? readingDialog.device.displayName : '--' }}
+ </div>
+ <div class="device-sub">
+ 琛ㄥ彿 {{ readingDialog.device ? readingDialog.device.meterAddress : '--' }} 路 鍗曚綅
+ {{ readingDialog.device ? unitText(readingDialog.device.meterType) : '--' }}
+ </div>
+ </div>
+ </el-form-item>
+ <el-form-item label="涓婃湡琛ㄧ爜">
+ <span v-if="readingDialog.previousLoading" class="device-sub">璇诲彇涓��</span>
+ <span v-else-if="readingDialog.previousReading != null">
+ {{ formatNumber(readingDialog.previousReading) }}
+ {{ readingDialog.device ? unitText(readingDialog.device.meterType) : '' }}
+ </span>
+ <span v-else class="device-sub">鏃�</span>
+ </el-form-item>
+ <el-form-item label="鎶勮〃鏃ユ湡" prop="readingDate">
+ <el-date-picker
+ v-model="readingDialog.form.readingDate"
+ type="date"
+ value-format="YYYY-MM-DD"
+ :clearable="false"
+ :disabled-date="disableReadingDate"
+ placeholder="璇烽�夋嫨鎶勮〃鏃ユ湡"
+ style="width: 100%"
+ />
+ <div class="field-tip">涓嶅彲鏅氫簬浠婂ぉ锛屼笉鍙棭浜庤澶囪捣濮嬭〃鐮佹棩鏈�</div>
+ </el-form-item>
+ <el-form-item label="鏈琛ㄧ爜" prop="readingValue">
+ <el-input-number
+ v-model="readingDialog.form.readingValue"
+ :min="0"
+ :precision="readingPrecision"
+ :step="readingStep"
+ controls-position="right"
+ style="width: 100%"
+ />
+ <div class="field-tip">鏈琛ㄧ爜涓嶈兘灏忎簬涓婃湡琛ㄧ爜锛屽崟浣� {{ unitText(readingDialog.device && readingDialog.device.meterType) }}</div>
+ </el-form-item>
+ <el-form-item label="澶囨敞">
+ <el-input v-model="readingDialog.form.remark" type="textarea" :rows="2" maxlength="500" show-word-limit />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <el-button @click="readingDialog.visible = false">鍙� 娑�</el-button>
+ <el-button type="primary" :loading="readingDialog.submitting" @click="submitReading">纭� 瀹�</el-button>
+ </template>
+ </el-dialog>
+
+ <!-- 鎶勮〃璁板綍 -->
+ <el-drawer
+ v-model="readingDrawer.visible"
+ direction="rtl"
+ size="720px"
+ :title="readingDrawerTitle"
+ :destroy-on-close="false"
+ >
+ <div class="readings-panel">
+ <el-table :data="readingDrawer.list" v-loading="readingDrawer.loading" size="small" border>
+ <el-table-column label="鎶勮〃鏃ユ湡" width="120">
+ <template #default="scope">{{ readingDate(scope.row) }}</template>
+ </el-table-column>
+ <el-table-column label="琛ㄧ爜" width="130" align="right">
+ <template #default="scope">{{ formatNumber(scope.row.metricValue) }}</template>
+ </el-table-column>
+ <el-table-column label="鏈湡鐢ㄩ噺" width="130" align="right">
+ <template #default="scope">
+ <span v-if="scope.row.usageValue != null">{{ formatNumber(scope.row.usageValue) }}</span>
+ <span v-else class="device-sub">--</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="澶囨敞" min-width="180" show-overflow-tooltip>
+ <template #default="scope">{{ scope.row.remark || '--' }}</template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" width="90" align="center">
+ <template #default="scope">
+ <el-button
+ v-if="scope.row.remark !== '璧峰琛ㄧ爜'"
+ link
+ type="danger"
+ @click="handleDeleteReading(scope.row)"
+ >
+ 鍒犻櫎
+ </el-button>
+ <span v-else class="device-sub">--</span>
+ </template>
+ </el-table-column>
+ </el-table>
+ <el-pagination
+ class="readings-pagination"
+ layout="total, sizes, prev, pager, next"
+ :total="readingDrawer.total"
+ :current-page="readingDrawer.current"
+ :page-size="readingDrawer.size"
+ :page-sizes="[10, 20, 50]"
+ @current-change="handleReadingPageChange"
+ @size-change="handleReadingSizeChange"
+ />
+ </div>
+ </el-drawer>
+
+ <!-- 鎵嬪姩鏌ヨ〃锛堜粎绗笁鏂规帴鍏ヨ澶囷級 -->
+ <el-dialog v-model="collectDialog.visible" title="鎵嬪姩鏌ヨ〃" width="480px" append-to-body>
+ <el-form label-width="92px">
+ <el-form-item label="鏌ヨ〃璁惧">
+ <div class="collect-devices">
+ <el-tag v-if="collectDialog.device" size="small" effect="plain">
+ {{ collectDialog.device.displayName }}锛坽{ collectDialog.device.meterAddress }}锛�
+ </el-tag>
+ </div>
+ </el-form-item>
+ <el-form-item label="鏃ユ湡鑼冨洿">
+ <el-date-picker
+ v-model="collectDialog.range"
+ type="daterange"
+ value-format="YYYY-MM-DD"
+ range-separator="鑷�"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ :disabled-date="disableAfterYesterday"
+ style="width: 100%"
+ />
+ </el-form-item>
+ <el-form-item label="鍖呭惈绀哄��">
+ <el-switch v-model="collectDialog.includeReadings" />
+ <span class="field-tip">鍏抽棴鍚庡彧閲囬泦鏈熼棿鐢ㄩ噺</span>
+ </el-form-item>
+ </el-form>
+ <div class="dialog-tip">
+ 鎵嬪姩鏌ヨ〃鍦ㄥ悗鍙版墽琛岋紝瀹屾垚鍚庡垪琛ㄤ細鑷姩鍒锋柊锛涢噸澶嶆煡璇㈠悓涓�鏃堕棿鑼冨洿涓嶄細浜х敓閲嶅璁板綍銆�
+ </div>
+ <template #footer>
+ <el-button @click="collectDialog.visible = false">鍙� 娑�</el-button>
+ <el-button type="primary" :loading="collectDialog.submitting" @click="submitCollect">寮�濮嬫煡琛�</el-button>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup>
+import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
+import { useRouter } from 'vue-router'
+import dayjs from 'dayjs'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import { ArrowDown, Plus, Refresh, Search } from '@element-plus/icons-vue'
+import DeviceFormDialog from '../waterElectricMeter/components/DeviceFormDialog.vue'
+import {
+ addManualMeterDevice,
+ addMeterReading,
+ collectMeterDevice,
+ deleteMeterDevice,
+ deleteMeterReading,
+ listMeterDevices,
+ listMeterReadings
+} from '@/api/energyManagement/energyMeter'
+
+defineOptions({ name: 'MeterLedger' })
+
+const router = useRouter()
+
+// 涓夌鑳芥簮绫诲瀷锛屽悇鑷繚鐣欎笂娆$殑绛涢�夋潯浠朵笌鍒嗛〉
+const meterTypes = [
+ { value: 'WATER', label: '姘磋〃' },
+ { value: 'ELECTRIC', label: '鐢佃〃' },
+ { value: 'GAS', label: '钂告苯琛�' }
+]
+
+// 鏂板鍏ュ彛鎸夎兘婧愮被鍨嬪垎缁勶細涓夌被琛ㄩ兘鏀寔绗笁鏂规帴鍏ヤ笌鎵嬪伐鎶勮〃
+const addGroups = [
+ {
+ type: 'WATER',
+ name: '姘磋〃',
+ options: [
+ { source: 'PROVIDER', label: '绗笁鏂规帴鍏�', hint: '鑷姩閲囬泦' },
+ { source: 'MANUAL', label: '鎵嬪伐鎶勮〃', hint: '鎵嬪姩褰曡〃' }
+ ]
+ },
+ {
+ type: 'ELECTRIC',
+ name: '鐢佃〃',
+ options: [
+ { source: 'PROVIDER', label: '绗笁鏂规帴鍏�', hint: '鑷姩閲囬泦' },
+ { source: 'MANUAL', label: '鎵嬪伐鎶勮〃', hint: '鎵嬪姩褰曡〃' }
+ ]
+ },
+ {
+ type: 'GAS',
+ name: '钂告苯琛�',
+ options: [
+ { source: 'PROVIDER', label: '绗笁鏂规帴鍏�', hint: '鑷姩閲囬泦' },
+ { source: 'MANUAL', label: '鎵嬪伐鎶勮〃', hint: '鎵嬪姩褰曡〃' }
+ ]
+ }
+]
+
+const addMenuVisible = ref(false)
+const activeType = ref('WATER')
+const activeTypeName = computed(() => typeText(activeType.value))
+
+const stateMap = reactive({
+ WATER: { keyword: '', collectionMode: '', current: 1, size: 10, total: 0 },
+ ELECTRIC: { keyword: '', collectionMode: '', current: 1, size: 10, total: 0 },
+ GAS: { keyword: '', collectionMode: '', current: 1, size: 10, total: 0 }
+})
+
+const counts = reactive({ WATER: null, ELECTRIC: null, GAS: null })
+const devices = ref([])
+const tableLoading = ref(false)
+const deviceFormRef = ref(null)
+const manualFormRef = ref(null)
+const readingFormRef = ref(null)
+
+// 绗笁鏂规帴鍏� 鈫� 璺宠浆鑳借�楀疄鏃剁洃鎺э紙甯﹁澶嘔D锛屾寜鍗曞彴璁惧鏌ョ湅锛�
+const dataRouteMap = {
+ WATER: '/energyManagement/realtimeMonitor',
+ ELECTRIC: '/energyManagement/realtimeMonitor',
+ GAS: '/energyManagement/realtimeMonitor'
+}
+const unitMap = { WATER: 'm鲁', ELECTRIC: '搴�', GAS: 'm鲁' }
+
+const manualDialog = reactive({
+ visible: false,
+ submitting: false,
+ meterType: 'WATER',
+ form: {
+ meterAddress: '',
+ displayName: '',
+ location: '',
+ initialReading: 0,
+ initialReadingDate: dayjs().format('YYYY-MM-DD')
+ }
+})
+
+const manualRules = {
+ meterAddress: [{ required: true, message: '璇疯緭鍏ヨ〃鍙�', trigger: 'blur' }],
+ initialReading: [{ required: true, message: '璇疯緭鍏ヨ捣濮嬭〃鐮�', trigger: 'blur' }],
+ initialReadingDate: [{ required: true, message: '璇烽�夋嫨璧峰鏃ユ湡', trigger: 'change' }]
+}
+
+const readingDialog = reactive({
+ visible: false,
+ submitting: false,
+ device: null,
+ previousReading: null,
+ previousLoading: false,
+ form: {
+ readingDate: dayjs().format('YYYY-MM-DD'),
+ readingValue: 0,
+ remark: ''
+ }
+})
+
+const readingRules = {
+ readingDate: [{ required: true, message: '璇烽�夋嫨鎶勮〃鏃ユ湡', trigger: 'change' }],
+ readingValue: [{ required: true, message: '璇疯緭鍏ユ湰娆¤〃鐮�', trigger: 'blur' }]
+}
+
+const readingDrawer = reactive({
+ visible: false,
+ device: null,
+ list: [],
+ total: 0,
+ current: 1,
+ size: 10,
+ loading: false
+})
+
+const readingDrawerTitle = computed(() => {
+ const device = readingDrawer.device
+ return device ? `鎶勮〃璁板綍 路 ${device.displayName}` : '鎶勮〃璁板綍'
+})
+
+const collectDialog = reactive({
+ visible: false,
+ submitting: false,
+ device: null,
+ range: [],
+ includeReadings: true
+})
+
+// 褰曡〃绮惧害锛氱數琛ㄤ袱浣嶏紝姘磋〃/姘旇〃涓変綅
+const readingPrecision = computed(() => (activeType.value === 'ELECTRIC' ? 2 : 3))
+const readingStep = computed(() => (activeType.value === 'ELECTRIC' ? 0.01 : 0.001))
+
+// 鎵嬪伐鏂板鎸夊疄闄呴�夋嫨鐨勭被鍨嬪甫鍏ユ爣棰樸�佺簿搴﹀拰鍗曚綅锛岄伩鍏嶈窡闅忛〉绛句覆绫诲瀷
+const manualDialogTitle = computed(() => `鏂板${typeText(manualDialog.meterType)} 路 鎵嬪伐鎶勮〃`)
+const manualReadingPrecision = computed(() => (manualDialog.meterType === 'ELECTRIC' ? 2 : 3))
+const manualReadingStep = computed(() => (manualDialog.meterType === 'ELECTRIC' ? 0.01 : 0.001))
+
+let collectReloadTimer = null
+
+onMounted(() => {
+ loadDevices()
+ loadCounts()
+})
+
+onBeforeUnmount(() => {
+ if (collectReloadTimer) {
+ clearTimeout(collectReloadTimer)
+ collectReloadTimer = null
+ }
+})
+
+/* ------------------------------ 鍒楄〃 ------------------------------ */
+
+async function loadDevices() {
+ const state = stateMap[activeType.value]
+ const collectionMode = state.collectionMode
+ tableLoading.value = true
+ try {
+ const res = await listMeterDevices({
+ current: state.current,
+ size: state.size,
+ meterType: activeType.value,
+ keyword: state.keyword || undefined,
+ collectionMode: collectionMode || undefined
+ })
+ const data = res.data || {}
+ devices.value = data.records || []
+ state.total = data.total || 0
+ } catch (e) {
+ devices.value = []
+ state.total = 0
+ } finally {
+ tableLoading.value = false
+ }
+}
+
+// 椤电涓婄殑璁惧鍙版暟锛堜笉鍙楁煡璇㈡潯浠跺奖鍝嶏級
+async function loadCounts() {
+ try {
+ const results = await Promise.all(
+ meterTypes.map((item) => listMeterDevices({ current: 1, size: 1, meterType: item.value }))
+ )
+ meterTypes.forEach((item, index) => {
+ const data = results[index].data || {}
+ counts[item.value] = data.total || 0
+ })
+ } catch (e) {
+ // 鍙版暟灞曠ず澶辫触涓嶅奖鍝嶅垪琛ㄤ娇鐢�
+ }
+}
+
+function handleTabChange() {
+ // 鍒囨崲绫诲瀷鏃跺厛娓呯┖涓婁竴绫诲瀷鐨勮锛岄伩鍏嶇湅鍒版棫鏁版嵁
+ devices.value = []
+ loadDevices()
+}
+
+// 绫诲瀷鍗$墖鐐瑰嚮鍒囨崲
+function switchType(value) {
+ if (value === activeType.value) {
+ return
+ }
+ activeType.value = value
+ handleTabChange()
+}
+
+// 椤靛ご鍒锋柊锛氬垪琛ㄤ笌鍙版暟涓�璧峰埛鏂�
+function refreshAll() {
+ loadDevices()
+ loadCounts()
+}
+
+function handleQuery() {
+ stateMap[activeType.value].current = 1
+ loadDevices()
+}
+
+function handleReset() {
+ const state = stateMap[activeType.value]
+ state.keyword = ''
+ state.collectionMode = ''
+ state.current = 1
+ loadDevices()
+}
+
+function handlePageChange(current) {
+ stateMap[activeType.value].current = current
+ loadDevices()
+}
+
+function handleSizeChange(size) {
+ const state = stateMap[activeType.value]
+ state.size = size
+ state.current = 1
+ loadDevices()
+}
+
+// 璺ㄩ〉杩炵画搴忓彿
+function indexMethod(index) {
+ const state = stateMap[activeType.value]
+ return (state.current - 1) * state.size + index + 1
+}
+
+/* ------------------------------ 鏂板 / 缂栬緫 / 鍒犻櫎 ------------------------------ */
+
+function handleAdd(type, source) {
+ addMenuVisible.value = false
+ // 鍒囧埌瑕佹柊澧炵殑绫诲瀷锛屼繚瀛樺悗鑳界洿鎺ュ湪褰撳墠鍒楄〃鐪嬪埌鏂拌澶�
+ if (type && type !== activeType.value) {
+ activeType.value = type
+ handleTabChange()
+ }
+ if (source === 'MANUAL') {
+ openManualDialog(type)
+ return
+ }
+ openDeviceForm('add', null, type)
+}
+
+function openDeviceForm(mode, row, meterType) {
+ deviceFormRef.value && deviceFormRef.value.open(mode, row, meterType)
+}
+
+function handleDeviceSaved() {
+ loadDevices()
+ loadCounts()
+}
+
+function openManualDialog(meterType) {
+ manualDialog.meterType = meterType || activeType.value
+ manualDialog.form.meterAddress = ''
+ manualDialog.form.displayName = ''
+ manualDialog.form.location = ''
+ manualDialog.form.initialReading = 0
+ manualDialog.form.initialReadingDate = dayjs().format('YYYY-MM-DD')
+ manualDialog.visible = true
+ nextTick(() => manualFormRef.value && manualFormRef.value.clearValidate())
+}
+
+async function submitManualDevice() {
+ if (!manualFormRef.value) {
+ return
+ }
+ const valid = await manualFormRef.value.validate().catch(() => false)
+ if (!valid) {
+ return
+ }
+ manualDialog.submitting = true
+ try {
+ await addManualMeterDevice({
+ meterType: manualDialog.meterType,
+ meterAddress: manualDialog.form.meterAddress.trim(),
+ displayName: manualDialog.form.displayName,
+ location: manualDialog.form.location,
+ initialReading: manualDialog.form.initialReading,
+ initialReadingDate: manualDialog.form.initialReadingDate
+ })
+ ElMessage.success('鎵嬪伐鎶勮〃璁惧宸叉柊澧�')
+ manualDialog.visible = false
+ handleDeviceSaved()
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ } finally {
+ manualDialog.submitting = false
+ }
+}
+
+async function handleDelete(row) {
+ try {
+ await ElMessageBox.confirm(
+ `纭鍒犻櫎璁惧銆�${row.displayName}銆嶏紵鍒犻櫎鍚庤璁惧鐨勬妱琛ㄨ褰曞皢涓�骞舵竻闄わ紝涓斾笉鍙仮澶嶃�俙,
+ '鍒犻櫎璁惧',
+ { type: 'warning', confirmButtonText: '鍒犻櫎', cancelButtonText: '鍙栨秷' }
+ )
+ } catch (e) {
+ return
+ }
+ try {
+ await deleteMeterDevice(row.id)
+ ElMessage.success('鍒犻櫎鎴愬姛')
+ // 鍒犻櫎褰撳墠椤垫渶鍚庝竴鏉℃椂鍥為��涓�椤碉紝閬垮厤钀藉湪绌洪〉
+ const state = stateMap[activeType.value]
+ if (devices.value.length === 1 && state.current > 1) {
+ state.current -= 1
+ }
+ handleDeviceSaved()
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ }
+}
+
+function isAutoCollect(row) {
+ return !!row && (row.sourceType === 'PROVIDER' || row.simulated === 1)
+}
+
+function isManualRow(row) {
+ return !!row && row.simulated !== 1 && row.sourceType === 'MANUAL'
+}
+
+function deleteTip(row) {
+ if (row.isSeed === 1) {
+ return '鍒濆鍖栬澶囦笉鍏佽鍒犻櫎'
+ }
+ return '绗笁鏂规帴鍏ヨ澶囪浣跨敤鍋滅敤'
+}
+
+/* ------------------------------ 褰曡〃 + 鎶勮〃璁板綍 ------------------------------ */
+
+async function openReadingDialog(row) {
+ readingDialog.device = row
+ readingDialog.previousReading = null
+ readingDialog.form.readingDate = dayjs().format('YYYY-MM-DD')
+ readingDialog.form.readingValue = 0
+ readingDialog.form.remark = ''
+ readingDialog.visible = true
+ nextTick(() => readingFormRef.value && readingFormRef.value.clearValidate())
+ readingDialog.previousLoading = true
+ try {
+ const res = await listMeterReadings(row.id, { current: 1, size: 1 })
+ const rows = (res.data && res.data.records) || []
+ readingDialog.previousReading = rows.length ? rows[0].metricValue : null
+ } catch (e) {
+ readingDialog.previousReading = null
+ } finally {
+ readingDialog.previousLoading = false
+ }
+}
+
+async function submitReading() {
+ if (!readingFormRef.value || !readingDialog.device) {
+ return
+ }
+ const valid = await readingFormRef.value.validate().catch(() => false)
+ if (!valid) {
+ return
+ }
+ readingDialog.submitting = true
+ try {
+ const device = readingDialog.device
+ const res = await addMeterReading(device.id, {
+ readingDate: readingDialog.form.readingDate,
+ readingValue: readingDialog.form.readingValue,
+ remark: readingDialog.form.remark
+ })
+ const data = res.data || {}
+ if (data.usage == null) {
+ ElMessage.success('琛ㄧ爜宸茶褰曪紙鏆傛棤涓婃湡琛ㄧ爜锛屾湰鏈熺敤閲忔棤娉曡绠楋級')
+ } else {
+ ElMessage.success(`鏈湡鐢ㄩ噺 ${formatNumber(data.usage)} ${unitText(device.meterType)}`)
+ }
+ readingDialog.visible = false
+ handleDeviceSaved()
+ if (readingDrawer.visible && readingDrawer.device && readingDrawer.device.id === device.id) {
+ loadReadings()
+ }
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ } finally {
+ readingDialog.submitting = false
+ }
+}
+
+function openReadingsDrawer(row) {
+ readingDrawer.device = row
+ readingDrawer.current = 1
+ readingDrawer.list = []
+ readingDrawer.total = 0
+ readingDrawer.visible = true
+ loadReadings()
+}
+
+async function loadReadings() {
+ if (!readingDrawer.device) {
+ return
+ }
+ readingDrawer.loading = true
+ try {
+ const res = await listMeterReadings(readingDrawer.device.id, {
+ current: readingDrawer.current,
+ size: readingDrawer.size
+ })
+ const data = res.data || {}
+ readingDrawer.list = data.records || []
+ readingDrawer.total = data.total || 0
+ } catch (e) {
+ readingDrawer.list = []
+ readingDrawer.total = 0
+ } finally {
+ readingDrawer.loading = false
+ }
+}
+
+function handleReadingPageChange(current) {
+ readingDrawer.current = current
+ loadReadings()
+}
+
+function handleReadingSizeChange(size) {
+ readingDrawer.size = size
+ readingDrawer.current = 1
+ loadReadings()
+}
+
+async function handleDeleteReading(row) {
+ const device = readingDrawer.device
+ if (!device) {
+ return
+ }
+ try {
+ await ElMessageBox.confirm(
+ `纭鍒犻櫎 ${readingDate(row)} 鐨勬妱琛ㄨ褰曪紵鍒犻櫎鍚庝細閲嶇畻涓嬩竴鏈熺殑鏈湡鐢ㄩ噺銆俙,
+ '鍒犻櫎鎶勮〃璁板綍',
+ { type: 'warning', confirmButtonText: '鍒犻櫎', cancelButtonText: '鍙栨秷' }
+ )
+ } catch (e) {
+ return
+ }
+ try {
+ await deleteMeterReading(device.id, row.id)
+ ElMessage.success('鍒犻櫎鎴愬姛')
+ if (readingDrawer.list.length === 1 && readingDrawer.current > 1) {
+ readingDrawer.current -= 1
+ }
+ loadReadings()
+ handleDeviceSaved()
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ }
+}
+
+/* ------------------------------ 鏌ヨ〃锛堢涓夋柟鎺ュ叆锛� ------------------------------ */
+
+function openCollectDialog(row) {
+ if (!row || !row.id) {
+ ElMessage.warning('璇峰厛閫夋嫨璁惧')
+ return
+ }
+ collectDialog.device = row
+ collectDialog.range = [
+ dayjs().subtract(3, 'day').format('YYYY-MM-DD'),
+ dayjs().subtract(1, 'day').format('YYYY-MM-DD')
+ ]
+ collectDialog.includeReadings = true
+ collectDialog.visible = true
+}
+
+async function submitCollect() {
+ if (!collectDialog.device) {
+ return
+ }
+ if (!collectDialog.range || collectDialog.range.length !== 2) {
+ ElMessage.warning('璇烽�夋嫨鏌ヨ〃鏃ユ湡鑼冨洿')
+ return
+ }
+ collectDialog.submitting = true
+ try {
+ await collectMeterDevice(collectDialog.device.id, {
+ startDate: collectDialog.range[0],
+ endDate: collectDialog.range[1],
+ includeReadings: collectDialog.includeReadings
+ })
+ collectDialog.visible = false
+ ElMessage.success('鏌ヨ〃浠诲姟宸叉彁浜わ紝姝e湪鍚庡彴閲囬泦')
+ if (collectReloadTimer) {
+ clearTimeout(collectReloadTimer)
+ }
+ collectReloadTimer = setTimeout(() => {
+ loadDevices()
+ loadCounts()
+ collectReloadTimer = null
+ }, 4000)
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ } finally {
+ collectDialog.submitting = false
+ }
+}
+
+/* ------------------------------ 璺宠浆 / 宸ュ叿 ------------------------------ */
+
+function goData(row) {
+ const path = dataRouteMap[row.meterType]
+ if (!path) {
+ ElMessage.warning('鏆備笉鏀寔璇ョ被鍨嬬殑璁惧鏁版嵁椤�')
+ return
+ }
+ router.push({ path, query: { meterId: row.id } })
+}
+
+function typeText(meterType) {
+ const map = { WATER: '姘磋〃', ELECTRIC: '鐢佃〃', GAS: '钂告苯琛�' }
+ return map[meterType] || meterType || '--'
+}
+
+function typeTag(meterType) {
+ if (meterType === 'ELECTRIC') {
+ return 'warning'
+ }
+ if (meterType === 'GAS') {
+ return 'success'
+ }
+ return 'primary'
+}
+
+function unitText(meterType) {
+ return unitMap[meterType] || 'm鲁'
+}
+
+function locationPlaceholder(meterType) {
+ if (meterType === 'ELECTRIC') {
+ return '濡傦細涓�鍙锋ゼ涓�灞傞厤鐢甸棿'
+ }
+ if (meterType === 'GAS') {
+ return '濡傦細涓�鍙锋ゼ涓�灞傝捀姹借〃绠�'
+ }
+ return '濡傦細浜屽彿妤间竴灞傛按琛ㄤ簳'
+}
+
+function readingDate(row) {
+ const value = row.measureTime || ''
+ return value ? value.slice(0, 10) : '--'
+}
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num.toFixed(3).replace(/\.?0+$/, '')
+}
+
+function disableAfterToday(date) {
+ return dayjs(date).isAfter(dayjs(), 'day')
+}
+
+function disableAfterYesterday(date) {
+ return dayjs(date).isAfter(dayjs().subtract(1, 'day'), 'day')
+}
+
+function disableReadingDate(date) {
+ if (dayjs(date).isAfter(dayjs(), 'day')) {
+ return true
+ }
+ const device = readingDialog.device
+ if (device && device.initialReadingDate) {
+ return dayjs(date).isBefore(dayjs(device.initialReadingDate), 'day')
+ }
+ return false
+}
+</script>
+
+<style lang="scss" scoped>
+.meter-ledger {
+ padding-bottom: 24px;
+}
+
+/* ---------------- 椤靛ご ---------------- */
+.page-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-end;
+ justify-content: space-between;
+ gap: 12px;
+ margin-bottom: 14px;
+}
+
+.page-title {
+ font-size: 20px;
+ font-weight: 600;
+ color: #1f2d3d;
+ line-height: 1.3;
+}
+
+.page-head-actions {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+/* 鏂板鑿滃崟锛氭寜姘磋〃/鐢佃〃/姘旇〃鍒嗙粍 */
+.add-menu {
+ display: flex;
+ flex-direction: column;
+}
+
+.add-group {
+ padding: 6px 2px;
+}
+
+.add-group + .add-group {
+ border-top: 1px solid #f0f2f5;
+}
+
+.add-group-title {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 2px 8px 6px;
+ font-size: 12px;
+ font-weight: 600;
+ color: #303133;
+}
+
+.add-dot {
+ width: 7px;
+ height: 7px;
+ border-radius: 50%;
+ background: #8c9bb3;
+}
+
+.add-dot.water {
+ background: #2f6fe4;
+}
+
+.add-dot.electric {
+ background: #ef8a1f;
+}
+
+.add-dot.gas {
+ background: #23a26a;
+}
+
+.add-option {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 1px;
+ width: 100%;
+ padding: 6px 8px;
+ border: 0;
+ border-radius: 6px;
+ background: transparent;
+ text-align: left;
+ cursor: pointer;
+}
+
+.add-option:hover {
+ background: #f5f9ff;
+}
+
+.add-option-label {
+ font-size: 13px;
+ line-height: 1.3;
+ color: #303133;
+}
+
+.add-option-hint {
+ font-size: 11px;
+ line-height: 1.3;
+ color: #a8abb2;
+}
+
+/* ---------------- 绫诲瀷鍒囨崲 ---------------- */
+.type-switch {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 12px;
+ margin-bottom: 12px;
+}
+
+.type-card {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 14px 16px;
+ border: 1px solid #ebeef5;
+ border-radius: 10px;
+ background: #fff;
+ cursor: pointer;
+ transition: all 0.2s;
+
+ &:hover {
+ border-color: #c6d9f5;
+ box-shadow: 0 4px 14px rgba(31, 45, 61, 0.06);
+ }
+
+ &.active {
+ border-color: #3d7eff;
+ box-shadow: 0 4px 16px rgba(61, 126, 255, 0.14);
+ background: linear-gradient(180deg, #f5f9ff 0%, #ffffff 100%);
+ }
+}
+
+.type-badge {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 38px;
+ height: 38px;
+ border-radius: 10px;
+ font-size: 16px;
+ font-weight: 600;
+ color: #fff;
+ background: #8c9bb3;
+ flex-shrink: 0;
+}
+
+.type-card.water .type-badge {
+ background: linear-gradient(135deg, #4d9dff 0%, #2f6fe4 100%);
+}
+
+.type-card.electric .type-badge {
+ background: linear-gradient(135deg, #ffb45c 0%, #ef8a1f 100%);
+}
+
+.type-card.gas .type-badge {
+ background: linear-gradient(135deg, #5fd39a 0%, #23a26a 100%);
+}
+
+.type-info {
+ min-width: 0;
+}
+
+.type-name {
+ font-size: 14px;
+ font-weight: 500;
+ color: #1f2d3d;
+}
+
+.type-count {
+ margin-top: 2px;
+ font-size: 12px;
+ color: #909399;
+
+ b {
+ font-size: 18px;
+ font-weight: 600;
+ color: #1f2d3d;
+ margin-right: 2px;
+ }
+}
+
+/* ---------------- 绛涢�� ---------------- */
+.filter-bar {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 10px;
+ padding: 12px 16px;
+ margin-bottom: 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 10px;
+ background: #fff;
+}
+
+.filter-keyword {
+ width: 240px;
+}
+
+.filter-summary {
+ margin-left: auto;
+ font-size: 13px;
+ color: #909399;
+
+ b {
+ color: #1f2d3d;
+ font-weight: 600;
+ }
+}
+
+/* ---------------- 琛ㄦ牸 ---------------- */
+.table-card {
+ padding: 6px 16px 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 10px;
+ background: #fff;
+}
+
+.ledger-table {
+ :deep(.el-table__header th) {
+ background: #fafbfc;
+ color: #909399;
+ font-weight: 500;
+ font-size: 12px;
+ border-bottom: 1px solid #f0f2f5;
+ }
+
+ :deep(.el-table__cell) {
+ padding: 7px 0;
+ }
+
+ :deep(.el-table__row > td) {
+ border-bottom: 1px solid #f5f7fa;
+ }
+
+ :deep(.el-table__row:hover > td) {
+ background: #f7faff;
+ }
+
+ /* 琛ㄥ彿绛夌紪鍙峰垪锛氱瓑瀹芥暟瀛椼�佸急鍖栭鑹� */
+ :deep(.col-mono .cell) {
+ color: #606266;
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ }
+
+ :deep(.el-table__inner-wrapper::before) {
+ display: none;
+ }
+}
+
+.device-cell {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ min-width: 0;
+}
+
+/* 鍗曡灞曠ず锛氬浘鏍� + 鍚嶇О + 鏍囪 */
+.name-cell {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ white-space: nowrap;
+}
+
+.name-cell .device-name {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ display: block;
+}
+
+
+.device-text {
+ min-width: 0;
+}
+
+.device-name {
+ font-size: 13px;
+ font-weight: 500;
+ color: #1f2d3d;
+ line-height: 1.4;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+}
+
+.device-name.sub-line {
+ font-weight: 400;
+ color: #303133;
+}
+
+.device-sub {
+ margin-top: 2px;
+ font-size: 12px;
+ color: #a8abb2;
+ line-height: 1.4;
+}
+
+.collect-mode {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ font-size: 12px;
+
+ i {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: #909399;
+ }
+
+ &.auto {
+ color: #2f9e6e;
+
+ i {
+ background: #2f9e6e;
+ }
+ }
+
+ &.manual {
+ color: #909399;
+ }
+}
+
+
+.num {
+ font-size: 13px;
+ font-weight: 600;
+ color: #1f2d3d;
+ font-variant-numeric: tabular-nums;
+}
+
+/* 涓婃湡璇绘暟寮卞寲涓�绾э紝绐佸嚭鏈�鏂拌鏁� */
+.num.prev {
+ font-weight: 500;
+ color: #606266;
+}
+
+.num-unit {
+ margin-left: 3px;
+ font-size: 11px;
+ font-weight: 400;
+ color: #a8abb2;
+}
+
+.cell-actions {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 12px;
+ flex-wrap: nowrap;
+ white-space: nowrap;
+
+ :deep(.el-button) {
+ margin-left: 0;
+ padding: 0;
+ font-size: 12px;
+ }
+}
+
+.empty-box {
+ padding: 16px 0;
+}
+
+.table-footer {
+ display: flex;
+ justify-content: flex-end;
+ padding-top: 12px;
+}
+
+/* ---------------- 寮圭獥鍐呯殑閫氱敤鏍峰紡 ---------------- */
+.item-tip {
+ margin-left: 4px;
+ font-size: 12px;
+ color: #909399;
+}
+
+.btn-disabled {
+ display: inline-block;
+ padding: 0 8px;
+}
+
+.field-tip {
+ margin-left: 8px;
+ font-size: 12px;
+ line-height: 1.5;
+ color: #909399;
+}
+
+.reading-device {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.readings-panel {
+ padding: 0 4px 24px;
+}
+
+.readings-pagination {
+ margin: 12px 0 0;
+ justify-content: flex-end;
+}
+
+.collect-devices {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+}
+
+.dialog-tip {
+ padding: 8px 12px;
+ border-radius: 4px;
+ background: #f4f4f5;
+ font-size: 12px;
+ line-height: 1.6;
+ color: #909399;
+}
+</style>
diff --git a/src/views/energyManagement/realtime/index.vue b/src/views/energyManagement/realtime/index.vue
new file mode 100644
index 0000000..e9e0ec5
--- /dev/null
+++ b/src/views/energyManagement/realtime/index.vue
@@ -0,0 +1,847 @@
+<template>
+ <div class="app-container energy-realtime">
+ <div class="page-head">
+ <div class="head-text">
+ <h2>鑳借�楀疄鏃剁洃鎺�</h2>
+ <p>瀹炴椂灞曠ず姘淬�佺數銆佽捀姹芥秷鑰楁儏鍐碉紱鐢佃〃涓� 15 鍒嗛挓瀹炴椂鏁版嵁锛屾按琛� / 钂告苯琛ㄤ负鏃ュ喕缁撴暟鎹紝浠ユ渶杩戜竴涓湁鏁版嵁鐨勪笟鍔℃棩鍛堢幇銆�</p>
+ </div>
+ <div class="head-actions">
+ <span class="update-time">鏇存柊浜� {{ generatedAtText }}</span>
+ <el-switch v-model="autoRefresh" active-text="鑷姩鍒锋柊" />
+ <el-button type="primary" :loading="loading" @click="load()">鍒锋柊</el-button>
+ </div>
+ </div>
+
+ <div v-if="scopedMeter" class="scope-bar">
+ <span>褰撳墠鏌ョ湅鍗曞彴璁惧锛�<b>{{ overview.scopeLabel || ('璁惧 #' + scopedMeter) }}</b></span>
+ <el-button link type="primary" @click="clearScope">鏌ョ湅鍏ㄩ儴琛ㄥ叿</el-button>
+ </div>
+
+ <el-alert
+ v-if="overview.mockMode"
+ class="mock-alert"
+ type="info"
+ :closable="false"
+ show-icon
+ title="褰撳墠涓烘紨绀烘暟鎹ā寮忥細鏈厤缃涓夋柟鎺堟潈鐮侊紝瀹炴椂鏁版嵁鐢辨湰鍦版ā鎷熺敓鎴愶紝浠呯敤浜庤仈璋冧笌椤甸潰婕旂ず銆�"
+ />
+
+ <div class="media-grid">
+ <section
+ v-for="item in mediaList"
+ :key="item.meterType"
+ class="media-card"
+ :class="'media-' + item.meterType.toLowerCase()"
+ >
+ <div class="card-head">
+ <span class="media-badge">{{ mediumShort(item.meterType) }}</span>
+ <div class="card-title">
+ <h3>{{ item.meterName }}</h3>
+ <span>{{ item.deviceCount }} 鍙拌澶�</span>
+ </div>
+ </div>
+
+ <div class="card-value">
+ <span class="num">{{ formatNumber(item.latestUsage) }}</span>
+ <span class="unit">{{ displayUnit(item.unit) }}</span>
+ <span class="date">{{ item.latestUsageDate ? item.latestUsageDate.slice(5) + ' 鐢ㄩ噺' : '鏆傛棤鐢ㄩ噺' }}</span>
+ </div>
+
+ <div class="compare-line">
+ <span :class="['compare', compareClass(item.compareRate)]">
+ {{ compareText(item.compareRate) }}
+ </span>
+ <span class="compare-label">杈冧笂涓�涓氬姟鏃�</span>
+ <span v-if="item.previousUsage != null" class="previous">
+ 涓婁竴鏃� {{ formatNumber(item.previousUsage) }}
+ </span>
+ </div>
+
+ <div class="card-stats">
+ <div>
+ <span>鏈湀绱</span>
+ <b>{{ formatNumber(item.monthTotal) }}<i>{{ displayUnit(item.unit) }}</i></b>
+ </div>
+ <div>
+ <span>杩� 7 鏃ユ棩鍧�</span>
+ <b>{{ formatNumber(item.avgDaily) }}<i>{{ displayUnit(item.unit) }}</i></b>
+ </div>
+ <div>
+ <span>鏈�杩戦噰闆�</span>
+ <b class="time">{{ shortTime(item.lastSuccessAt) }}</b>
+ </div>
+ </div>
+
+ <div v-if="item.meterType === 'ELECTRIC'" class="electric-extra">
+ <span>褰撳墠鏈夊姛鍔熺巼 <b>{{ formatNumber(item.currentPower) }} kW</b></span>
+ <span>鍔熺巼鍥犳暟 <b>{{ formatNumber(item.powerFactor) }}</b></span>
+ </div>
+ </section>
+ </div>
+
+ <el-row :gutter="12" class="main-row">
+ <el-col :xs="24" :lg="15">
+ <section class="panel">
+ <div class="panel-head">
+ <div class="panel-title">杩� 7 鏃ヨ兘鑰楄秼鍔�</div>
+ <div class="legend">
+ <span><i class="dot water"></i>姘� m鲁</span>
+ <span><i class="dot gas"></i>钂告苯 m鲁</span>
+ <span><i class="dot electric"></i>鐢� 搴�</span>
+ </div>
+ </div>
+ <div ref="trendRef" class="chart chart-trend"></div>
+ </section>
+ </el-col>
+ <el-col :xs="24" :lg="9">
+ <section class="panel">
+ <div class="panel-head">
+ <div class="panel-title">鐢佃〃浠婃棩瀹炴椂璐熻嵎</div>
+ <span class="panel-range">{{ electricRangeText }}</span>
+ </div>
+ <template v-if="hasElectricCurve">
+ <div class="electric-stats">
+ <div>
+ <span>浠婃棩绱鐢ㄧ數</span>
+ <b>{{ formatNumber(overview.electric.todayTotal) }}<i>搴�</i></b>
+ </div>
+ <div>
+ <span>褰撳墠鍔熺巼</span>
+ <b>{{ formatNumber(overview.electric.currentPower) }}<i>kW</i></b>
+ </div>
+ <div>
+ <span>鍔熺巼鍥犳暟</span>
+ <b>{{ formatNumber(overview.electric.powerFactor) }}</b>
+ </div>
+ </div>
+ <div ref="electricRef" class="chart chart-electric"></div>
+ </template>
+ <el-empty v-else description="鏆傛棤 15 鍒嗛挓瀹炴椂鏁版嵁" :image-size="60" />
+ </section>
+ </el-col>
+ </el-row>
+
+ <section class="panel alerts-panel">
+ <div class="panel-head">
+ <div class="panel-title">杩愯鎻愮ず</div>
+ <span class="panel-range">鍏� {{ alerts.length }} 鏉�</span>
+ </div>
+ <div v-if="alerts.length" class="alert-list">
+ <div v-for="(item, index) in alerts" :key="index" :class="['alert-item', item.level]">
+ <span class="alert-dot"></span>
+ <span class="alert-text">{{ item.text }}</span>
+ </div>
+ </div>
+ <div v-else class="alert-empty">
+ 姘淬�佺數銆佽捀姹戒笁绫讳粙璐ㄩ噰闆嗘甯革紝鏆傛棤闇�瑕佸鐞嗙殑鎻愮ず銆�
+ </div>
+ </section>
+ </div>
+</template>
+
+<script setup>
+import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
+import { useRoute, useRouter } from 'vue-router'
+import * as echarts from 'echarts'
+import { getEnergyRealtimeOverview } from '@/api/energyManagement/energyMeter'
+
+defineOptions({ name: 'EnergyRealtimeMonitor' })
+
+const route = useRoute()
+const router = useRouter()
+
+const COLOR_WATER = '#409eff'
+const COLOR_ELECTRIC = '#e6a23c'
+const COLOR_GAS = '#21a675'
+const MEDIA_ORDER = { WATER: 0, ELECTRIC: 1, GAS: 2 }
+
+const loading = ref(false)
+const autoRefresh = ref(true)
+const overview = ref({ media: [], trend: [], alerts: [] })
+
+const trendRef = ref(null)
+const electricRef = ref(null)
+const charts = {}
+let timer = null
+
+const scopedMeter = computed(() => {
+ const value = route.query.meterId
+ return value ? Number(value) : null
+})
+
+const mediaList = computed(() => [...(overview.value.media || [])]
+ .sort((a, b) => (MEDIA_ORDER[a.meterType] ?? 9) - (MEDIA_ORDER[b.meterType] ?? 9)))
+
+const alerts = computed(() => overview.value.alerts || [])
+
+const generatedAtText = computed(() => shortTime(overview.value.generatedAt))
+
+const electricRangeText = computed(() => {
+ const electric = overview.value.electric
+ if (!electric) {
+ return '--'
+ }
+ return `${electric.rangeStart || '00:00'} ~ ${electric.rangeEnd || '--'}`
+})
+
+const hasElectricCurve = computed(() => {
+ const electric = overview.value.electric
+ return Boolean(electric && Array.isArray(electric.series)
+ && electric.series.some((item) => item.power != null))
+})
+
+onMounted(() => {
+ load()
+ startTimer()
+ window.addEventListener('resize', handleResize)
+})
+
+onBeforeUnmount(() => {
+ window.removeEventListener('resize', handleResize)
+ stopTimer()
+ disposeCharts()
+})
+
+watch(autoRefresh, (value) => {
+ if (value) {
+ startTimer()
+ } else {
+ stopTimer()
+ }
+})
+
+watch(() => route.query.meterId, () => {
+ load()
+})
+
+async function load(silent = false) {
+ if (!silent) {
+ loading.value = true
+ }
+ const params = {}
+ if (scopedMeter.value) {
+ params.meterId = scopedMeter.value
+ }
+ try {
+ const res = await getEnergyRealtimeOverview(params)
+ overview.value = res.data || { media: [], trend: [], alerts: [] }
+ await nextTick()
+ renderCharts()
+ } catch (e) {
+ overview.value = { media: [], trend: [], alerts: [] }
+ } finally {
+ loading.value = false
+ }
+}
+
+function startTimer() {
+ stopTimer()
+ timer = setInterval(() => load(true), 60 * 1000)
+}
+
+function stopTimer() {
+ if (timer) {
+ clearInterval(timer)
+ timer = null
+ }
+}
+
+function handleResize() {
+ Object.keys(charts).forEach((key) => charts[key] && charts[key].resize())
+}
+
+function disposeCharts() {
+ Object.keys(charts).forEach((key) => {
+ charts[key] && charts[key].dispose()
+ delete charts[key]
+ })
+}
+
+function initChart(refEl, key) {
+ if (!refEl) {
+ return null
+ }
+ if (!charts[key]) {
+ charts[key] = echarts.init(refEl)
+ }
+ return charts[key]
+}
+
+function renderCharts() {
+ renderTrend()
+ renderElectric()
+}
+
+function renderTrend() {
+ const chart = initChart(trendRef.value, 'trend')
+ if (!chart) {
+ return
+ }
+ const trend = overview.value.trend || []
+ const hasData = trend.some((item) => item.water != null || item.electric != null || item.gas != null)
+ chart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: { type: 'line' },
+ valueFormatter: (value) => (value == null ? '鏆傛棤鏁版嵁' : Number(value).toFixed(3).replace(/\.?0+$/, ''))
+ },
+ grid: { left: 48, right: 52, top: 24, bottom: 28 },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: trend.map((item) => item.day.slice(5)),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: { color: '#909399', fontSize: 11 }
+ },
+ yAxis: [
+ {
+ type: 'value',
+ name: 'm鲁',
+ nameTextStyle: { color: '#909399', fontSize: 11 },
+ axisLabel: { color: '#909399', fontSize: 11 },
+ splitLine: { lineStyle: { type: 'dashed', color: '#f0f2f5' } }
+ },
+ {
+ type: 'value',
+ name: '搴�',
+ nameTextStyle: { color: '#909399', fontSize: 11 },
+ axisLabel: { color: '#909399', fontSize: 11 },
+ splitLine: { show: false }
+ }
+ ],
+ series: [
+ lineSeries('姘�', trend.map((item) => item.water), COLOR_WATER, 0),
+ lineSeries('钂告苯', trend.map((item) => item.gas), COLOR_GAS, 0),
+ lineSeries('鐢�', trend.map((item) => item.electric), COLOR_ELECTRIC, 1)
+ ],
+ graphic: hasData ? [] : emptyGraphic()
+ },
+ true
+ )
+ chart.resize()
+}
+
+function lineSeries(name, data, color, yAxisIndex) {
+ return {
+ name,
+ type: 'line',
+ smooth: true,
+ symbol: 'circle',
+ symbolSize: 5,
+ connectNulls: false,
+ yAxisIndex,
+ data,
+ lineStyle: { width: 2, color },
+ itemStyle: { color },
+ emphasis: { focus: 'series' }
+ }
+}
+
+function renderElectric() {
+ const electric = overview.value.electric
+ const series = electric ? (electric.series || []).filter((item) => item.power != null) : []
+ if (!series.length) {
+ if (charts.electric) {
+ charts.electric.dispose()
+ delete charts.electric
+ }
+ return
+ }
+ const chart = initChart(electricRef.value, 'electric')
+ if (!chart) {
+ return
+ }
+ chart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ formatter: (params) => {
+ const item = params && params[0]
+ if (!item) {
+ return ''
+ }
+ return `${item.axisValue}<br/>鏈夊姛鍔熺巼锛�${formatNumber(item.value)} kW`
+ }
+ },
+ grid: { left: 46, right: 16, top: 20, bottom: 26 },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: series.map((item) => item.time),
+ axisTick: { show: false },
+ axisLine: { lineStyle: { color: '#e4e7ed' } },
+ axisLabel: { color: '#909399', fontSize: 10, interval: Math.max(Math.floor(series.length / 6), 0) }
+ },
+ yAxis: {
+ type: 'value',
+ name: 'kW',
+ nameTextStyle: { color: '#909399', fontSize: 11 },
+ axisLabel: { color: '#909399', fontSize: 10 },
+ splitLine: { lineStyle: { type: 'dashed', color: '#f0f2f5' } }
+ },
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ showSymbol: false,
+ data: series.map((item) => item.power),
+ lineStyle: { width: 2, color: COLOR_ELECTRIC },
+ areaStyle: {
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
+ { offset: 0, color: 'rgba(230, 162, 60, 0.28)' },
+ { offset: 1, color: 'rgba(230, 162, 60, 0.02)' }
+ ])
+ }
+ }
+ ]
+ },
+ true
+ )
+ chart.resize()
+}
+
+function emptyGraphic() {
+ return [{ type: 'text', left: 'center', top: 'middle', style: { text: '鏆傛棤鏁版嵁', fill: '#c0c4cc', fontSize: 13 } }]
+}
+
+function clearScope() {
+ router.replace({ path: '/energyManagement/realtimeMonitor' })
+}
+
+function mediumShort(meterType) {
+ return { WATER: '姘�', ELECTRIC: '鐢�', GAS: '钂告苯' }[meterType] || meterType
+}
+
+function displayUnit(unit) {
+ if (!unit) {
+ return ''
+ }
+ if (unit === 'm3') {
+ return 'm鲁'
+ }
+ if (unit === 'kWh') {
+ return '搴�'
+ }
+ return unit
+}
+
+function compareClass(rate) {
+ if (rate == null || Number(rate) === 0) {
+ return 'flat'
+ }
+ return Number(rate) > 0 ? 'up' : 'down'
+}
+
+function compareText(rate) {
+ if (rate == null) {
+ return '鈥�'
+ }
+ const value = Number(rate)
+ if (value === 0) {
+ return '鎸佸钩'
+ }
+ return `${value > 0 ? '鈫�' : '鈫�'} ${Math.abs(value).toFixed(1)}%`
+}
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num.toFixed(3).replace(/\.?0+$/, '')
+}
+
+function shortTime(value) {
+ if (!value) {
+ return '--'
+ }
+ return String(value).length > 16 ? String(value).slice(0, 16) : value
+}
+</script>
+
+<style lang="scss" scoped>
+.energy-realtime {
+ padding-bottom: 24px;
+}
+
+.page-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+ margin-bottom: 14px;
+
+ h2 {
+ margin: 0 0 4px;
+ font-size: 18px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ p {
+ margin: 0;
+ font-size: 12px;
+ color: #909399;
+ }
+}
+
+.head-actions {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+}
+
+.update-time {
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.scope-bar {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 8px 14px;
+ margin-bottom: 12px;
+ font-size: 13px;
+ color: #606266;
+ background: #f4f8ff;
+ border: 1px solid #d9ecff;
+ border-radius: 6px;
+
+ b {
+ color: #2f7fd8;
+ font-weight: 500;
+ }
+}
+
+.mock-alert {
+ margin-bottom: 12px;
+}
+
+.media-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
+ gap: 12px;
+}
+
+.media-card {
+ padding: 14px 16px 12px;
+ border: 1px solid #ebeef5;
+ border-top: 3px solid #409eff;
+ border-radius: 8px;
+ background: #fff;
+
+ &.media-electric {
+ border-top-color: #e6a23c;
+ }
+
+ &.media-gas {
+ border-top-color: #21a675;
+ }
+}
+
+.card-head {
+ display: flex;
+ align-items: flex-start;
+ gap: 10px;
+}
+
+.media-badge {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 34px;
+ height: 34px;
+ flex: 0 0 34px;
+ border-radius: 9px;
+ background: #eef5ff;
+ color: #2f7fd8;
+ font-size: 14px;
+ font-weight: 600;
+
+ .media-electric & {
+ background: #fdf6ec;
+ color: #c98a24;
+ }
+
+ .media-gas & {
+ background: #ecf8f2;
+ color: #1d8f66;
+ }
+}
+
+.card-title {
+ flex: 1;
+ min-width: 0;
+
+ h3 {
+ margin: 0 0 3px;
+ font-size: 15px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ span {
+ font-size: 12px;
+ color: #909399;
+ }
+}
+
+.card-value {
+ display: flex;
+ align-items: baseline;
+ gap: 5px;
+ margin: 14px 0 6px;
+
+ .num {
+ font-size: 30px;
+ font-weight: 600;
+ line-height: 1.1;
+ color: #303133;
+ }
+
+ .unit {
+ font-size: 13px;
+ color: #909399;
+ }
+
+ .date {
+ margin-left: auto;
+ font-size: 12px;
+ color: #c0c4cc;
+ }
+}
+
+.compare-line {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 12px;
+ color: #909399;
+
+ .compare {
+ font-weight: 600;
+
+ &.up {
+ color: #f56c6c;
+ }
+
+ &.down {
+ color: #21a675;
+ }
+
+ &.flat {
+ color: #909399;
+ }
+ }
+
+ .previous {
+ margin-left: auto;
+ color: #a8abb2;
+ }
+}
+
+.card-stats {
+ display: flex;
+ gap: 6px;
+ margin-top: 12px;
+
+ > div {
+ flex: 1;
+ padding: 7px 9px;
+ border-radius: 6px;
+ background: #f7f9fc;
+
+ span {
+ display: block;
+ font-size: 11px;
+ color: #909399;
+ }
+
+ b {
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+
+ i {
+ margin-left: 2px;
+ font-size: 11px;
+ font-style: normal;
+ font-weight: 400;
+ color: #a8abb2;
+ }
+
+ &.time {
+ font-size: 12px;
+ font-weight: 400;
+ color: #606266;
+ }
+ }
+ }
+}
+
+.electric-extra {
+ display: flex;
+ gap: 16px;
+ margin-top: 10px;
+ padding-top: 9px;
+ border-top: 1px dashed #ebeef5;
+ font-size: 12px;
+ color: #909399;
+
+ b {
+ color: #303133;
+ font-weight: 600;
+ }
+}
+
+.main-row {
+ margin-top: 12px;
+}
+
+.panel {
+ padding: 14px 16px;
+ margin-bottom: 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 8px;
+ background: #fff;
+}
+
+.panel-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ margin-bottom: 10px;
+}
+
+.panel-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+}
+
+.panel-range {
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.legend {
+ display: flex;
+ gap: 14px;
+ font-size: 12px;
+ color: #606266;
+
+ .dot {
+ display: inline-block;
+ width: 8px;
+ height: 8px;
+ margin-right: 4px;
+ border-radius: 50%;
+
+ &.water {
+ background: #409eff;
+ }
+
+ &.electric {
+ background: #e6a23c;
+ }
+
+ &.gas {
+ background: #21a675;
+ }
+ }
+}
+
+.electric-stats {
+ display: flex;
+ gap: 8px;
+ margin-bottom: 8px;
+
+ > div {
+ flex: 1;
+ padding: 7px 9px;
+ border-radius: 6px;
+ background: #f7f9fc;
+
+ span {
+ display: block;
+ font-size: 11px;
+ color: #909399;
+ }
+
+ b {
+ font-size: 15px;
+ color: #303133;
+
+ i {
+ margin-left: 2px;
+ font-size: 11px;
+ font-style: normal;
+ font-weight: 400;
+ color: #a8abb2;
+ }
+ }
+ }
+}
+
+.chart {
+ width: 100%;
+}
+
+.chart-trend {
+ height: 300px;
+}
+
+.chart-electric {
+ height: 218px;
+}
+
+.alerts-panel {
+ margin-top: 0;
+}
+
+.alert-list {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+}
+
+.alert-item {
+ display: flex;
+ align-items: flex-start;
+ gap: 8px;
+ padding: 8px 12px;
+ border-radius: 6px;
+ font-size: 13px;
+ background: #fdf6ec;
+ color: #8a5a12;
+
+ &.info {
+ background: #f4f8ff;
+ color: #2f5f96;
+ }
+
+ .alert-dot {
+ width: 6px;
+ height: 6px;
+ margin-top: 6px;
+ border-radius: 50%;
+ background: currentColor;
+ flex: 0 0 6px;
+ }
+}
+
+.alert-empty {
+ padding: 10px 0;
+ font-size: 13px;
+ color: #909399;
+}
+</style>
diff --git a/src/views/energyManagement/waterElectricMeter/components/DeviceFormDialog.vue b/src/views/energyManagement/waterElectricMeter/components/DeviceFormDialog.vue
new file mode 100644
index 0000000..8ce8667
--- /dev/null
+++ b/src/views/energyManagement/waterElectricMeter/components/DeviceFormDialog.vue
@@ -0,0 +1,287 @@
+<template>
+ <el-dialog
+ v-model="visible"
+ :title="(isEdit ? '缂栬緫' : '鏂板') + typeName"
+ width="640px"
+ append-to-body
+ destroy-on-close
+ @closed="handleClosed"
+ >
+ <el-form ref="formRef" :model="form" :rules="rules" label-width="108px" v-loading="submitting">
+ <!-- 鏂板鏃惰兘婧愮被鍨嬬敱鍏ュ彛鍥哄畾锛屼笉鍐嶆彁渚涙按/鐢靛垏鎹� -->
+ <el-form-item v-if="!isEdit" label="鑳芥簮绫诲瀷">
+ <el-tag :type="typeTag" size="small" effect="plain">{{ typeName }}</el-tag>
+ <span class="type-tip">鎸夋柊澧炲叆鍙h嚜鍔ㄥ甫鍏ワ紝涓嶅彲淇敼</span>
+ </el-form-item>
+
+ <el-form-item v-if="!isEdit" label="閫氫俊鍦板潃" prop="meterAddress">
+ <div class="address-row">
+ <el-input
+ v-model="form.meterAddress"
+ placeholder="璇疯緭鍏ョ涓夋柟閫氫俊鍦板潃锛屼繚鐣欏墠瀵奸浂"
+ clearable
+ style="flex: 1"
+ @keyup.enter="handleVerify"
+ />
+ <el-button type="primary" plain :loading="verifying" @click="handleVerify">
+ 楠岃瘉骞惰鍙栨。妗�
+ </el-button>
+ </div>
+ <div class="field-tip">璁惧绫诲瀷涓庨�氫俊鍦板潃鍏卞悓鐢ㄤ簬鍖归厤绗笁鏂规。妗堬紝淇濆瓨鍓嶅繀椤婚獙璇侀�氳繃銆�</div>
+ </el-form-item>
+ <el-form-item v-else label="閫氫俊鍦板潃">
+ <el-input v-model="form.meterAddress" disabled />
+ <div class="field-tip">閫氫俊鍦板潃鍙樻洿闇�鍋滅敤鏃х粦瀹氬悗閲嶆柊楠岃瘉锛屽巻鍙查噰闆嗚褰曚粛褰掑睘鏃ц澶囥��</div>
+ </el-form-item>
+
+ <el-alert
+ v-if="archive"
+ :type="archive.bindable ? 'success' : 'warning'"
+ :closable="false"
+ show-icon
+ class="archive-alert"
+ >
+ <template #title>{{ archive.message }}</template>
+ <div class="archive-grid">
+ <span>绗笁鏂笽D锛歿{ archive.providerMeterId || '--' }}</span>
+ <span>鍚嶇О锛歿{ archive.providerName || '--' }}</span>
+ <span>鍖哄煙锛歿{ archive.areaName || '--' }}</span>
+ <span>鍦ㄧ嚎鐘舵�侊細{{ onlineText(archive.onlineStatus) }}</span>
+ </div>
+ </el-alert>
+ <el-alert
+ v-else-if="verifyError"
+ type="error"
+ :title="verifyError"
+ :closable="false"
+ show-icon
+ class="archive-alert"
+ />
+
+ <el-form-item label="鏄剧ず鍚嶇О" prop="displayName">
+ <el-input v-model="form.displayName" placeholder="榛樿浣跨敤绗笁鏂瑰悕绉�" maxlength="128" />
+ </el-form-item>
+
+ <el-form-item label="瀹夎浣嶇疆">
+ <el-input v-model="form.location" maxlength="255" :placeholder="locationPlaceholder" />
+ </el-form-item>
+
+ <el-form-item v-if="isEdit" label="鍚敤鐘舵��">
+ <el-switch
+ v-model="form.enabled"
+ :active-value="1"
+ :inactive-value="0"
+ active-text="鍚敤"
+ inactive-text="鍋滅敤"
+ />
+ <div class="field-tip">鍋滅敤涓嶅垹闄ゅ巻鍙茶褰曪紱閲嶆柊鍚敤鍚庢寜杩涘害琛ラ噰鍋滅敤鏈熼棿鏁版嵁銆�</div>
+ </el-form-item>
+ </el-form>
+
+ <template #footer>
+ <el-button @click="visible = false">鍙� 娑�</el-button>
+ <el-button
+ type="primary"
+ :loading="submitting"
+ :disabled="!isEdit && !(archive && archive.bindable)"
+ @click="handleSubmit"
+ >
+ 纭� 瀹�
+ </el-button>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup>
+import { computed, nextTick, reactive, ref } from 'vue'
+import { ElMessage } from 'element-plus'
+import { addMeterDevice, updateMeterDevice, verifyMeterDevice } from '@/api/energyManagement/energyMeter'
+
+const props = defineProps({
+ defaultMeterType: {
+ type: String,
+ default: 'WATER'
+ }
+})
+
+const emit = defineEmits(['success'])
+
+const visible = ref(false)
+const isEdit = ref(false)
+const submitting = ref(false)
+const verifying = ref(false)
+const verifyError = ref('')
+const archive = ref(null)
+const formRef = ref(null)
+const currentId = ref(null)
+
+const form = reactive({
+ meterType: 'WATER',
+ meterAddress: '',
+ displayName: '',
+ location: '',
+ enabled: 1
+})
+
+const typeName = computed(() => {
+ const map = { WATER: '姘磋〃', ELECTRIC: '鐢佃〃', GAS: '姘旇〃' }
+ return map[form.meterType] || '璁惧'
+})
+
+const typeTag = computed(() => {
+ if (form.meterType === 'ELECTRIC') {
+ return 'warning'
+ }
+ if (form.meterType === 'GAS') {
+ return 'success'
+ }
+ return 'primary'
+})
+
+const locationPlaceholder = computed(() => {
+ if (form.meterType === 'ELECTRIC') {
+ return '濡傦細涓�鍙锋ゼ涓�灞傞厤鐢甸棿'
+ }
+ if (form.meterType === 'GAS') {
+ return '濡傦細涓�鍙锋ゼ涓�灞傜噧姘旇〃绠�'
+ }
+ return '濡傦細涓�鍙锋ゼ涓�灞傛按琛ㄤ簳'
+})
+
+const rules = {
+ meterType: [{ required: true, message: '璇烽�夋嫨鑳芥簮绫诲瀷', trigger: 'change' }],
+ meterAddress: [{ required: true, message: '璇疯緭鍏ラ�氫俊鍦板潃', trigger: 'blur' }],
+ displayName: [{ required: true, message: '璇疯緭鍏ユ樉绀哄悕绉�', trigger: 'blur' }]
+}
+
+function open(mode, row, meterType) {
+ isEdit.value = mode === 'edit'
+ currentId.value = row ? row.id : null
+ archive.value = null
+ verifyError.value = ''
+ if (row) {
+ form.meterType = row.meterType
+ form.meterAddress = row.meterAddress
+ form.displayName = row.displayName
+ form.location = row.location || ''
+ form.enabled = row.enabled
+ } else {
+ form.meterType = meterType || props.defaultMeterType || 'WATER'
+ form.meterAddress = ''
+ form.displayName = ''
+ form.location = ''
+ form.enabled = 1
+ }
+ visible.value = true
+ nextTick(() => formRef.value && formRef.value.clearValidate())
+}
+
+async function handleVerify() {
+ if (!form.meterAddress) {
+ ElMessage.warning('璇峰厛杈撳叆閫氫俊鍦板潃')
+ return
+ }
+ verifying.value = true
+ verifyError.value = ''
+ archive.value = null
+ try {
+ const res = await verifyMeterDevice({
+ meterType: form.meterType,
+ meterAddress: form.meterAddress.trim()
+ })
+ archive.value = res.data
+ if (res.data && res.data.bindable && !form.displayName) {
+ form.displayName = res.data.providerName || form.meterAddress
+ }
+ } catch (e) {
+ verifyError.value = (e && e.message) || '绗笁鏂规湭鎵惧埌璇ヨ〃璁�'
+ } finally {
+ verifying.value = false
+ }
+}
+
+async function handleSubmit() {
+ if (!formRef.value) {
+ return
+ }
+ const valid = await formRef.value.validate().catch(() => false)
+ if (!valid) {
+ return
+ }
+ submitting.value = true
+ try {
+ if (isEdit.value) {
+ await updateMeterDevice(currentId.value, {
+ displayName: form.displayName,
+ location: form.location,
+ enabled: form.enabled
+ })
+ ElMessage.success('璁惧淇℃伅宸叉洿鏂�')
+ } else {
+ await addMeterDevice({
+ meterType: form.meterType,
+ meterAddress: form.meterAddress.trim(),
+ displayName: form.displayName,
+ location: form.location
+ })
+ ElMessage.success('缁戝畾鎴愬姛锛屽巻鍙茶ˉ閲囦换鍔″凡鍒涘缓')
+ }
+ visible.value = false
+ emit('success')
+ } finally {
+ submitting.value = false
+ }
+}
+
+function handleClosed() {
+ archive.value = null
+ verifyError.value = ''
+ formRef.value && formRef.value.resetFields()
+}
+
+function onlineText(value) {
+ if (value === 1) {
+ return '鍦ㄧ嚎'
+ }
+ if (value === 0) {
+ return '绂荤嚎'
+ }
+ return '鏈煡'
+}
+
+defineExpose({ open })
+</script>
+
+<style scoped>
+.address-row {
+ display: flex;
+ gap: 8px;
+ width: 100%;
+}
+
+.field-tip {
+ margin-top: 4px;
+ font-size: 12px;
+ line-height: 1.5;
+ color: #909399;
+}
+
+.type-tip {
+ margin-left: 8px;
+ font-size: 12px;
+ color: #909399;
+}
+
+.archive-alert {
+ margin-bottom: 18px;
+}
+
+.archive-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 4px 12px;
+ margin-top: 6px;
+ font-size: 12px;
+ color: #606266;
+}
+</style>
diff --git a/src/views/energyManagement/waterElectricMeter/components/DeviceSidePanel.vue b/src/views/energyManagement/waterElectricMeter/components/DeviceSidePanel.vue
new file mode 100644
index 0000000..11cdd61
--- /dev/null
+++ b/src/views/energyManagement/waterElectricMeter/components/DeviceSidePanel.vue
@@ -0,0 +1,453 @@
+<template>
+ <el-drawer
+ :model-value="modelValue"
+ direction="rtl"
+ size="620px"
+ :title="device ? device.displayName : '璁惧鏁版嵁'"
+ :destroy-on-close="false"
+ @update:model-value="(val) => emit('update:modelValue', val)"
+ @open="handleOpen"
+ @closed="handleClosed"
+ >
+ <div v-if="device" class="side-panel">
+ <div class="panel-head">
+ <div class="panel-title">
+ <el-tag :type="device.meterType === 'WATER' ? 'primary' : 'warning'" effect="plain">
+ {{ device.meterType === 'WATER' ? '姘磋〃' : '鐢佃〃' }}
+ </el-tag>
+ <span class="address">{{ device.meterAddress }}</span>
+ <el-tag :type="device.enabled === 1 ? 'success' : 'info'" size="small">
+ {{ device.enabled === 1 ? '鍚敤' : '鍋滅敤' }}
+ </el-tag>
+ </div>
+ <el-button type="primary" plain size="small" @click="emit('collect', device)">鏌� 琛�</el-button>
+ </div>
+
+ <el-descriptions :column="2" border size="small" class="panel-desc">
+ <el-descriptions-item label="绗笁鏂笽D">{{ device.providerMeterId || '--' }}</el-descriptions-item>
+ <el-descriptions-item label="绗笁鏂瑰悕绉�">{{ device.providerName || '--' }}</el-descriptions-item>
+ <el-descriptions-item label="鍖哄煙">{{ device.providerAreaName || '--' }}</el-descriptions-item>
+ <el-descriptions-item label="鍦ㄧ嚎鐘舵��">
+ {{ device.onlineStatus === 1 ? '鍦ㄧ嚎' : device.onlineStatus === 0 ? '绂荤嚎' : '鏈煡' }}
+ </el-descriptions-item>
+ <el-descriptions-item label="瀹夎浣嶇疆">{{ device.location || '--' }}</el-descriptions-item>
+ <el-descriptions-item label="琛ラ噰璧风偣">{{ device.syncStartDate || '--' }}</el-descriptions-item>
+ <el-descriptions-item label="鏈�杩戞垚鍔熼噰闆�">{{ device.lastSuccessAt || '--' }}</el-descriptions-item>
+ <el-descriptions-item label="鏈�杩戦噰闆嗙粨鏋�">
+ <el-tag :type="taskTagType(device.lastTaskStatus)" size="small">
+ {{ device.collectStateText || '灏氭湭閲囬泦' }}
+ </el-tag>
+ </el-descriptions-item>
+ </el-descriptions>
+
+ <el-row :gutter="12" class="panel-cards">
+ <el-col :span="12">
+ <div class="mini-card">
+ <div class="mini-label">鏈�鏂拌〃鐮佽鏁�</div>
+ <div class="mini-value">
+ {{ latestReading != null ? formatNumber(latestReading) : '--' }}
+ <span class="mini-unit">{{ unit }}</span>
+ </div>
+ <div class="mini-sub">{{ latestReadingTime || '鏆傛棤璇绘暟' }}</div>
+ </div>
+ </el-col>
+ <el-col :span="12">
+ <div class="mini-card">
+ <div class="mini-label">鏈�杩戜竴澶╃敤閲�</div>
+ <div class="mini-value">
+ {{ device.lastDayUsage != null ? formatNumber(device.lastDayUsage) : '--' }}
+ <span class="mini-unit">{{ unit }}</span>
+ </div>
+ <div class="mini-sub">{{ device.lastDayUsageDate || '鏆傛棤鏁版嵁' }}</div>
+ </div>
+ </el-col>
+ </el-row>
+
+ <el-card shadow="never" class="panel-chart-card">
+ <template #header>
+ <div class="card-head">
+ <span>杩� 14 澶╃敤閲�</span>
+ <span class="card-sub">鍗曚綅锛歿{ unit }}</span>
+ </div>
+ </template>
+ <div v-if="trendLoading" v-loading="true" class="chart-placeholder"></div>
+ <div v-else-if="!trendData.length" class="chart-placeholder empty">鏆傛棤鏁版嵁</div>
+ <div v-show="trendData.length" ref="trendChartRef" class="chart-placeholder"></div>
+ </el-card>
+
+ <el-tabs v-model="activeTab" class="panel-tabs" @tab-change="handleTabChange">
+ <el-tab-pane label="鐢ㄩ噺璁板綍" name="usage">
+ <el-table :data="usageRows" v-loading="usageLoading" size="small" border height="260">
+ <el-table-column label="涓氬姟鏃ユ湡" width="110">
+ <template #default="scope">{{ formatDay(scope.row.measureTime) }}</template>
+ </el-table-column>
+ <el-table-column label="鐢ㄩ噺" width="110" align="right">
+ <template #default="scope">{{ formatNumber(scope.row.metricValue) }}</template>
+ </el-table-column>
+ <el-table-column prop="sourceApi" label="鏉ユ簮鎺ュ彛" min-width="130" />
+ <el-table-column label="閲囬泦鏃堕棿" min-width="150">
+ <template #default="scope">{{ scope.row.collectedAt || '--' }}</template>
+ </el-table-column>
+ </el-table>
+ <el-pagination
+ class="panel-pagination"
+ layout="total, prev, pager, next"
+ :total="usageTotal"
+ :page-size="pageSize"
+ :current-page="usagePage"
+ @current-change="handleUsagePageChange"
+ />
+ </el-tab-pane>
+ <el-tab-pane label="璇绘暟璁板綍" name="reading">
+ <el-table :data="readingRows" v-loading="readingLoading" size="small" border height="260">
+ <el-table-column label="绀哄�兼椂闂�" min-width="150">
+ <template #default="scope">{{ scope.row.measureTime }}</template>
+ </el-table-column>
+ <el-table-column label="琛ㄧ爜" width="120" align="right">
+ <template #default="scope">{{ formatNumber(scope.row.metricValue) }}</template>
+ </el-table-column>
+ <el-table-column prop="sourceApi" label="鏉ユ簮鎺ュ彛" min-width="130" />
+ <el-table-column label="閲囬泦鏃堕棿" min-width="150">
+ <template #default="scope">{{ scope.row.collectedAt || '--' }}</template>
+ </el-table-column>
+ </el-table>
+ <el-pagination
+ class="panel-pagination"
+ layout="total, prev, pager, next"
+ :total="readingTotal"
+ :page-size="pageSize"
+ :current-page="readingPage"
+ @current-change="handleReadingPageChange"
+ />
+ </el-tab-pane>
+ </el-tabs>
+ </div>
+ </el-drawer>
+</template>
+
+<script setup>
+import { computed, nextTick, ref } from 'vue'
+import * as echarts from 'echarts'
+import dayjs from 'dayjs'
+import { listMeterMeasurements } from '@/api/energyManagement/energyMeter'
+
+const props = defineProps({
+ modelValue: {
+ type: Boolean,
+ default: false
+ },
+ device: {
+ type: Object,
+ default: null
+ }
+})
+
+const emit = defineEmits(['update:modelValue', 'collect'])
+
+const activeTab = ref('usage')
+const pageSize = 10
+const usageRows = ref([])
+const usageTotal = ref(0)
+const usagePage = ref(1)
+const usageLoading = ref(false)
+const readingRows = ref([])
+const readingTotal = ref(0)
+const readingPage = ref(1)
+const readingLoading = ref(false)
+const latestReading = ref(null)
+const latestReadingTime = ref('')
+const trendData = ref([])
+const trendLoading = ref(false)
+const trendChartRef = ref(null)
+let trendChart = null
+
+const unit = computed(() => (props.device && props.device.meterType === 'WATER' ? 'm鲁' : 'kWh'))
+const usageMetric = computed(() => (props.device && props.device.meterType === 'WATER' ? 'WATER_USAGE' : 'ELECTRIC_USAGE'))
+const readingMetric = computed(() => (props.device && props.device.meterType === 'WATER' ? 'WATER_READING' : 'ELECTRIC_READING'))
+
+function handleOpen() {
+ if (!props.device) {
+ return
+ }
+ usagePage.value = 1
+ readingPage.value = 1
+ activeTab.value = 'usage'
+ loadUsage()
+ loadReading()
+ loadTrend()
+}
+
+function handleClosed() {
+ if (trendChart) {
+ trendChart.dispose()
+ trendChart = null
+ }
+}
+
+async function loadUsage() {
+ if (!props.device) {
+ return
+ }
+ usageLoading.value = true
+ try {
+ const res = await listMeterMeasurements(props.device.id, {
+ metricCode: usageMetric.value,
+ granularity: 'D',
+ current: usagePage.value,
+ size: pageSize
+ })
+ usageRows.value = (res.data && res.data.records) || []
+ usageTotal.value = (res.data && res.data.total) || 0
+ } finally {
+ usageLoading.value = false
+ }
+}
+
+async function loadReading() {
+ if (!props.device) {
+ return
+ }
+ readingLoading.value = true
+ try {
+ const res = await listMeterMeasurements(props.device.id, {
+ metricCode: readingMetric.value,
+ granularity: 'POINT',
+ current: readingPage.value,
+ size: pageSize
+ })
+ readingRows.value = (res.data && res.data.records) || []
+ readingTotal.value = (res.data && res.data.total) || 0
+ if (readingPage.value === 1 && readingRows.value.length) {
+ latestReading.value = readingRows.value[0].metricValue
+ latestReadingTime.value = readingRows.value[0].measureTime
+ }
+ } finally {
+ readingLoading.value = false
+ }
+}
+
+async function loadTrend() {
+ if (!props.device) {
+ return
+ }
+ trendLoading.value = true
+ trendData.value = []
+ try {
+ const end = dayjs().format('YYYY-MM-DD')
+ const start = dayjs().subtract(13, 'day').format('YYYY-MM-DD')
+ const res = await listMeterMeasurements(props.device.id, {
+ metricCode: usageMetric.value,
+ granularity: 'D',
+ start,
+ end,
+ current: 1,
+ size: 100
+ })
+ const records = (res.data && res.data.records) || []
+ trendData.value = records
+ .slice()
+ .sort((a, b) => (a.measureTime > b.measureTime ? 1 : -1))
+ .map((item) => ({
+ day: (item.measureTime || '').slice(5, 10),
+ value: item.metricValue
+ }))
+ await nextTick()
+ renderTrend()
+ } finally {
+ trendLoading.value = false
+ }
+}
+
+function renderTrend() {
+ if (!trendChartRef.value || !trendData.value.length) {
+ return
+ }
+ if (!trendChart) {
+ trendChart = echarts.init(trendChartRef.value)
+ }
+ const color = props.device && props.device.meterType === 'WATER' ? '#409eff' : '#e6a23c'
+ trendChart.setOption(
+ {
+ grid: { left: 44, right: 16, top: 20, bottom: 30 },
+ tooltip: {
+ trigger: 'axis',
+ valueFormatter: (value) => (value == null ? '鏆傛棤鏁版嵁' : `${formatNumber(value)} ${unit.value}`)
+ },
+ xAxis: {
+ type: 'category',
+ data: trendData.value.map((item) => item.day),
+ axisLabel: { fontSize: 11 }
+ },
+ yAxis: {
+ type: 'value',
+ name: unit.value,
+ nameTextStyle: { fontSize: 11 },
+ splitLine: { lineStyle: { type: 'dashed' } }
+ },
+ series: [
+ {
+ name: '鐢ㄩ噺',
+ type: 'bar',
+ barMaxWidth: 16,
+ data: trendData.value.map((item) => item.value),
+ itemStyle: { color, borderRadius: [3, 3, 0, 0] }
+ }
+ ]
+ },
+ true
+ )
+ trendChart.resize()
+}
+
+function handleTabChange() {
+ if (activeTab.value === 'usage') {
+ loadUsage()
+ } else {
+ loadReading()
+ }
+}
+
+function handleUsagePageChange(page) {
+ usagePage.value = page
+ loadUsage()
+}
+
+function handleReadingPageChange(page) {
+ readingPage.value = page
+ loadReading()
+}
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num
+ .toFixed(3)
+ .replace(/\.?0+$/, '')
+}
+
+function formatDay(value) {
+ return value ? String(value).slice(0, 10) : '--'
+}
+
+function taskTagType(status) {
+ if (status === 'SUCCESS') {
+ return 'success'
+ }
+ if (status === 'FAILED') {
+ return 'danger'
+ }
+ if (status === 'RETRY' || status === 'EMPTY') {
+ return 'warning'
+ }
+ return 'info'
+}
+
+defineExpose({ reload: handleOpen })
+</script>
+
+<style scoped>
+.side-panel {
+ padding: 0 4px 24px;
+}
+
+.panel-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ margin-bottom: 12px;
+}
+
+.panel-title {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.panel-title .address {
+ font-size: 13px;
+ color: #606266;
+}
+
+.panel-desc {
+ margin-bottom: 12px;
+}
+
+.panel-cards {
+ margin-bottom: 12px;
+}
+
+.mini-card {
+ padding: 10px 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 6px;
+ background: #fafcff;
+}
+
+.mini-label {
+ font-size: 12px;
+ color: #909399;
+}
+
+.mini-value {
+ margin: 4px 0 2px;
+ font-size: 22px;
+ font-weight: 600;
+ color: #303133;
+}
+
+.mini-unit {
+ font-size: 12px;
+ font-weight: 400;
+ color: #909399;
+}
+
+.mini-sub {
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.panel-chart-card {
+ margin-bottom: 12px;
+}
+
+.card-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ font-size: 14px;
+}
+
+.card-sub {
+ font-size: 12px;
+ color: #909399;
+}
+
+.chart-placeholder {
+ height: 200px;
+ width: 100%;
+}
+
+.chart-placeholder.empty {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: #909399;
+ font-size: 13px;
+}
+
+.panel-tabs {
+ margin-top: 4px;
+}
+
+.panel-pagination {
+ margin-top: 8px;
+ justify-content: flex-end;
+}
+</style>
diff --git a/src/views/energyManagement/waterElectricMeter/index.vue b/src/views/energyManagement/waterElectricMeter/index.vue
new file mode 100644
index 0000000..282c15c
--- /dev/null
+++ b/src/views/energyManagement/waterElectricMeter/index.vue
@@ -0,0 +1,998 @@
+<template>
+ <div class="app-container meter-page">
+ <!-- 椤堕儴绛涢�� -->
+ <el-card shadow="never" class="filter-card">
+ <div class="filter-grid">
+ <div class="filter-item">
+ <span class="filter-label">鑳芥簮绫诲瀷</span>
+ <el-radio-group v-model="query.meterType" @change="handleTypeChange">
+ <el-radio-button value="WATER">姘磋〃</el-radio-button>
+ <el-radio-button value="ELECTRIC">鐢佃〃</el-radio-button>
+ </el-radio-group>
+ </div>
+ <div class="filter-item">
+ <span class="filter-label">璁惧鑼冨洿</span>
+ <el-select v-model="query.scope" style="width: 160px" @change="handleScopeChange">
+ <el-option label="鍏ㄩ儴宸茬粦瀹氳澶�" value="ALL" />
+ <el-option label="鍗曞彴璁惧" value="SINGLE" />
+ </el-select>
+ </div>
+ <div v-if="query.scope === 'SINGLE'" class="filter-item">
+ <el-select
+ v-model="query.meterId"
+ filterable
+ clearable
+ placeholder="鎼滅储璁惧鍚嶇О/閫氫俊鍦板潃"
+ style="width: 280px"
+ @change="loadAll"
+ >
+ <el-option
+ v-for="item in deviceOptions"
+ :key="item.id"
+ :label="item.displayName + '锛�' + item.meterAddress + '锛�'"
+ :value="item.id"
+ />
+ </el-select>
+ </div>
+ <div class="filter-item">
+ <span class="filter-label">鏈堜唤</span>
+ <el-date-picker
+ v-model="query.month"
+ type="month"
+ value-format="YYYY-MM"
+ :clearable="false"
+ style="width: 140px"
+ @change="handleMonthChange"
+ />
+ </div>
+ <div class="filter-item">
+ <span class="filter-label">骞翠唤</span>
+ <el-date-picker
+ v-model="query.year"
+ type="year"
+ value-format="YYYY"
+ :clearable="false"
+ style="width: 110px"
+ @change="handleYearChange"
+ />
+ </div>
+ <div class="filter-actions">
+ <el-button type="primary" @click="loadAll">鏌ヨ</el-button>
+ <el-button @click="refreshAll">鍒锋柊鏁版嵁</el-button>
+ <el-button v-hasPermi="['energyMeter:device:add']" type="success" @click="openDeviceForm('add')">
+ 鏂板璁惧
+ </el-button>
+ </div>
+ </div>
+ </el-card>
+
+ <el-alert
+ v-if="overview.mockMode"
+ class="mock-alert"
+ type="info"
+ :closable="false"
+ show-icon
+ title="褰撳墠涓烘紨绀烘暟鎹ā寮忥細鏈厤缃涓夋柟鎺堟潈鐮侊紝鏌ヨ〃缁撴灉鐢辨湰鍦版ā鎷熺敓鎴愶紝浠呯敤浜庤仈璋冧笌椤甸潰婕旂ず銆�"
+ />
+
+ <!-- 閲囬泦鐘舵�佹潯 -->
+ <div class="status-bar">
+ <span class="status-item">鏁版嵁鎴嚦锛�<b>{{ overview.dataThrough || '--' }}</b></span>
+ <span class="status-item">鏈�杩戞垚鍔熼噰闆嗭細<b>{{ overview.lastSuccessAt || '--' }}</b></span>
+ <span class="status-item">
+ 鏁版嵁鑼冨洿锛�<b>{{ overview.dataStart || '--' }} ~ {{ overview.dataEnd || '--' }}</b>
+ </span>
+ <el-tag :type="syncTagType(overview.syncStatus)" size="small">{{ overview.syncStatusText || '鏆傛棤鏁版嵁' }}</el-tag>
+ <span class="status-item">鏈湀瑕嗙洊锛�<b>{{ overview.coverageRate == null ? '--' : overview.coverageRate + '%' }}</b></span>
+ <span class="status-item status-scope">{{ overview.scopeLabel || '--' }}</span>
+ </div>
+
+ <!-- 缁熻鍗$墖 -->
+ <el-row :gutter="12" class="stat-row">
+ <el-col :xs="24" :sm="12" :md="6">
+ <div class="stat-card">
+ <div class="stat-label">{{ query.month }} 绱鐢ㄩ噺</div>
+ <div class="stat-value">
+ {{ overview.monthHasData ? formatNumber(overview.monthTotal) : '--' }}
+ <span class="stat-unit">{{ unit }}</span>
+ </div>
+ <div class="stat-sub">
+ 宸查噰闆� {{ overview.collectedDays || 0 }}/{{ overview.expectedDays || 0 }} 澶�
+ </div>
+ </div>
+ </el-col>
+ <el-col :xs="24" :sm="12" :md="6">
+ <div class="stat-card">
+ <div class="stat-label">涓婃湀鍚屾湡绱</div>
+ <div class="stat-value">
+ {{ overview.monthHasData ? formatNumber(overview.monthPreviousTotal) : '--' }}
+ <span class="stat-unit">{{ unit }}</span>
+ </div>
+ <div class="stat-sub">
+ 鐜瘮
+ <span :class="comparisonClass(overview.monthTotal, overview.monthPreviousTotal)">
+ {{ comparisonText(overview.monthTotal, overview.monthPreviousTotal) }}
+ </span>
+ </div>
+ </div>
+ </el-col>
+ <el-col :xs="24" :sm="12" :md="6">
+ <div class="stat-card">
+ <div class="stat-label">{{ query.year }} 骞寸疮璁$敤閲�</div>
+ <div class="stat-value">
+ {{ overview.yearHasData ? formatNumber(overview.yearTotal) : '--' }}
+ <span class="stat-unit">{{ unit }}</span>
+ </div>
+ <div class="stat-sub">宸查噰闆嗘暟鎹悎璁★紝缂哄け鏃ヤ笉鎸� 0 璁�</div>
+ </div>
+ </el-col>
+ <el-col :xs="24" :sm="12" :md="6">
+ <div class="stat-card">
+ <div class="stat-label">鍘诲勾鍚屾湀绱</div>
+ <div class="stat-value">
+ {{ overview.yearHasData ? formatNumber(overview.yearPreviousTotal) : '--' }}
+ <span class="stat-unit">{{ unit }}</span>
+ </div>
+ <div class="stat-sub">
+ 鍚屾瘮
+ <span :class="comparisonClass(overview.yearTotal, overview.yearPreviousTotal)">
+ {{ comparisonText(overview.yearTotal, overview.yearPreviousTotal) }}
+ </span>
+ </div>
+ </div>
+ </el-col>
+ </el-row>
+
+ <!-- 鍥捐〃 -->
+ <el-row :gutter="12">
+ <el-col :xs="24" :lg="12">
+ <el-card shadow="never" class="chart-card">
+ <template #header>
+ <div class="card-head">
+ <span>{{ query.month }} 姣忔棩鐢ㄩ噺</span>
+ <span class="card-sub">鍗曚綅锛歿{ unit }}</span>
+ </div>
+ </template>
+ <div ref="monthChartRef" class="chart"></div>
+ <div class="chart-note">
+ <span>褰撴湀鐢ㄩ噺锛歿{ overview.monthHasData ? formatNumber(overview.monthTotal) : '--' }} {{ unit }}</span>
+ <span>涓婃湀鐢ㄩ噺锛歿{ overview.monthHasData ? formatNumber(overview.monthPreviousTotal) : '--' }} {{ unit }}</span>
+ <span>鏈湀璐圭敤锛歿{ overview.monthCost == null ? '--' : formatNumber(overview.monthCost) + ' 鍏�' }}</span>
+ </div>
+ </el-card>
+ </el-col>
+ <el-col :xs="24" :lg="12">
+ <el-card shadow="never" class="chart-card">
+ <template #header>
+ <div class="card-head">
+ <span>{{ query.year }} 骞存瘡鏈堢敤閲�</span>
+ <span class="card-sub">鍗曚綅锛歿{ unit }}</span>
+ </div>
+ </template>
+ <div ref="yearChartRef" class="chart"></div>
+ <div class="chart-note">
+ <span>鏈勾鐢ㄩ噺锛歿{ overview.yearHasData ? formatNumber(overview.yearTotal) : '--' }} {{ unit }}</span>
+ <span>鍘诲勾鐢ㄩ噺锛歿{ overview.yearHasData ? formatNumber(overview.yearPreviousTotal) : '--' }} {{ unit }}</span>
+ <span>鏈勾璐圭敤锛歿{ overview.yearCost == null ? '--' : formatNumber(overview.yearCost) + ' 鍏�' }}</span>
+ </div>
+ </el-card>
+ </el-col>
+ </el-row>
+
+ <!-- 璁惧鍒楄〃 -->
+ <el-card shadow="never" class="device-card">
+ <template #header>
+ <div class="card-head">
+ <span>缁戝畾璁惧</span>
+ <div class="table-actions">
+ <el-button
+ v-hasPermi="['energyMeter:device:collect']"
+ size="small"
+ :disabled="!selectedRows.length"
+ @click="openCollectDialog(selectedRows)"
+ >
+ 鎵归噺鏌ヨ〃锛坽{ selectedRows.length }}锛�
+ </el-button>
+ </div>
+ </div>
+ </template>
+
+ <el-table
+ :data="devices"
+ v-loading="tableLoading"
+ border
+ row-key="id"
+ @selection-change="handleSelectionChange"
+ >
+ <el-table-column type="selection" width="44" reserve-selection />
+ <el-table-column label="璁惧鍚嶇О" min-width="180">
+ <template #default="scope">
+ <div class="device-name">{{ scope.row.displayName }}</div>
+ <div class="device-sub">{{ scope.row.providerName || '--' }}</div>
+ </template>
+ </el-table-column>
+ <el-table-column label="绫诲瀷" width="80" align="center">
+ <template #default="scope">
+ <el-tag :type="scope.row.meterType === 'WATER' ? 'primary' : 'warning'" size="small" effect="plain">
+ {{ scope.row.meterType === 'WATER' ? '姘磋〃' : '鐢佃〃' }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="meterAddress" label="閫氫俊鍦板潃" min-width="130" />
+ <el-table-column prop="providerMeterId" label="绗笁鏂笽D" width="120" />
+ <el-table-column prop="providerAreaName" label="鍖哄煙" width="110" />
+ <el-table-column label="鐘舵��" width="110" align="center">
+ <template #default="scope">
+ <el-tag :type="scope.row.enabled === 1 ? 'success' : 'info'" size="small">
+ {{ scope.row.enabled === 1 ? '鍚敤' : '鍋滅敤' }}
+ </el-tag>
+ <el-tag
+ v-if="scope.row.onlineStatus != null"
+ class="online-tag"
+ :type="scope.row.onlineStatus === 1 ? 'success' : 'danger'"
+ size="small"
+ effect="plain"
+ >
+ {{ scope.row.onlineStatus === 1 ? '鍦ㄧ嚎' : '绂荤嚎' }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏈�杩戦噰闆�" min-width="170">
+ <template #default="scope">
+ <div class="device-sub">{{ scope.row.lastTaskTime || '--' }}</div>
+ <el-tag :type="taskTagType(scope.row.lastTaskStatus)" size="small" effect="plain">
+ {{ scope.row.collectStateText || '灏氭湭閲囬泦' }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏈�杩戜竴澶╃敤閲�" width="130" align="right">
+ <template #default="scope">
+ <span v-if="scope.row.lastDayUsage != null">
+ {{ formatNumber(scope.row.lastDayUsage) }} {{ scope.row.meterType === 'WATER' ? 'm鲁' : 'kWh' }}
+ </span>
+ <span v-else class="device-sub">--</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏈�鏂拌鏁�" width="130" align="right">
+ <template #default="scope">
+ <span v-if="scope.row.latestReading != null">
+ {{ formatNumber(scope.row.latestReading) }} {{ scope.row.meterType === 'WATER' ? 'm鲁' : 'kWh' }}
+ </span>
+ <span v-else class="device-sub">--</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" width="210" fixed="right" align="center">
+ <template #default="scope">
+ <el-button link type="primary" @click="openSidePanel(scope.row)">鏌ョ湅</el-button>
+ <el-button
+ v-hasPermi="['energyMeter:device:collect']"
+ link
+ type="primary"
+ @click="openCollectDialog([scope.row])"
+ >
+ 鏌ヨ〃
+ </el-button>
+ <el-button
+ v-hasPermi="['energyMeter:device:edit']"
+ link
+ type="primary"
+ @click="openDeviceForm('edit', scope.row)"
+ >
+ 缂栬緫
+ </el-button>
+ <el-button v-hasPermi="['energyMeter:device:edit']" link type="danger" @click="toggleEnabled(scope.row)">
+ {{ scope.row.enabled === 1 ? '鍋滅敤' : '鍚敤' }}
+ </el-button>
+ </template>
+ </el-table-column>
+ <template #empty>
+ <el-empty description="鏆傛棤缁戝畾璁惧锛岃鍏堟柊澧�" :image-size="80" />
+ </template>
+ </el-table>
+
+ <el-pagination
+ class="device-pagination"
+ layout="total, sizes, prev, pager, next, jumper"
+ :total="page.total"
+ :current-page="page.current"
+ :page-size="page.size"
+ :page-sizes="[10, 20, 50]"
+ @current-change="handlePageChange"
+ @size-change="handleSizeChange"
+ />
+ </el-card>
+
+ <!-- 鏂板/缂栬緫 -->
+ <DeviceFormDialog ref="deviceFormRef" :default-meter-type="query.meterType" @success="handleDeviceSaved" />
+
+ <!-- 鍙充晶鏁版嵁闈㈡澘 -->
+ <DeviceSidePanel
+ v-model="sidePanelVisible"
+ :device="currentDevice"
+ @collect="(row) => openCollectDialog([row])"
+ />
+
+
+ <!-- 鎵嬪姩鏌ヨ〃 -->
+ <el-dialog v-model="collectDialog.visible" title="鎵嬪姩鏌ヨ〃" width="480px" append-to-body>
+ <el-form label-width="92px">
+ <el-form-item label="鏌ヨ〃璁惧">
+ <div class="collect-devices">
+ <el-tag v-for="item in collectDialog.devices" :key="item.id" size="small" effect="plain">
+ {{ item.displayName }}锛坽{ item.meterAddress }}锛�
+ </el-tag>
+ </div>
+ </el-form-item>
+ <el-form-item label="鏃ユ湡鑼冨洿">
+ <el-date-picker
+ v-model="collectDialog.range"
+ type="daterange"
+ value-format="YYYY-MM-DD"
+ range-separator="鑷�"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ :disabled-date="disableAfterYesterday"
+ style="width: 100%"
+ />
+ </el-form-item>
+ <el-form-item label="鍖呭惈绀哄��">
+ <el-switch v-model="collectDialog.includeReadings" />
+ <span class="field-tip">鍏抽棴鍚庡彧閲囬泦鏈熼棿鐢ㄩ噺</span>
+ </el-form-item>
+ </el-form>
+ <div class="dialog-tip">
+ 鎵嬪姩鏌ヨ〃鍦ㄥ悗鍙版墽琛岋紝瀹屾垚鍚庨〉闈㈡暟鎹細鑷姩鍒锋柊锛涢噸澶嶆煡璇㈠悓涓�鏃堕棿鑼冨洿涓嶄細浜х敓閲嶅璁板綍銆�
+ </div>
+ <template #footer>
+ <el-button @click="collectDialog.visible = false">鍙� 娑�</el-button>
+ <el-button type="primary" :loading="collectDialog.submitting" @click="submitCollect">寮�濮嬫煡琛�</el-button>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup>
+import { nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
+import * as echarts from 'echarts'
+import dayjs from 'dayjs'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import DeviceFormDialog from './components/DeviceFormDialog.vue'
+import DeviceSidePanel from './components/DeviceSidePanel.vue'
+import {
+ collectMeterDevice,
+ collectMeterDevices,
+ getMeterOverview,
+ listMeterDeviceOptions,
+ listMeterDevices,
+ updateMeterDevice
+} from '@/api/energyManagement/energyMeter'
+
+defineOptions({ name: 'WaterElectricMeter' })
+
+const query = reactive({
+ meterType: 'WATER',
+ scope: 'ALL',
+ meterId: null,
+ month: dayjs().format('YYYY-MM'),
+ year: dayjs().format('YYYY')
+})
+
+const page = reactive({ current: 1, size: 10, total: 0 })
+const devices = ref([])
+const deviceOptions = ref([])
+const selectedRows = ref([])
+const tableLoading = ref(false)
+const overview = ref({})
+const currentDevice = ref(null)
+const sidePanelVisible = ref(false)
+const deviceFormRef = ref(null)
+
+const collectDialog = reactive({
+ visible: false,
+ devices: [],
+ range: [],
+ includeReadings: true,
+ submitting: false
+})
+
+const monthChartRef = ref(null)
+const yearChartRef = ref(null)
+let monthChart = null
+let yearChart = null
+let collectReloadTimer = null
+
+const unit = ref('m鲁')
+
+onMounted(() => {
+ loadOptions()
+ loadAll()
+ window.addEventListener('resize', handleResize)
+})
+
+onBeforeUnmount(() => {
+ window.removeEventListener('resize', handleResize)
+ if (collectReloadTimer) {
+ clearTimeout(collectReloadTimer)
+ collectReloadTimer = null
+ }
+ if (monthChart) {
+ monthChart.dispose()
+ monthChart = null
+ }
+ if (yearChart) {
+ yearChart.dispose()
+ yearChart = null
+ }
+})
+
+function handleResize() {
+ monthChart && monthChart.resize()
+ yearChart && yearChart.resize()
+}
+
+function loadAll() {
+ loadOverview()
+ loadDevices()
+}
+
+function refreshAll() {
+ loadOptions()
+ loadAll()
+ ElMessage.success('宸插埛鏂�')
+}
+
+async function loadOverview() {
+ const params = {
+ meterType: query.meterType,
+ month: query.month,
+ year: Number(query.year)
+ }
+ if (query.scope === 'SINGLE' && query.meterId) {
+ params.meterId = query.meterId
+ }
+ try {
+ const res = await getMeterOverview(params)
+ overview.value = res.data || {}
+ unit.value = overview.value.unit === 'm3' ? 'm鲁' : overview.value.unit || 'm鲁'
+ await nextTick()
+ renderMonthChart()
+ renderYearChart()
+ } catch (e) {
+ overview.value = {}
+ }
+}
+
+async function loadDevices() {
+ tableLoading.value = true
+ try {
+ const res = await listMeterDevices({
+ current: page.current,
+ size: page.size,
+ meterType: query.meterType
+ })
+ const data = res.data || {}
+ devices.value = data.records || []
+ page.total = data.total || 0
+ } finally {
+ tableLoading.value = false
+ }
+}
+
+async function loadOptions() {
+ try {
+ const res = await listMeterDeviceOptions({ meterType: query.meterType })
+ deviceOptions.value = res.data || []
+ if (query.scope === 'SINGLE') {
+ const exists = deviceOptions.value.some((item) => item.id === query.meterId)
+ if (!exists) {
+ query.meterId = deviceOptions.value.length ? deviceOptions.value[0].id : null
+ }
+ }
+ } catch (e) {
+ deviceOptions.value = []
+ }
+}
+
+function handleTypeChange() {
+ query.meterId = null
+ query.scope = 'ALL'
+ page.current = 1
+ loadOptions()
+ loadAll()
+}
+
+function handleScopeChange(value) {
+ if (value === 'ALL') {
+ query.meterId = null
+ } else if (!query.meterId && deviceOptions.value.length) {
+ query.meterId = deviceOptions.value[0].id
+ }
+ loadAll()
+}
+
+function handleMonthChange(value) {
+ if (value) {
+ query.year = value.slice(0, 4)
+ }
+ loadAll()
+}
+
+function handleYearChange(value) {
+ if (value) {
+ const monthPart = (query.month || dayjs().format('YYYY-MM')).slice(5, 7)
+ query.month = `${value}-${monthPart}`
+ }
+ loadAll()
+}
+
+function handlePageChange(current) {
+ page.current = current
+ loadDevices()
+}
+
+function handleSizeChange(size) {
+ page.size = size
+ page.current = 1
+ loadDevices()
+}
+
+function handleSelectionChange(rows) {
+ selectedRows.value = rows
+}
+
+function openDeviceForm(mode, row) {
+ deviceFormRef.value && deviceFormRef.value.open(mode, row)
+}
+
+function handleDeviceSaved() {
+ loadOptions()
+ loadAll()
+}
+
+function openSidePanel(row) {
+ currentDevice.value = row
+ sidePanelVisible.value = true
+}
+
+async function toggleEnabled(row) {
+ const action = row.enabled === 1 ? '鍋滅敤' : '鍚敤'
+ const tips =
+ action === '鍋滅敤'
+ ? '鍋滅敤鍚庝笉鍐嶅弬涓庢瘡鏃ヨ嚜鍔ㄥ悓姝ワ紝鍘嗗彶閲囬泦鏁版嵁浼氫繚鐣欍��'
+ : '鍚敤鍚庡皢鎸夎繘搴﹁嚜鍔ㄨˉ閲囧仠鐢ㄦ湡闂寸殑鏁版嵁銆�'
+ try {
+ await ElMessageBox.confirm(`纭${action}璁惧銆�${row.displayName}銆嶏紵${tips}`, `${action}璁惧`, {
+ type: 'warning',
+ confirmButtonText: action,
+ cancelButtonText: '鍙栨秷'
+ })
+ } catch (e) {
+ return
+ }
+ try {
+ await updateMeterDevice(row.id, { enabled: row.enabled === 1 ? 0 : 1 })
+ ElMessage.success(`${action}鎴愬姛`)
+ loadOptions()
+ loadAll()
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ }
+}
+
+function openCollectDialog(rows) {
+ const list = Array.isArray(rows) ? rows : [rows]
+ const valid = list.filter((item) => item && item.id)
+ if (!valid.length) {
+ ElMessage.warning('璇峰厛閫夋嫨璁惧')
+ return
+ }
+ collectDialog.devices = valid
+ collectDialog.range = [
+ dayjs().subtract(3, 'day').format('YYYY-MM-DD'),
+ dayjs().subtract(1, 'day').format('YYYY-MM-DD')
+ ]
+ collectDialog.includeReadings = true
+ collectDialog.visible = true
+}
+
+async function submitCollect() {
+ if (!collectDialog.range || collectDialog.range.length !== 2) {
+ ElMessage.warning('璇烽�夋嫨鏌ヨ〃鏃ユ湡鑼冨洿')
+ return
+ }
+ collectDialog.submitting = true
+ try {
+ const payload = {
+ startDate: collectDialog.range[0],
+ endDate: collectDialog.range[1],
+ includeReadings: collectDialog.includeReadings
+ }
+ if (collectDialog.devices.length === 1) {
+ await collectMeterDevice(collectDialog.devices[0].id, payload)
+ } else {
+ await collectMeterDevices({
+ ...payload,
+ meterIds: collectDialog.devices.map((item) => item.id)
+ })
+ }
+ collectDialog.visible = false
+ ElMessage.success('鏌ヨ〃浠诲姟宸叉彁浜わ紝姝e湪鍚庡彴閲囬泦')
+ if (collectReloadTimer) {
+ clearTimeout(collectReloadTimer)
+ }
+ collectReloadTimer = setTimeout(() => {
+ loadAll()
+ collectReloadTimer = null
+ }, 4000)
+ } catch (e) {
+ // 閿欒鎻愮ず宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�灞曠ず
+ } finally {
+ collectDialog.submitting = false
+ }
+}
+
+/* ------------------------------ 鍥捐〃 ------------------------------ */
+
+function renderMonthChart() {
+ if (!monthChartRef.value) {
+ return
+ }
+ if (!monthChart) {
+ monthChart = echarts.init(monthChartRef.value)
+ }
+ const series = overview.value.monthSeries || []
+ const color = query.meterType === 'WATER' ? '#409eff' : '#e6a23c'
+ monthChart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ valueFormatter: (value) => (value == null ? '鏆傛棤鏁版嵁' : `${formatNumber(value)} ${unit.value}`)
+ },
+ legend: { data: ['褰撴湀', '涓婃湀鍚屾湡'], top: 0, itemWidth: 12, itemHeight: 8 },
+ grid: { left: 48, right: 16, top: 34, bottom: 42 },
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => (item.day ? item.day.slice(5) : '')),
+ axisLabel: { fontSize: 11, rotate: series.length > 20 ? 45 : 0, interval: series.length > 20 ? 1 : 0 },
+ axisTick: { show: false }
+ },
+ yAxis: {
+ type: 'value',
+ name: `鐢ㄩ噺锛�${unit.value}锛塦,
+ nameTextStyle: { fontSize: 11 },
+ splitLine: { lineStyle: { type: 'dashed' } }
+ },
+ series: [
+ {
+ name: '褰撴湀',
+ type: 'bar',
+ barMaxWidth: 16,
+ data: series.map((item) => item.current),
+ itemStyle: { color, borderRadius: [3, 3, 0, 0] }
+ },
+ {
+ name: '涓婃湀鍚屾湡',
+ type: 'line',
+ smooth: false,
+ symbolSize: 4,
+ lineStyle: { width: 1.5, color: '#909399' },
+ itemStyle: { color: '#909399' },
+ data: series.map((item) => item.previous)
+ }
+ ],
+ graphic: overview.value.monthHasData
+ ? []
+ : [{ type: 'text', left: 'center', top: 'middle', style: { text: '鏆傛棤鏁版嵁', fill: '#909399', fontSize: 15 } }]
+ },
+ true
+ )
+ monthChart.resize()
+}
+
+function renderYearChart() {
+ if (!yearChartRef.value) {
+ return
+ }
+ if (!yearChart) {
+ yearChart = echarts.init(yearChartRef.value)
+ }
+ const series = overview.value.yearSeries || []
+ const color = query.meterType === 'WATER' ? '#409eff' : '#e6a23c'
+ yearChart.setOption(
+ {
+ tooltip: {
+ trigger: 'axis',
+ valueFormatter: (value) => (value == null ? '鏆傛棤鏁版嵁' : `${formatNumber(value)} ${unit.value}`)
+ },
+ legend: { data: ['鏈勾', '鍘诲勾鍚屾湀'], top: 0, itemWidth: 12, itemHeight: 8 },
+ grid: { left: 52, right: 16, top: 34, bottom: 32 },
+ xAxis: {
+ type: 'category',
+ data: series.map((item) => (item.month ? item.month.slice(5) + '鏈�' : '')),
+ axisLabel: { fontSize: 11 },
+ axisTick: { show: false }
+ },
+ yAxis: {
+ type: 'value',
+ name: `鐢ㄩ噺锛�${unit.value}锛塦,
+ nameTextStyle: { fontSize: 11 },
+ splitLine: { lineStyle: { type: 'dashed' } }
+ },
+ series: [
+ {
+ name: '鏈勾',
+ type: 'bar',
+ barMaxWidth: 22,
+ data: series.map((item) => item.current),
+ itemStyle: { color, borderRadius: [3, 3, 0, 0] }
+ },
+ {
+ name: '鍘诲勾鍚屾湀',
+ type: 'line',
+ symbolSize: 4,
+ lineStyle: { width: 1.5, color: '#909399' },
+ itemStyle: { color: '#909399' },
+ data: series.map((item) => item.previous)
+ }
+ ],
+ graphic: overview.value.yearHasData
+ ? []
+ : [{ type: 'text', left: 'center', top: 'middle', style: { text: '鏆傛棤鏁版嵁', fill: '#909399', fontSize: 15 } }]
+ },
+ true
+ )
+ yearChart.resize()
+}
+
+/* ------------------------------ 宸ュ叿 ------------------------------ */
+
+function formatNumber(value) {
+ if (value == null || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return String(value)
+ }
+ return num.toFixed(3).replace(/\.?0+$/, '')
+}
+
+function comparisonText(current, previous) {
+ if (current == null || previous == null || Number(previous) === 0) {
+ return '--'
+ }
+ const diff = ((Number(current) - Number(previous)) / Number(previous)) * 100
+ return `${diff >= 0 ? '+' : ''}${diff.toFixed(1)}%`
+}
+
+function comparisonClass(current, previous) {
+ if (current == null || previous == null || Number(previous) === 0) {
+ return 'compare-flat'
+ }
+ return Number(current) >= Number(previous) ? 'compare-up' : 'compare-down'
+}
+
+function syncTagType(status) {
+ if (status === 'OK') {
+ return 'success'
+ }
+ if (status === 'PARTIAL') {
+ return 'warning'
+ }
+ if (status === 'STALE') {
+ return 'danger'
+ }
+ return 'info'
+}
+
+function taskTagType(status) {
+ if (status === 'SUCCESS') {
+ return 'success'
+ }
+ if (status === 'FAILED') {
+ return 'danger'
+ }
+ if (status === 'RETRY' || status === 'EMPTY') {
+ return 'warning'
+ }
+ return 'info'
+}
+
+function disableAfterYesterday(date) {
+ return dayjs(date).isAfter(dayjs().subtract(1, 'day'), 'day')
+}
+</script>
+
+<style scoped>
+.meter-page {
+ padding-bottom: 24px;
+}
+
+.filter-card {
+ margin-bottom: 12px;
+}
+
+.filter-grid {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 16px 20px;
+}
+
+.filter-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.filter-label {
+ font-size: 13px;
+ color: #606266;
+ white-space: nowrap;
+}
+
+.filter-actions {
+ display: flex;
+ gap: 8px;
+ margin-left: auto;
+}
+
+.mock-alert {
+ margin-bottom: 12px;
+}
+
+.status-bar {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 16px;
+ padding: 10px 14px;
+ margin-bottom: 12px;
+ border-radius: 6px;
+ background: #f5f7fa;
+ font-size: 13px;
+ color: #606266;
+}
+
+.status-item b {
+ color: #303133;
+ font-weight: 500;
+}
+
+.status-scope {
+ margin-left: auto;
+ color: #909399;
+}
+
+.stat-row {
+ margin-bottom: 12px;
+}
+
+.stat-card {
+ padding: 16px 18px;
+ margin-bottom: 12px;
+ border: 1px solid #ebeef5;
+ border-radius: 8px;
+ background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%);
+}
+
+.stat-label {
+ font-size: 13px;
+ color: #909399;
+}
+
+.stat-value {
+ margin: 8px 0 4px;
+ font-size: 26px;
+ font-weight: 600;
+ color: #303133;
+ line-height: 1.2;
+}
+
+.stat-unit {
+ margin-left: 4px;
+ font-size: 13px;
+ font-weight: 400;
+ color: #909399;
+}
+
+.stat-sub {
+ font-size: 12px;
+ color: #a8abb2;
+}
+
+.compare-up {
+ color: #f56c6c;
+}
+
+.compare-down {
+ color: #67c23a;
+}
+
+.compare-flat {
+ color: #909399;
+}
+
+.chart-card {
+ margin-bottom: 12px;
+}
+
+.card-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ font-size: 14px;
+ font-weight: 500;
+}
+
+.card-sub {
+ font-size: 12px;
+ font-weight: 400;
+ color: #909399;
+}
+
+.chart {
+ width: 100%;
+ height: 300px;
+}
+
+.chart-note {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 20px;
+ padding-top: 8px;
+ font-size: 12px;
+ color: #909399;
+}
+
+.device-card {
+ margin-top: 4px;
+}
+
+.table-actions {
+ display: flex;
+ gap: 8px;
+}
+
+.device-name {
+ font-size: 13px;
+ color: #303133;
+}
+
+.device-sub {
+ font-size: 12px;
+ color: #909399;
+}
+
+.online-tag {
+ margin-left: 6px;
+}
+
+.device-pagination {
+ margin-top: 12px;
+ justify-content: flex-end;
+}
+
+.collect-devices {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ max-height: 96px;
+ overflow-y: auto;
+}
+
+.field-tip {
+ margin-left: 8px;
+ font-size: 12px;
+ color: #909399;
+}
+
+.dialog-tip {
+ padding: 8px 12px;
+ border-radius: 4px;
+ background: #f4f4f5;
+ font-size: 12px;
+ line-height: 1.6;
+ color: #909399;
+}
+</style>
diff --git a/src/views/energyManagement/waterManagement/components/formDia.vue b/src/views/energyManagement/waterManagement/components/formDia.vue
deleted file mode 100644
index bf605ca..0000000
--- a/src/views/energyManagement/waterManagement/components/formDia.vue
+++ /dev/null
@@ -1,214 +0,0 @@
-<template>
- <div>
- <el-dialog
- v-model="dialogFormVisible"
- title="鐢ㄦ按璁惧"
- width="70%"
- @close="closeDia"
- >
- <el-form
- :model="form"
- label-width="140px"
- label-position="top"
- :rules="rules"
- ref="formRef"
- >
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="璁惧锛�" prop="deviceModel">
- <el-select
- v-model="form.deviceModel"
- placeholder="璇烽�夋嫨"
- clearable
- @change="setName"
- :disabled="operationType !== 'add'"
- >
- <el-option
- v-for="item in codeList"
- :key="item.deviceModel"
- :label="item.deviceName"
- :value="item.deviceModel"
- >
- {{item.deviceName + '--' + item.deviceModel}}
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="姣忔棩闄愬埗姘撮噺锛�" prop="waterDayLimit">
- <el-input
- v-model="form.waterDayLimit"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="棰濆畾娴侀噺锛�" prop="ratedRate">
- <el-input
- v-model="form.ratedRate"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="瀹為檯娴侀噺锛�" prop="actualTraffic">
- <el-input
- v-model="form.actualTraffic"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="杩愯鏃堕棿锛�" prop="runTime">
- <el-date-picker
- style="width: 100%"
- v-model="form.runTime"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="褰撴棩鐢ㄦ按閲忥細" prop="waterDay">
- <el-input
- v-model="form.waterDay"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="姘磋垂鍗曚环锛�" prop="waterPrice">
- <el-input
- v-model="form.waterPrice"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鐢ㄦ按绫诲瀷锛�" prop="type">
- <el-select
- v-model="form.type"
- placeholder="璇烽�夋嫨"
- clearable
- >
- <el-option label="宸ヤ笟鐢ㄦ按" value="industrial" />
- <el-option label="鐢熸椿鐢ㄦ按" value="domestic" />
- <el-option label="娑堥槻鐢ㄦ按" value="fire" />
- <el-option label="缁垮寲鐢ㄦ按" value="greening" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
-</template>
-
-<script setup>
-import {ref, reactive, nextTick} from "vue";
-import useUserStore from "@/store/modules/user.js";
-import {waterDeviceList, waterEquipmentAdd, waterEquipmentUpdate} from "@/api/energyManagement/waterManagement.js";
-import { getCurrentDate } from "@/utils/index.js";
-const { proxy } = getCurrentInstance()
-const emit = defineEmits(['close'])
-const dialogFormVisible = ref(false);
-const operationType = ref('')
-const userStore = useUserStore();
-
-const data = reactive({
- form: {
- deviceName: "",
- deviceModel: "",
- waterDayLimit: "",
- ratedRate: "",
- actualTraffic: "",
- runTime: "",
- waterDay: "",
- waterPrice: "",
- type: "",
- },
- rules: {
- deviceModel: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- runTime: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- waterDayLimit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- ratedRate: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- actualTraffic: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- waterDay: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- waterPrice: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- type: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- },
-})
-const { form, rules } = toRefs(data);
-const codeList = ref([])
-
-// 鎵撳紑寮规
-const openDialog = (type, row) => {
- operationType.value = type;
- dialogFormVisible.value = true;
- form.value = {}
- proxy.resetForm("formRef");
- waterDeviceList({size: -1}).then((res) => {
- codeList.value = res.data.records;
- });
- if (type === "edit") {
- form.value = {...row}
- }
-}
-const setName = (code) => {
- const index = codeList.value.findIndex(item => item.deviceModel === code);
- if (index > -1) {
- console.log(codeList)
- form.value.name = codeList.value[index].deviceName;
- }
-}
-const submitForm = () => {
- proxy.$refs["formRef"].validate(valid => {
- if (valid) {
- if (operationType.value === "add") {
- waterEquipmentAdd(form.value).then(response => {
- proxy.$modal.msgSuccess("鏂板鎴愬姛")
- closeDia()
- })
- } else {
- waterEquipmentUpdate(form.value).then(response => {
- proxy.$modal.msgSuccess("淇敼鎴愬姛")
- closeDia()
- })
- }
- }
- })
-}
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- dialogFormVisible.value = false;
- emit('close')
-};
-defineExpose({
- openDialog,
-});
-</script>
-
-<style scoped>
-
-</style>
diff --git a/src/views/energyManagement/waterManagement/components/waterBillForm.vue b/src/views/energyManagement/waterManagement/components/waterBillForm.vue
deleted file mode 100644
index 667fe10..0000000
--- a/src/views/energyManagement/waterManagement/components/waterBillForm.vue
+++ /dev/null
@@ -1,203 +0,0 @@
-<template>
- <div>
- <el-dialog
- v-model="dialogFormVisible"
- title="姘磋垂绠$悊"
- width="70%"
- @close="closeDia"
- >
- <el-form
- :model="form"
- label-width="140px"
- label-position="top"
- :rules="rules"
- ref="formRef"
- >
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="璁惧锛�" prop="code">
- <el-select
- v-model="form.code"
- placeholder="璇烽�夋嫨"
- clearable
- @change="setName"
- :disabled="operationType !== 'add'"
- >
- <el-option
- v-for="item in codeList"
- :key="item.deviceModel"
- :label="item.deviceName"
- :value="item.deviceModel"
- >
- {{item.deviceName + '--' + item.deviceModel}}
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鐢ㄦ按閲忥細" prop="waterConsumption">
- <el-input
- v-model="form.waterConsumption"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="姘磋垂鍗曚环锛�" prop="waterPrice">
- <el-input
- v-model="form.waterPrice"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="姘磋垂閲戦锛�" prop="waterBill">
- <el-input
- v-model="form.waterBill"
- placeholder="鑷姩璁$畻"
- clearable
- disabled
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="璁¤垂鏃ユ湡锛�" prop="billDate">
- <el-date-picker
- style="width: 100%"
- v-model="form.billDate"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鐢ㄦ按绫诲瀷锛�" prop="waterType">
- <el-select
- v-model="form.waterType"
- placeholder="璇烽�夋嫨"
- clearable
- >
- <el-option label="宸ヤ笟鐢ㄦ按" value="industrial" />
- <el-option label="鐢熸椿鐢ㄦ按" value="domestic" />
- <el-option label="娑堥槻鐢ㄦ按" value="fire" />
- <el-option label="缁垮寲鐢ㄦ按" value="greening" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
-</template>
-
-<script setup>
-import {ref, reactive, nextTick, watch} from "vue";
-import useUserStore from "@/store/modules/user.js";
-import {waterDeviceList, waterBillAdd, waterBillUpdate} from "@/api/energyManagement/waterManagement.js";
-import { getCurrentDate } from "@/utils/index.js";
-const { proxy } = getCurrentInstance()
-const emit = defineEmits(['close'])
-const dialogFormVisible = ref(false);
-const operationType = ref('')
-const userStore = useUserStore();
-
-const data = reactive({
- form: {
- name: "",
- code: "",
- waterConsumption: "",
- waterPrice: "",
- waterBill: "",
- billDate: "",
- waterType: "",
- },
- rules: {
- code: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- waterConsumption: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- waterPrice: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- billDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- waterType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- },
-})
-const { form, rules } = toRefs(data);
-const codeList = ref([])
-
-// 鎵撳紑寮规
-const openDialog = (type, row) => {
- operationType.value = type;
- dialogFormVisible.value = true;
- form.value = {}
- proxy.resetForm("formRef");
- waterDeviceList().then((res) => {
- codeList.value = res.data;
- });
- if (type === "edit") {
- form.value = {...row}
- }
-}
-const setName = (code) => {
- const index = codeList.value.findIndex(item => item.deviceModel === code);
- if (index > -1) {
- console.log(codeList)
- form.value.name = codeList.value[index].deviceName;
- }
-}
-
-// 璁$畻姘磋垂閲戦
-const calculateWaterBill = () => {
- if (form.value.waterConsumption && form.value.waterPrice) {
- form.value.waterBill = (parseFloat(form.value.waterConsumption) * parseFloat(form.value.waterPrice)).toFixed(2);
- }
-}
-
-// 鐩戝惉鐢ㄦ按閲忓拰姘磋垂鍗曚环鍙樺寲
-watch([() => form.value.waterConsumption, () => form.value.waterPrice], () => {
- calculateWaterBill();
-});
-
-const submitForm = () => {
- proxy.$refs["formRef"].validate(valid => {
- if (valid) {
- if (operationType.value === "add") {
- waterBillAdd(form.value).then(response => {
- proxy.$modal.msgSuccess("鏂板鎴愬姛")
- closeDia()
- })
- } else {
- waterBillUpdate(form.value).then(response => {
- proxy.$modal.msgSuccess("淇敼鎴愬姛")
- closeDia()
- })
- }
- }
- })
-}
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- dialogFormVisible.value = false;
- emit('close')
-};
-defineExpose({
- openDialog,
-});
-</script>
-
-<style scoped>
-
-</style>
diff --git a/src/views/energyManagement/waterManagement/index.vue b/src/views/energyManagement/waterManagement/index.vue
deleted file mode 100644
index 4ada029..0000000
--- a/src/views/energyManagement/waterManagement/index.vue
+++ /dev/null
@@ -1,329 +0,0 @@
-<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">璁惧鍚嶇О锛�</span>
- <el-input
- v-model="searchForm.deviceName"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button
- >
- </div>
- <div>
- <el-button type="primary" @click="openForm('add')">鏂板</el-button>
- <el-button type="info" plain icon="Upload" @click="handleImport">瀵煎叆</el-button>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
- </div>
- </div>
- <div class="table_list">
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
- <form-dia ref="formDia" @close="handleQuery"></form-dia>
- <el-dialog
- :title="upload.title"
- v-model="upload.open"
- width="400px"
- append-to-body
- @close="handleDialogClose"
- >
- <el-upload
- ref="uploadRef"
- :limit="1"
- accept=".xlsx, .xls"
- :headers="upload.headers"
- :action="upload.url"
- :disabled="upload.isUploading"
- :before-upload="upload.beforeUpload"
- :on-progress="upload.onProgress"
- :on-success="upload.onSuccess"
- :on-error="upload.onError"
- :on-change="upload.onChange"
- :auto-upload="false"
- drag
- >
- <el-icon class="el-icon--upload"><upload-filled /></el-icon>
- <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
- <template #tip>
- <div class="el-upload__tip text-center">
- <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
- <el-link
- type="primary"
- :underline="false"
- style="font-size: 12px; vertical-align: baseline"
- @click="importTemplate"
- >涓嬭浇妯℃澘</el-link
- >
- </div>
- </template>
- </el-upload>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
- <el-button @click="upload.open = false">鍙� 娑�</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
-</template>
-
-<script setup>
-import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref, reactive, nextTick, getCurrentInstance} from "vue";
-import FormDia from "@/views/energyManagement/waterManagement/components/formDia.vue";
-import {ElMessageBox} from "element-plus";
-import {getToken} from "@/utils/auth.js";
-import {waterEquipmentDelete, waterEquipmentListPage} from "@/api/energyManagement/waterManagement.js";
-const { proxy } = getCurrentInstance();
-
-const data = reactive({
- searchForm: {
- name: "",
- },
-});
-const { searchForm } = toRefs(data);
-
-const selectedRows = ref([]);
-const tableColumn = ref([
- {
- label: "璁惧鍚嶇О",
- prop: "deviceName",
- width: 200,
- },
- {
- label: "瑙勬牸鍨嬪彿",
- prop: "deviceModel",
- width: 200,
- },
- {
- label: "棰濆畾娴侀噺",
- prop: "ratedRate",
- },
- {
- label: "瀹為檯娴侀噺",
- prop: "actualTraffic",
- },
- {
- label: "杩愯鏃堕棿",
- prop: "runTime",
- width:150
- },
- {
- label: "褰撴棩鐢ㄦ按閲�",
- prop: "waterDay",
- width: 150,
- },
- {
- label: "姣忔棩闄愬埗姘撮噺",
- prop: "waterDayLimit",
- width:220
- },
- {
- label: "姘磋垂鍗曚环",
- prop: "waterPrice",
- width: 120,
- },
- {
- dataType: "action",
- label: "鎿嶄綔",
- align: "center",
- fixed: 'right',
- operation: [
- {
- name: "缂栬緫",
- type: "text",
- clickFun: (row) => {
- openForm("edit", row);
- },
- },
- ],
- },
-]);
-const tableData = ref([]);
-const tableLoading = ref(false);
-const page = reactive({
- current: 1,
- size: 100,
- total: 0,
-});
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-const formDia = ref()
-const upload = reactive({
- // 鏄惁鏄剧ず寮瑰嚭灞傦紙瀹㈡埛瀵煎叆锛�
- open: false,
- // 寮瑰嚭灞傛爣棰橈紙瀹㈡埛瀵煎叆锛�
- title: "",
- // 鏄惁绂佺敤涓婁紶
- isUploading: false,
- // 璁剧疆涓婁紶鐨勮姹傚ご閮�
- headers: { Authorization: "Bearer " + getToken() },
- // 涓婁紶鐨勫湴鍧�
- url: import.meta.env.VITE_APP_BASE_API + "/waterRecord/importData",
- // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
- beforeUpload: (file) => {
- console.log('鏂囦欢鍗冲皢涓婁紶', file);
- // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠�
- const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls');
- if (!isValid) {
- proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢");
- }
- return isValid;
- },
- // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋�
- onChange: (file, fileList) => {
- console.log('鏂囦欢鐘舵�佹敼鍙�', file, fileList);
- },
- // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟
- onSuccess: (response, file, fileList) => {
- console.log('涓婁紶鎴愬姛', response, file, fileList);
- if(response.code === 200){
- proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
- }else if(response.code === 500){
- proxy.$modal.msgError(response.msg);
- }else{
- proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
- }
- upload.open = false;
- getList();
- },
- // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟
- onError: (error, file, fileList) => {
- console.log('涓婁紶澶辫触', error, file, fileList);
- proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
- upload.open = false;
- },
- // 鏂囦欢涓婁紶杩涘害鏀瑰彉鏃剁殑鍥炶皟
- onProgress: (event, file, fileList) => {
- console.log('涓婁紶杩涘害', event, file, fileList);
- upload.isUploading = true;
- },
-});
-
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-
-const getList = () => {
- tableLoading.value = true;
- waterEquipmentListPage({ ...searchForm.value, ...page }).then((res) => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- page.total = res.data.total;
- }).catch(() => {
- tableLoading.value = false;
- })
-};
-
-// 鎵撳紑寮规
-const openForm = (type, row) => {
- nextTick(() => {
- formDia.value?.openDialog(type, row)
- })
-};
-
-/** 瀵煎叆鎸夐挳鎿嶄綔 */
-function handleImport() {
- upload.title = "鐢ㄦ按璁惧";
- upload.open = true;
- // 娓呯┖涓婃涓婁紶鐨勬枃浠跺垪琛�
- nextTick(() => {
- proxy.$refs["uploadRef"]?.clearFiles();
- });
-}
-function importTemplate() {
- proxy.download(
- "/waterRecord/export",
- {},
- '鐢ㄦ按璁惧瀵煎叆妯$増.xlsx'
- );
-}
-/** 鎻愪氦涓婁紶鏂囦欢 */
-function submitFileForm() {
- proxy.$refs["uploadRef"].submit();
-}
-
-/** 寮规鍏抽棴鏃舵竻绌烘枃浠跺垪琛� */
-function handleDialogClose() {
- nextTick(() => {
- proxy.$refs["uploadRef"]?.clearFiles();
- });
-}
-
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- tableLoading.value = true;
- waterEquipmentDelete(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- proxy.download("/waterRecord/export", {}, "鐢ㄦ按绠$悊.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-onMounted(() => {
- getList();
-});
-</script>
-
-<style scoped>
-
-</style>
diff --git a/src/views/energyManagement/waterManagement/waterBill.vue b/src/views/energyManagement/waterManagement/waterBill.vue
deleted file mode 100644
index ea382f0..0000000
--- a/src/views/energyManagement/waterManagement/waterBill.vue
+++ /dev/null
@@ -1,181 +0,0 @@
-<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">璁惧鍚嶇О锛�</span>
- <el-input
- v-model="searchForm.name"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button
- >
- </div>
- <div>
- <el-button type="primary" @click="openForm('add')">鏂板</el-button>
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
- </div>
- </div>
- <div class="table_list">
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
- <form-dia ref="formDia" @close="handleQuery"></form-dia>
- </div>
-</template>
-
-<script setup>
-import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref, reactive, nextTick} from "vue";
-import FormDia from "@/views/energyManagement/waterManagement/components/waterBillForm.vue";
-import {ElMessageBox} from "element-plus";
-import {waterBillDelete, waterBillListPage} from "@/api/energyManagement/waterManagement.js";
-const { proxy } = getCurrentInstance();
-
-const data = reactive({
- searchForm: {
- name: "",
- },
-});
-const { searchForm } = toRefs(data);
-
-const selectedRows = ref([]);
-const tableColumn = ref([
- {
- label: "璁惧鍚嶇О",
- prop: "name",
- width: 200,
- },
- {
- label: "瑙勬牸鍨嬪彿",
- prop: "code",
- width: 200,
- },
- {
- label: "鐢ㄦ按閲�",
- prop: "waterConsumption",
- },
- {
- label: "姘磋垂鍗曚环",
- prop: "waterPrice",
- },
- {
- label: "姘磋垂閲戦",
- prop: "waterBill",
- width:150
- },
- {
- label: "璁¤垂鏃ユ湡",
- prop: "billDate",
- width: 150,
- },
- {
- label: "鐢ㄦ按绫诲瀷",
- prop: "waterType",
- width:120
- },
- {
- dataType: "action",
- label: "鎿嶄綔",
- align: "center",
- fixed: 'right',
- operation: [
- {
- name: "缂栬緫",
- type: "text",
- clickFun: (row) => {
- openForm("edit", row);
- },
- },
- ],
- },
-]);
-const tableData = ref([]);
-const tableLoading = ref(false);
-const page = reactive({
- current: 1,
- size: 100,
- total: 0,
-});
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-const formDia = ref()
-
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-
-const getList = () => {
- tableLoading.value = true;
- waterBillListPage({ ...searchForm.value, ...page }).then((res) => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- page.total = res.data.total;
- });
-};
-
-// 鎵撳紑寮规
-const openForm = (type, row) => {
- nextTick(() => {
- formDia.value?.openDialog(type, row)
- })
-};
-
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- tableLoading.value = true;
- waterBillDelete(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-onMounted(() => {
- getList();
-});
-</script>
-
-<style scoped>
-
-</style>
diff --git a/src/views/energyManagement/waterManagement/waterTrends.vue b/src/views/energyManagement/waterManagement/waterTrends.vue
deleted file mode 100644
index 12e45fc..0000000
--- a/src/views/energyManagement/waterManagement/waterTrends.vue
+++ /dev/null
@@ -1,118 +0,0 @@
-<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">璁惧鍚嶇О锛�</span>
- <el-input
- v-model="searchForm.name"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button
- >
- </div>
- </div>
- <div class="table_list">
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
- </div>
-</template>
-
-<script setup>
-import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref, reactive} from "vue";
-import {listPageByWaterTrend} from "@/api/energyManagement/waterManagement.js";
-
-const data = reactive({
- searchForm: {
- name: "",
- },
-});
-const { searchForm } = toRefs(data);
-
-const selectedRows = ref([]);
-const tableColumn = ref([
- {
- label: "璁惧鍚嶇О",
- prop: "name",
- width: 220,
- },
- {
- label: "瑙勬牸鍨嬪彿",
- prop: "code",
- width: 220,
- },
- {
- label: "杩愯鏃堕棿",
- prop: "runDate",
- width: 250,
- },
- {
- label: "鏄ㄦ棩鐢ㄦ按閲�",
- prop: "toDayNum",
- },
- {
- label: "鏈湀骞冲潎姘撮噺",
- prop: "avgNum",
- width:150
- },
- {
- label: "瓒嬪娍",
- prop: "trend",
- width: 220,
- },
-]);
-const tableData = ref([]);
-const tableLoading = ref(false);
-const page = reactive({
- current: 1,
- size: 100,
- total: 0,
-});
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-
-const getList = () => {
- tableLoading.value = true;
- listPageByWaterTrend({ ...searchForm.value, ...page }).then((res) => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- page.total = res.data.total;
- });
-};
-
-onMounted(() => {
- getList();
-});
-</script>
-
-<style scoped>
-
-</style>
--
Gitblit v1.9.3