餐饮油烟智能监测与监管一体化平台
riku
2026-03-13 e365192a36d6d9432fbd00ea9d577a38f8679707
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<template>
  <el-container class="data-dashboard">
    <el-main>
      <div class="grid-container">
        <div class="left-section">
          <!-- 设备在线情况区域 -->
          <DeviceStatus
            :online-count="onlineCount"
            :offline-count="offlineCount"
            :normal-count="normalCount"
            :fault-count="faultCount"
          />
          <!-- 分区数据排名区域 -->
          <DistrictRanking
            style="flex: 1"
            :selected-month="selectedMonth"
            :ranking-type="rankingType"
            :ranking-data="rankingData"
            :sorted-ranking-data="sortedRankingData"
            @month-change="handleMonthChange"
            @type-change="handleTypeChange"
          />
        </div>
        <div class="right-section">
          <!-- 设备实时数据区域 -->
          <RealTimeData style="flex: 1" :devices="devices" />
        </div>
      </div>
 
      <!-- 在线设备和店铺清单区域 -->
      <ShopList
        :shops="shops"
        :shop-types="shopTypes"
        :districts="districts"
        :filter="filter"
        @filter-change="handleFilterChange"
      />
    </el-main>
  </el-container>
</template>
 
<script>
import DeviceStatus from '@/components/monitor/DeviceStatus.vue'
import RealTimeData from '@/components/monitor/RealTimeData.vue'
import DistrictRanking from '@/components/monitor/DistrictRanking.vue'
import ShopList from '@/components/monitor/ShopList.vue'
 
export default {
  name: 'DataDashboard',
  components: {
    DeviceStatus,
    RealTimeData,
    DistrictRanking,
    ShopList,
  },
  data() {
    return {
      // 设备在线情况数据
      onlineCount: 0,
      offlineCount: 0,
      normalCount: 0,
      faultCount: 0,
 
      // 设备实时数据
      devices: [],
 
      // 分区数据排名
      selectedMonth: '2023-12',
      rankingType: 'hourly',
      rankingData: [],
      sortedRankingData: [],
 
      // 筛选条件
      filter: {
        district: '',
        shopType: '',
        status: '',
      },
      shopTypes: ['中餐', '西餐', '快餐', '火锅', '烧烤'],
      districts: ['东城区', '西城区', '朝阳区', '海淀区', '丰台区'],
 
      // 店铺数据
      shops: [
        {
          id: 1,
          name: '张三餐厅',
          deviceCount: 2,
          status: '在线',
          district: '东城区',
          type: '中餐',
        },
        {
          id: 2,
          name: '李四饭店',
          deviceCount: 1,
          status: '离线',
          district: '西城区',
          type: '西餐',
        },
        {
          id: 3,
          name: '王五小吃',
          deviceCount: 3,
          status: '在线',
          district: '朝阳区',
          type: '快餐',
        },
        {
          id: 4,
          name: '赵六火锅',
          deviceCount: 2,
          status: '在线',
          district: '海淀区',
          type: '火锅',
        },
        {
          id: 5,
          name: '钱七烧烤',
          deviceCount: 1,
          status: '离线',
          district: '丰台区',
          type: '烧烤',
        },
      ],
    }
  },
  mounted() {
    this.initData()
    this.startRealTimeUpdate()
  },
  methods: {
    initData() {
      // 初始化设备在线情况数据
      this.updateDeviceStatus()
 
      // 初始化实时数据
      this.updateRealTimeData()
 
      // 初始化分区数据排名
      this.updateRankingData()
    },
 
    updateDeviceStatus() {
      // 模拟数据 - 实际应从API获取
      this.onlineCount = Math.floor(Math.random() * 50) + 50
      this.offlineCount = Math.floor(Math.random() * 20)
      this.normalCount = this.onlineCount
      this.faultCount = this.offlineCount
    },
 
    updateRealTimeData() {
      // 模拟数据 - 实际应从API获取
      this.devices = [
        {
          deviceId: 'DEV-001',
          supplier: '供应商A',
          status: '正常',
          monitorTime: new Date().toLocaleString(),
          smokeDensity: (Math.random() * 2).toFixed(2),
          fanCurrent: (Math.random() * 5 + 1).toFixed(2),
          purifierCurrent: (Math.random() * 3 + 0.5).toFixed(2),
          hourlyData: this.generateHourlyData(),
        },
        {
          deviceId: 'DEV-002',
          supplier: '供应商B',
          status: '正常',
          monitorTime: new Date().toLocaleString(),
          smokeDensity: (Math.random() * 2).toFixed(2),
          fanCurrent: (Math.random() * 5 + 1).toFixed(2),
          purifierCurrent: (Math.random() * 3 + 0.5).toFixed(2),
          hourlyData: this.generateHourlyData(),
        },
        {
          deviceId: 'DEV-003',
          supplier: '供应商C',
          status: '异常',
          monitorTime: new Date().toLocaleString(),
          smokeDensity: (Math.random() * 15 + 5).toFixed(2),
          fanCurrent: (Math.random() * 3 + 4).toFixed(2),
          purifierCurrent: (Math.random() * 2 + 2).toFixed(2),
          hourlyData: this.generateHourlyData(),
        },
        {
          deviceId: 'DEV-004',
          supplier: '供应商D',
          status: '异常',
          monitorTime: new Date().toLocaleString(),
          smokeDensity: (Math.random() * 15 + 5).toFixed(2),
          fanCurrent: (Math.random() * 3 + 4).toFixed(2),
          purifierCurrent: (Math.random() * 2 + 2).toFixed(2),
          hourlyData: this.generateHourlyData(),
        },
      ]
    },
 
    generateHourlyData() {
      // 生成模拟的近一小时数据
      const hourlyData = []
      for (let i = 59; i >= 0; i--) {
        const time = new Date()
        time.setMinutes(time.getMinutes() - i)
        hourlyData.push({
          time: time.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' }),
          smokeDensity: (Math.random() * 2).toFixed(2),
          fanCurrent: (Math.random() * 5 + 1).toFixed(2),
          purifierCurrent: (Math.random() * 3 + 0.5).toFixed(2),
        })
      }
      return hourlyData
    },
 
    updateRankingData() {
      // 模拟数据 - 实际应从API获取
      this.rankingData = [
        { name: '玄武区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 0 },
        { name: '秦淮区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: -1 },
        { name: '建邺区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 1 },
        { name: '鼓楼区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 0 },
        { name: '浦口区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: -2 },
        { name: '栖霞区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 2 },
        { name: '雨花台区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 0 },
        { name: '江宁区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 1 },
        { name: '六合区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: -1 },
        { name: '溧水区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 0 },
        { name: '高淳区', value: (Math.random() * 1.5 + 0.5).toFixed(2), rankChange: 1 },
      ]
 
      // 排序
      this.sortedRankingData = [...this.rankingData].sort(
        (a, b) => parseFloat(b.value) - parseFloat(a.value),
      )
    },
 
    startRealTimeUpdate() {
      // 每30秒更新一次数据
      this.realTimeInterval = setInterval(() => {
        this.updateDeviceStatus()
        this.updateRealTimeData()
      }, 30000)
    },
 
    handleMonthChange(val) {
      this.selectedMonth = val
      this.updateRankingData()
    },
 
    handleTypeChange(val) {
      this.rankingType = val
      this.updateRankingData()
    },
 
    handleFilterChange(val) {
      this.filter = { ...val }
    },
  },
}
</script>
 
<style scoped>
.data-dashboard {
  min-height: 100vh;
  background-color: #f5f7fa;
}
 
.el-header {
  padding: 20px;
  background-color: #f5f7fa;
}
 
.el-header h1 {
  font-size: 24px;
  margin: 0;
  color: #333;
}
 
.el-main {
  padding: 20px;
}
 
.grid-container {
  display: flex;
  /* display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: min-content; */
  gap: 20px;
}
 
.left-section {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
 
.right-section {
  width: 670px;
  display: flex;
  flex-direction: column;
}
 
/* 响应式设计 */
@media (max-width: 768px) {
  .grid-container {
    grid-template-columns: 1fr;
  }
 
  .left-section,
  .right-section {
    margin-bottom: 10px;
  }
}
</style>