餐饮油烟智能监测与监管一体化平台
riku
2026-03-17 45c217996d025d256fdd0ed5cb744750e68dd36d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<!-- e:\VSprojects\fume-supervision-vue\src\components\monitor\DeviceStatus.vue -->
<template>
  <el-card class="section" shadow="hover">
    <template #header>
      <div class="card-header">
        <span>设备在线情况</span>
      </div>
    </template>
    <el-row :gutter="0">
      <el-col :span="12">
        <el-row :gutter="10">
          <el-col :span="12">
            <el-card class="status-card online-card" shadow="hover">
              <div class="status-content">
                <el-icon class="status-icon online-icon"><iconify-icon icon="mdi:wifi" /></el-icon>
                <el-statistic title="在线设备" :value="onlineCount" />
              </div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="status-card offline-card" shadow="hover">
              <div class="status-content">
                <el-icon class="status-icon"><iconify-icon icon="mdi:wifi-off" /></el-icon>
                <el-statistic title="离线设备" :value="offlineCount" />
              </div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="status-card normal-card" shadow="hover">
              <div class="status-content">
                <el-icon class="status-icon normal-icon"
                  ><iconify-icon icon="mdi:check-circle"
                /></el-icon>
                <el-statistic title="正常设备" :value="normalCount" />
              </div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="status-card fault-card" shadow="hover">
              <div class="status-content">
                <el-icon class="status-icon"><iconify-icon icon="mdi:alert-circle" /></el-icon>
                <el-statistic title="故障设备" :value="faultCount" />
              </div>
            </el-card>
          </el-col>
        </el-row>
      </el-col>
      <el-col :span="12">
        <!-- <el-card class="chart-card" shadow="hover"> -->
        <div id="deviceChart" ref="chartRef" class="chart-container"></div>
        <!-- </el-card> -->
      </el-col>
    </el-row>
  </el-card>
</template>
 
<script>
import * as echarts from 'echarts'
import { Icon } from '@iconify/vue'
 
export default {
  name: 'DeviceStatus',
  components: {
    IconifyIcon: Icon,
  },
  props: {
    onlineCount: {
      type: Number,
      default: 0,
    },
    offlineCount: {
      type: Number,
      default: 0,
    },
    normalCount: {
      type: Number,
      default: 0,
    },
    faultCount: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      chart: null,
    }
  },
  mounted() {
    this.initChart()
  },
  watch: {
    onlineCount() {
      this.updateChart()
    },
    offlineCount() {
      this.updateChart()
    },
    normalCount() {
      this.updateChart()
    },
    faultCount() {
      this.updateChart()
    },
  },
  beforeUnmount() {
    if (this.chart) {
      this.chart.dispose()
    }
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$refs.chartRef)
      this.updateChart()
 
      window.addEventListener('resize', () => {
        this.chart.resize()
      })
    },
    updateChart() {
      if (!this.chart) return
 
      const option = {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b}: {c} ({d}%)',
        },
        legend: {
          show: false,
          bottom: '0%',
          data: ['在线设备', '离线设备', '正常设备', '故障设备'],
        },
        series: [
          {
            name: '在线状态',
            type: 'pie',
            radius: ['20%', '40%'],
            center: ['48%', '50%'],
            startAngle: 270,
            endAngle: 90,
            data: [
              { value: this.onlineCount, name: '在线设备', itemStyle: { color: '#67C23A' } },
              { value: this.offlineCount, name: '离线设备', itemStyle: { color: '#909399' } },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)',
              },
            },
          },
          {
            name: '运行状态',
            type: 'pie',
            radius: ['30%', '50%'],
            center: ['52%', '50%'],
            startAngle: 90,
            endAngle: 270,
            data: [
              { value: this.normalCount, name: '正常设备', itemStyle: { color: '#409EFF' } },
              { value: this.faultCount, name: '故障设备', itemStyle: { color: '#F56C6C' } },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)',
              },
            },
          },
        ],
      }
 
      this.chart.setOption(option)
    },
  },
}
</script>
 
<style scoped>
.section {
  margin-bottom: 20px;
}
 
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.status-card {
  text-align: center;
  transition: transform 0.3s ease;
  margin-bottom: 20px;
}
 
.status-card:hover {
  transform: translateY(-5px);
}
 
.status-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
 
.status-icon {
  font-size: 32px;
}
 
.online-icon {
  color: #67c23a;
  animation: pulse 2s infinite;
}
 
.normal-icon {
  color: #409eff;
  animation: pulse 2s infinite;
}
 
.online-card {
  border-top: 4px solid #67c23a;
}
 
.offline-card {
  border-top: 4px solid #909399;
}
 
.normal-card {
  border-top: 4px solid #409eff;
}
 
.fault-card {
  border-top: 4px solid #f56c6c;
}
 
.chart-card {
  width: 100%;
  height: 300px;
}
 
.chart-container {
  width: 100%;
  height: 300px;
}
 
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}
 
/* 响应式设计 */
@media (max-width: 768px) {
  .el-row {
    flex-direction: column;
  }
 
  .el-col {
    width: 100% !important;
    margin-bottom: 10px;
  }
}
</style>