|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="leakage-analysis">
|
|
|
3
|
+ <!-- 顶部筛选区 -->
|
|
|
4
|
+ <el-card shadow="never" class="filter-card">
|
|
|
5
|
+ <el-form :inline="true" :model="filterForm">
|
|
|
6
|
+ <el-form-item label="选择分区">
|
|
|
7
|
+ <el-select v-model="filterForm.zoneId" placeholder="全部分区" clearable @change="handleFilterChange" style="width: 220px">
|
|
|
8
|
+ <el-option v-for="z in zoneList" :key="z.id" :label="z.zoneName" :value="z.id" />
|
|
|
9
|
+ </el-select>
|
|
|
10
|
+ </el-form-item>
|
|
|
11
|
+ <el-form-item label="时间范围">
|
|
|
12
|
+ <el-date-picker v-model="dateRange" type="daterange" range-separator="至"
|
|
|
13
|
+ start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD"
|
|
|
14
|
+ @change="handleFilterChange" />
|
|
|
15
|
+ </el-form-item>
|
|
|
16
|
+ <el-form-item>
|
|
|
17
|
+ <el-button type="primary" @click="handleFilterChange">
|
|
|
18
|
+ <el-icon><Search /></el-icon> 查询
|
|
|
19
|
+ </el-button>
|
|
|
20
|
+ <el-button @click="handleReset">重置</el-button>
|
|
|
21
|
+ </el-form-item>
|
|
|
22
|
+ </el-form>
|
|
|
23
|
+ </el-card>
|
|
|
24
|
+
|
|
|
25
|
+ <!-- 统计卡片 -->
|
|
|
26
|
+ <el-row :gutter="12" style="margin-top: 12px">
|
|
|
27
|
+ <el-col :span="6">
|
|
|
28
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
29
|
+ <div class="stat-value" style="color: #409eff">{{ summaryStats.totalSupply }}</div>
|
|
|
30
|
+ <div class="stat-label">总供水量 (m³)</div>
|
|
|
31
|
+ </el-card>
|
|
|
32
|
+ </el-col>
|
|
|
33
|
+ <el-col :span="6">
|
|
|
34
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
35
|
+ <div class="stat-value" style="color: #67c23a">{{ summaryStats.totalSale }}</div>
|
|
|
36
|
+ <div class="stat-label">总售水量 (m³)</div>
|
|
|
37
|
+ </el-card>
|
|
|
38
|
+ </el-col>
|
|
|
39
|
+ <el-col :span="6">
|
|
|
40
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
41
|
+ <div class="stat-value" style="color: #e6a23c">{{ summaryStats.avgNrwRate }}%</div>
|
|
|
42
|
+ <div class="stat-label">平均产销差率</div>
|
|
|
43
|
+ </el-card>
|
|
|
44
|
+ </el-col>
|
|
|
45
|
+ <el-col :span="6">
|
|
|
46
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
47
|
+ <div class="stat-value" style="color: #f56c6c">{{ summaryStats.alarmCount }}</div>
|
|
|
48
|
+ <div class="stat-label">报警次数</div>
|
|
|
49
|
+ </el-card>
|
|
|
50
|
+ </el-col>
|
|
|
51
|
+ </el-row>
|
|
|
52
|
+
|
|
|
53
|
+ <!-- 图表区 -->
|
|
|
54
|
+ <el-row :gutter="12" style="margin-top: 12px">
|
|
|
55
|
+ <!-- 供水量/售水量对比柱状图 -->
|
|
|
56
|
+ <el-col :span="12">
|
|
|
57
|
+ <el-card shadow="never">
|
|
|
58
|
+ <template #header>供水量/售水量对比</template>
|
|
|
59
|
+ <div ref="barChartRef" style="height: 350px"></div>
|
|
|
60
|
+ </el-card>
|
|
|
61
|
+ </el-col>
|
|
|
62
|
+ <!-- 漏损率趋势折线图 -->
|
|
|
63
|
+ <el-col :span="12">
|
|
|
64
|
+ <el-card shadow="never">
|
|
|
65
|
+ <template #header>漏损率趋势</template>
|
|
|
66
|
+ <div ref="lineChartRef" style="height: 350px"></div>
|
|
|
67
|
+ </el-card>
|
|
|
68
|
+ </el-col>
|
|
|
69
|
+ </el-row>
|
|
|
70
|
+
|
|
|
71
|
+ <!-- 夜间最小流量 + 漏损分析操作 -->
|
|
|
72
|
+ <el-row :gutter="12" style="margin-top: 12px">
|
|
|
73
|
+ <el-col :span="8">
|
|
|
74
|
+ <el-card shadow="never">
|
|
|
75
|
+ <template #header>夜间最小流量 (MNF)</template>
|
|
|
76
|
+ <div style="text-align: center; padding: 20px 0">
|
|
|
77
|
+ <div style="font-size: 48px; font-weight: bold; color: #409eff">{{ mnfData.mnf }}</div>
|
|
|
78
|
+ <div style="font-size: 14px; color: #999; margin-top: 8px">m³/h (02:00-04:00)</div>
|
|
|
79
|
+ <el-tag :type="mnfData.analysisResult === '正常' ? 'success' : 'danger'" size="large" style="margin-top: 12px">
|
|
|
80
|
+ {{ mnfData.analysisResult }}
|
|
|
81
|
+ </el-tag>
|
|
|
82
|
+ <div style="margin-top: 16px">
|
|
|
83
|
+ <el-date-picker v-model="mnfDate" type="date" placeholder="选择日期" value-format="YYYY-MM-DD"
|
|
|
84
|
+ @change="loadMNF" style="width: 160px" />
|
|
|
85
|
+ </div>
|
|
|
86
|
+ </div>
|
|
|
87
|
+ </el-card>
|
|
|
88
|
+ </el-col>
|
|
|
89
|
+ <el-col :span="16">
|
|
|
90
|
+ <el-card shadow="never">
|
|
|
91
|
+ <template #header>
|
|
|
92
|
+ <div style="display: flex; justify-content: space-between; align-items: center">
|
|
|
93
|
+ <span>执行漏损分析</span>
|
|
|
94
|
+ </div>
|
|
|
95
|
+ </template>
|
|
|
96
|
+ <el-form :inline="true" :model="analyzeForm">
|
|
|
97
|
+ <el-form-item label="分区">
|
|
|
98
|
+ <el-select v-model="analyzeForm.zoneId" placeholder="选择分区" style="width: 160px">
|
|
|
99
|
+ <el-option v-for="z in zoneList" :key="z.id" :label="z.zoneName" :value="z.id" />
|
|
|
100
|
+ </el-select>
|
|
|
101
|
+ </el-form-item>
|
|
|
102
|
+ <el-form-item label="日期">
|
|
|
103
|
+ <el-date-picker v-model="analyzeForm.date" type="date" value-format="YYYY-MM-DD" style="width: 150px" />
|
|
|
104
|
+ </el-form-item>
|
|
|
105
|
+ <el-form-item label="供水量(m³)">
|
|
|
106
|
+ <el-input-number v-model="analyzeForm.supplyVolume" :min="0" :precision="2" controls-position="right" style="width: 130px" />
|
|
|
107
|
+ </el-form-item>
|
|
|
108
|
+ <el-form-item label="售水量(m³)">
|
|
|
109
|
+ <el-input-number v-model="analyzeForm.saleVolume" :min="0" :precision="2" controls-position="right" style="width: 130px" />
|
|
|
110
|
+ </el-form-item>
|
|
|
111
|
+ <el-form-item>
|
|
|
112
|
+ <el-button type="primary" @click="handleAnalyze" :loading="analyzing">执行分析</el-button>
|
|
|
113
|
+ </el-form-item>
|
|
|
114
|
+ </el-form>
|
|
|
115
|
+
|
|
|
116
|
+ <!-- 最近分析结果 -->
|
|
|
117
|
+ <div v-if="lastResult" style="margin-top: 12px; padding: 12px; background: #f5f7fa; border-radius: 4px">
|
|
|
118
|
+ <el-descriptions :column="4" size="small" border>
|
|
|
119
|
+ <el-descriptions-item label="漏损量">{{ lastResult.leakageVolume }} m³</el-descriptions-item>
|
|
|
120
|
+ <el-descriptions-item label="产销差率">{{ lastResult.nrwRate }}%</el-descriptions-item>
|
|
|
121
|
+ <el-descriptions-item label="漏损率">{{ lastResult.leakageRate }}%</el-descriptions-item>
|
|
|
122
|
+ <el-descriptions-item label="报警级别">
|
|
|
123
|
+ <el-tag :type="alarmTagType(lastResult.alarmLevel)" size="small">
|
|
|
124
|
+ {{ alarmLabel(lastResult.alarmLevel) }}
|
|
|
125
|
+ </el-tag>
|
|
|
126
|
+ </el-descriptions-item>
|
|
|
127
|
+ </el-descriptions>
|
|
|
128
|
+ </div>
|
|
|
129
|
+ </el-card>
|
|
|
130
|
+ </el-col>
|
|
|
131
|
+ </el-row>
|
|
|
132
|
+
|
|
|
133
|
+ <!-- 报警列表 -->
|
|
|
134
|
+ <el-card shadow="never" style="margin-top: 12px">
|
|
|
135
|
+ <template #header>
|
|
|
136
|
+ <div style="display: flex; justify-content: space-between; align-items: center">
|
|
|
137
|
+ <span>漏损报警列表</span>
|
|
|
138
|
+ <el-radio-group v-model="alarmFilter" size="small" @change="loadAlarms">
|
|
|
139
|
+ <el-radio-button value="">全部报警</el-radio-button>
|
|
|
140
|
+ <el-radio-button value="warning">预警</el-radio-button>
|
|
|
141
|
+ <el-radio-button value="critical">严重</el-radio-button>
|
|
|
142
|
+ </el-radio-group>
|
|
|
143
|
+ </div>
|
|
|
144
|
+ </template>
|
|
|
145
|
+ <el-table :data="alarmList" border stripe v-loading="alarmLoading">
|
|
|
146
|
+ <el-table-column prop="analysisDate" label="日期" width="120" />
|
|
|
147
|
+ <el-table-column label="分区" width="160">
|
|
|
148
|
+ <template #default="{ row }">{{ getZoneName(row.zoneId) }}</template>
|
|
|
149
|
+ </el-table-column>
|
|
|
150
|
+ <el-table-column prop="supplyVolume" label="供水量(m³)" width="120" align="right" />
|
|
|
151
|
+ <el-table-column prop="saleVolume" label="售水量(m³)" width="120" align="right" />
|
|
|
152
|
+ <el-table-column prop="leakageVolume" label="漏损量(m³)" width="120" align="right" />
|
|
|
153
|
+ <el-table-column prop="nrwRate" label="产销差率(%)" width="120" align="right">
|
|
|
154
|
+ <template #default="{ row }">
|
|
|
155
|
+ <span :style="{ color: row.nrwRate > 20 ? '#f56c6c' : row.nrwRate > 12 ? '#e6a23c' : '#67c23a' }">
|
|
|
156
|
+ {{ row.nrwRate }}%
|
|
|
157
|
+ </span>
|
|
|
158
|
+ </template>
|
|
|
159
|
+ </el-table-column>
|
|
|
160
|
+ <el-table-column prop="mnf" label="MNF(m³/h)" width="110" align="right" />
|
|
|
161
|
+ <el-table-column prop="alarmLevel" label="报警级别" width="100" align="center">
|
|
|
162
|
+ <template #default="{ row }">
|
|
|
163
|
+ <el-tag :type="alarmTagType(row.alarmLevel)" size="small">{{ alarmLabel(row.alarmLevel) }}</el-tag>
|
|
|
164
|
+ </template>
|
|
|
165
|
+ </el-table-column>
|
|
|
166
|
+ </el-table>
|
|
|
167
|
+ </el-card>
|
|
|
168
|
+
|
|
|
169
|
+ <!-- 漏损数据分页列表 -->
|
|
|
170
|
+ <el-card shadow="never" style="margin-top: 12px">
|
|
|
171
|
+ <template #header>漏损分析记录</template>
|
|
|
172
|
+ <el-table :data="leakageList" border stripe v-loading="leakageLoading">
|
|
|
173
|
+ <el-table-column prop="analysisDate" label="日期" width="120" />
|
|
|
174
|
+ <el-table-column label="分区" width="160">
|
|
|
175
|
+ <template #default="{ row }">{{ getZoneName(row.zoneId) }}</template>
|
|
|
176
|
+ </el-table-column>
|
|
|
177
|
+ <el-table-column prop="supplyVolume" label="供水量(m³)" width="120" align="right" />
|
|
|
178
|
+ <el-table-column prop="saleVolume" label="售水量(m³)" width="120" align="right" />
|
|
|
179
|
+ <el-table-column prop="leakageVolume" label="漏损量(m³)" width="120" align="right" />
|
|
|
180
|
+ <el-table-column prop="nrwRate" label="产销差率(%)" width="110" align="right" />
|
|
|
181
|
+ <el-table-column prop="leakageRate" label="漏损率(%)" width="100" align="right" />
|
|
|
182
|
+ <el-table-column prop="mnf" label="MNF(m³/h)" width="100" align="right" />
|
|
|
183
|
+ <el-table-column prop="alarmLevel" label="报警级别" width="100" align="center">
|
|
|
184
|
+ <template #default="{ row }">
|
|
|
185
|
+ <el-tag :type="alarmTagType(row.alarmLevel)" size="small">{{ alarmLabel(row.alarmLevel) }}</el-tag>
|
|
|
186
|
+ </template>
|
|
|
187
|
+ </el-table-column>
|
|
|
188
|
+ </el-table>
|
|
|
189
|
+ <el-pagination
|
|
|
190
|
+ style="margin-top: 12px; justify-content: flex-end"
|
|
|
191
|
+ :current-page="leakagePage"
|
|
|
192
|
+ :page-size="leakagePageSize"
|
|
|
193
|
+ :total="leakageTotal"
|
|
|
194
|
+ layout="total, prev, pager, next"
|
|
|
195
|
+ @current-change="handleLeakagePageChange"
|
|
|
196
|
+ />
|
|
|
197
|
+ </el-card>
|
|
|
198
|
+ </div>
|
|
|
199
|
+</template>
|
|
|
200
|
+
|
|
|
201
|
+<script setup lang="ts">
|
|
|
202
|
+import { ref, reactive, onMounted, nextTick } from 'vue'
|
|
|
203
|
+import { ElMessage } from 'element-plus'
|
|
|
204
|
+import { Search } from '@element-plus/icons-vue'
|
|
|
205
|
+import * as echarts from 'echarts'
|
|
|
206
|
+import {
|
|
|
207
|
+ getLeakagePage, analyzeLeakage, getLeakageTrend, getAlarms,
|
|
|
208
|
+ getZoneSummary, getAllZones, getMNFAnalysis
|
|
|
209
|
+} from '@/api/dma'
|
|
|
210
|
+
|
|
|
211
|
+// 分区列表
|
|
|
212
|
+const zoneList = ref<any[]>([])
|
|
|
213
|
+
|
|
|
214
|
+// 筛选
|
|
|
215
|
+const filterForm = reactive({ zoneId: null as number | null })
|
|
|
216
|
+const dateRange = ref<[string, string] | null>(null)
|
|
|
217
|
+
|
|
|
218
|
+// 统计卡片
|
|
|
219
|
+const summaryStats = reactive({ totalSupply: '0', totalSale: '0', avgNrwRate: '0', alarmCount: 0 })
|
|
|
220
|
+
|
|
|
221
|
+// 图表
|
|
|
222
|
+const barChartRef = ref<HTMLElement>()
|
|
|
223
|
+const lineChartRef = ref<HTMLElement>()
|
|
|
224
|
+let barChart: echarts.ECharts | null = null
|
|
|
225
|
+let lineChart: echarts.ECharts | null = null
|
|
|
226
|
+
|
|
|
227
|
+// MNF
|
|
|
228
|
+const mnfDate = ref('')
|
|
|
229
|
+const mnfData = reactive({ mnf: '0', analysisResult: '正常' })
|
|
|
230
|
+
|
|
|
231
|
+// 漏损分析操作
|
|
|
232
|
+const analyzeForm = reactive({
|
|
|
233
|
+ zoneId: null as number | null, date: '', supplyVolume: 0, saleVolume: 0
|
|
|
234
|
+})
|
|
|
235
|
+const analyzing = ref(false)
|
|
|
236
|
+const lastResult = ref<any>(null)
|
|
|
237
|
+
|
|
|
238
|
+// 报警
|
|
|
239
|
+const alarmFilter = ref('')
|
|
|
240
|
+const alarmList = ref<any[]>([])
|
|
|
241
|
+const alarmLoading = ref(false)
|
|
|
242
|
+
|
|
|
243
|
+// 漏损记录列表
|
|
|
244
|
+const leakageList = ref<any[]>([])
|
|
|
245
|
+const leakageLoading = ref(false)
|
|
|
246
|
+const leakagePage = ref(1)
|
|
|
247
|
+const leakagePageSize = ref(10)
|
|
|
248
|
+const leakageTotal = ref(0)
|
|
|
249
|
+
|
|
|
250
|
+function alarmTagType(level: string) {
|
|
|
251
|
+ return level === 'critical' ? 'danger' : level === 'warning' ? 'warning' : 'success'
|
|
|
252
|
+}
|
|
|
253
|
+function alarmLabel(level: string) {
|
|
|
254
|
+ return level === 'critical' ? '严重' : level === 'warning' ? '预警' : '正常'
|
|
|
255
|
+}
|
|
|
256
|
+function getZoneName(zoneId: number) {
|
|
|
257
|
+ return zoneList.value.find(z => z.id === zoneId)?.zoneName || String(zoneId)
|
|
|
258
|
+}
|
|
|
259
|
+
|
|
|
260
|
+async function loadZones() {
|
|
|
261
|
+ try {
|
|
|
262
|
+ const res = await getAllZones()
|
|
|
263
|
+ zoneList.value = res.data || []
|
|
|
264
|
+ } catch (e) { /* ignore */ }
|
|
|
265
|
+}
|
|
|
266
|
+
|
|
|
267
|
+async function loadTrend() {
|
|
|
268
|
+ if (!filterForm.zoneId) {
|
|
|
269
|
+ initEmptyCharts()
|
|
|
270
|
+ return
|
|
|
271
|
+ }
|
|
|
272
|
+ try {
|
|
|
273
|
+ const days = 30
|
|
|
274
|
+ const res = await getLeakageTrend(filterForm.zoneId, days)
|
|
|
275
|
+ const data = res.data || []
|
|
|
276
|
+ renderBarChart(data)
|
|
|
277
|
+ renderLineChart(data)
|
|
|
278
|
+ updateSummaryStats(data)
|
|
|
279
|
+ } catch (e) {
|
|
|
280
|
+ initEmptyCharts()
|
|
|
281
|
+ }
|
|
|
282
|
+}
|
|
|
283
|
+
|
|
|
284
|
+function updateSummaryStats(data: any[]) {
|
|
|
285
|
+ if (!data.length) {
|
|
|
286
|
+ summaryStats.totalSupply = '0'
|
|
|
287
|
+ summaryStats.totalSale = '0'
|
|
|
288
|
+ summaryStats.avgNrwRate = '0'
|
|
|
289
|
+ summaryStats.alarmCount = 0
|
|
|
290
|
+ return
|
|
|
291
|
+ }
|
|
|
292
|
+ let totalSupply = 0, totalSale = 0, totalNrw = 0, alarmCount = 0
|
|
|
293
|
+ for (const d of data) {
|
|
|
294
|
+ totalSupply += Number(d.supplyVolume || 0)
|
|
|
295
|
+ totalSale += Number(d.saleVolume || 0)
|
|
|
296
|
+ totalNrw += Number(d.nrwRate || 0)
|
|
|
297
|
+ if (d.alarmLevel && d.alarmLevel !== 'normal') alarmCount++
|
|
|
298
|
+ }
|
|
|
299
|
+ summaryStats.totalSupply = totalSupply.toFixed(0)
|
|
|
300
|
+ summaryStats.totalSale = totalSale.toFixed(0)
|
|
|
301
|
+ summaryStats.avgNrwRate = (totalNrw / data.length).toFixed(2)
|
|
|
302
|
+ summaryStats.alarmCount = alarmCount
|
|
|
303
|
+}
|
|
|
304
|
+
|
|
|
305
|
+function renderBarChart(data: any[]) {
|
|
|
306
|
+ if (!barChartRef.value) return
|
|
|
307
|
+ if (!barChart) barChart = echarts.init(barChartRef.value)
|
|
|
308
|
+ const dates = data.map(d => d.date)
|
|
|
309
|
+ barChart.setOption({
|
|
|
310
|
+ tooltip: { trigger: 'axis' },
|
|
|
311
|
+ legend: { data: ['供水量', '售水量'], bottom: 0 },
|
|
|
312
|
+ grid: { left: '3%', right: '4%', bottom: '12%', containLabel: true },
|
|
|
313
|
+ xAxis: { type: 'category', data: dates, axisLabel: { rotate: 45, fontSize: 10 } },
|
|
|
314
|
+ yAxis: { type: 'value', name: 'm³' },
|
|
|
315
|
+ series: [
|
|
|
316
|
+ { name: '供水量', type: 'bar', data: data.map(d => d.supplyVolume), itemStyle: { color: '#409eff' } },
|
|
|
317
|
+ { name: '售水量', type: 'bar', data: data.map(d => d.saleVolume), itemStyle: { color: '#67c23a' } }
|
|
|
318
|
+ ]
|
|
|
319
|
+ })
|
|
|
320
|
+}
|
|
|
321
|
+
|
|
|
322
|
+function renderLineChart(data: any[]) {
|
|
|
323
|
+ if (!lineChartRef.value) return
|
|
|
324
|
+ if (!lineChart) lineChart = echarts.init(lineChartRef.value)
|
|
|
325
|
+ const dates = data.map(d => d.date)
|
|
|
326
|
+ lineChart.setOption({
|
|
|
327
|
+ tooltip: { trigger: 'axis', formatter: '{b}<br/>{a}: {c}%' },
|
|
|
328
|
+ legend: { data: ['产销差率', '漏损率'], bottom: 0 },
|
|
|
329
|
+ grid: { left: '3%', right: '4%', bottom: '12%', containLabel: true },
|
|
|
330
|
+ xAxis: { type: 'category', data: dates, axisLabel: { rotate: 45, fontSize: 10 } },
|
|
|
331
|
+ yAxis: { type: 'value', name: '%', axisLabel: { formatter: '{value}%' } },
|
|
|
332
|
+ series: [
|
|
|
333
|
+ {
|
|
|
334
|
+ name: '产销差率', type: 'line', data: data.map(d => d.nrwRate), smooth: true,
|
|
|
335
|
+ itemStyle: { color: '#e6a23c' },
|
|
|
336
|
+ markLine: {
|
|
|
337
|
+ silent: true,
|
|
|
338
|
+ data: [
|
|
|
339
|
+ { yAxis: 12, lineStyle: { color: '#e6a23c', type: 'dashed' }, label: { formatter: '预警线 12%' } },
|
|
|
340
|
+ { yAxis: 20, lineStyle: { color: '#f56c6c', type: 'dashed' }, label: { formatter: '严重线 20%' } }
|
|
|
341
|
+ ]
|
|
|
342
|
+ }
|
|
|
343
|
+ },
|
|
|
344
|
+ {
|
|
|
345
|
+ name: '漏损率', type: 'line', data: data.map(d => d.leakageRate || d.nrwRate), smooth: true,
|
|
|
346
|
+ itemStyle: { color: '#f56c6c' }
|
|
|
347
|
+ }
|
|
|
348
|
+ ]
|
|
|
349
|
+ })
|
|
|
350
|
+}
|
|
|
351
|
+
|
|
|
352
|
+function initEmptyCharts() {
|
|
|
353
|
+ if (barChartRef.value) {
|
|
|
354
|
+ if (!barChart) barChart = echarts.init(barChartRef.value)
|
|
|
355
|
+ barChart.setOption({
|
|
|
356
|
+ title: { text: '请选择分区查看数据', left: 'center', top: 'center', textStyle: { color: '#999', fontSize: 14 } },
|
|
|
357
|
+ xAxis: { type: 'category', data: [] }, yAxis: { type: 'value' }, series: []
|
|
|
358
|
+ })
|
|
|
359
|
+ }
|
|
|
360
|
+ if (lineChartRef.value) {
|
|
|
361
|
+ if (!lineChart) lineChart = echarts.init(lineChartRef.value)
|
|
|
362
|
+ lineChart.setOption({
|
|
|
363
|
+ title: { text: '请选择分区查看数据', left: 'center', top: 'center', textStyle: { color: '#999', fontSize: 14 } },
|
|
|
364
|
+ xAxis: { type: 'category', data: [] }, yAxis: { type: 'value' }, series: []
|
|
|
365
|
+ })
|
|
|
366
|
+ }
|
|
|
367
|
+}
|
|
|
368
|
+
|
|
|
369
|
+async function loadMNF() {
|
|
|
370
|
+ if (!filterForm.zoneId || !mnfDate.value) return
|
|
|
371
|
+ try {
|
|
|
372
|
+ const res = await getMNFAnalysis(filterForm.zoneId, mnfDate.value)
|
|
|
373
|
+ const d = res.data
|
|
|
374
|
+ mnfData.mnf = String(d.mnf || '0')
|
|
|
375
|
+ mnfData.analysisResult = d.analysisResult || '正常'
|
|
|
376
|
+ } catch (e) { /* ignore */ }
|
|
|
377
|
+}
|
|
|
378
|
+
|
|
|
379
|
+async function handleAnalyze() {
|
|
|
380
|
+ if (!analyzeForm.zoneId || !analyzeForm.date) {
|
|
|
381
|
+ ElMessage.warning('请选择分区和日期')
|
|
|
382
|
+ return
|
|
|
383
|
+ }
|
|
|
384
|
+ analyzing.value = true
|
|
|
385
|
+ try {
|
|
|
386
|
+ const res = await analyzeLeakage({
|
|
|
387
|
+ zoneId: analyzeForm.zoneId,
|
|
|
388
|
+ date: analyzeForm.date,
|
|
|
389
|
+ supplyVolume: analyzeForm.supplyVolume,
|
|
|
390
|
+ saleVolume: analyzeForm.saleVolume
|
|
|
391
|
+ })
|
|
|
392
|
+ lastResult.value = res.data
|
|
|
393
|
+ ElMessage.success('分析完成')
|
|
|
394
|
+ loadLeakagePage()
|
|
|
395
|
+ loadTrend()
|
|
|
396
|
+ } catch (e: any) {
|
|
|
397
|
+ ElMessage.error(e.message || '分析失败')
|
|
|
398
|
+ } finally {
|
|
|
399
|
+ analyzing.value = false
|
|
|
400
|
+ }
|
|
|
401
|
+}
|
|
|
402
|
+
|
|
|
403
|
+async function loadAlarms() {
|
|
|
404
|
+ alarmLoading.value = true
|
|
|
405
|
+ try {
|
|
|
406
|
+ const res = await getAlarms(alarmFilter.value || undefined)
|
|
|
407
|
+ alarmList.value = res.data || []
|
|
|
408
|
+ } finally {
|
|
|
409
|
+ alarmLoading.value = false
|
|
|
410
|
+ }
|
|
|
411
|
+}
|
|
|
412
|
+
|
|
|
413
|
+async function loadLeakagePage() {
|
|
|
414
|
+ leakageLoading.value = true
|
|
|
415
|
+ try {
|
|
|
416
|
+ const params: any = { pageNum: leakagePage.value, pageSize: leakagePageSize.value }
|
|
|
417
|
+ if (filterForm.zoneId) params.zoneId = filterForm.zoneId
|
|
|
418
|
+ if (dateRange.value) {
|
|
|
419
|
+ params.startDate = dateRange.value[0]
|
|
|
420
|
+ params.endDate = dateRange.value[1]
|
|
|
421
|
+ }
|
|
|
422
|
+ const res = await getLeakagePage(params)
|
|
|
423
|
+ leakageList.value = res.data?.records || []
|
|
|
424
|
+ leakageTotal.value = res.data?.total || 0
|
|
|
425
|
+ } finally {
|
|
|
426
|
+ leakageLoading.value = false
|
|
|
427
|
+ }
|
|
|
428
|
+}
|
|
|
429
|
+
|
|
|
430
|
+function handleFilterChange() {
|
|
|
431
|
+ loadTrend()
|
|
|
432
|
+ loadLeakagePage()
|
|
|
433
|
+ if (filterForm.zoneId) {
|
|
|
434
|
+ const today = new Date().toISOString().split('T')[0]
|
|
|
435
|
+ mnfDate.value = today
|
|
|
436
|
+ loadMNF()
|
|
|
437
|
+ }
|
|
|
438
|
+}
|
|
|
439
|
+
|
|
|
440
|
+function handleReset() {
|
|
|
441
|
+ filterForm.zoneId = null
|
|
|
442
|
+ dateRange.value = null
|
|
|
443
|
+ handleFilterChange()
|
|
|
444
|
+}
|
|
|
445
|
+
|
|
|
446
|
+function handleLeakagePageChange(p: number) {
|
|
|
447
|
+ leakagePage.value = p
|
|
|
448
|
+ loadLeakagePage()
|
|
|
449
|
+}
|
|
|
450
|
+
|
|
|
451
|
+onMounted(async () => {
|
|
|
452
|
+ await loadZones()
|
|
|
453
|
+ await nextTick()
|
|
|
454
|
+ initEmptyCharts()
|
|
|
455
|
+ loadAlarms()
|
|
|
456
|
+ loadLeakagePage()
|
|
|
457
|
+
|
|
|
458
|
+ window.addEventListener('resize', () => {
|
|
|
459
|
+ barChart?.resize()
|
|
|
460
|
+ lineChart?.resize()
|
|
|
461
|
+ })
|
|
|
462
|
+})
|
|
|
463
|
+</script>
|
|
|
464
|
+
|
|
|
465
|
+<style scoped>
|
|
|
466
|
+.leakage-analysis { padding: 0; }
|
|
|
467
|
+.filter-card :deep(.el-card__body) { padding-bottom: 2px; }
|
|
|
468
|
+.stat-card { text-align: center; cursor: default; }
|
|
|
469
|
+.stat-value { font-size: 28px; font-weight: bold; }
|
|
|
470
|
+.stat-label { font-size: 13px; color: #999; margin-top: 4px; }
|
|
|
471
|
+</style>
|