餐饮油烟智能监测与监管一体化平台
riku
2026-03-03 015f3aa4e2818f8e0c16acd0515d9c8eb4026de8
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
<!-- e:\VSprojects\fume-supervision-vue\src\components\monitor\RealTimeData.vue -->
<template>
  <el-card class="section" shadow="hover">
    <template #header>
      <div class="card-header">
        <span>设备实时数据</span>
      </div>
    </template>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-card class="realtime-data" shadow="hover">
          <template #header>
            <span>实时分钟数据</span>
          </template>
          <el-descriptions :column="1" v-if="currentDevice">
            <el-descriptions-item label="设备编号">{{
              currentDevice.deviceId
            }}</el-descriptions-item>
            <el-descriptions-item label="设备供应商">{{
              currentDevice.supplier
            }}</el-descriptions-item>
            <el-descriptions-item label="油烟浓度"
              >{{ currentDevice.油烟浓度 }} mg/m³</el-descriptions-item
            >
            <el-descriptions-item label="风机电流"
              >{{ currentDevice.风机电流 }} A</el-descriptions-item
            >
            <el-descriptions-item label="净化器电流"
              >{{ currentDevice.净化器电流 }} A</el-descriptions-item
            >
          </el-descriptions>
        </el-card>
      </el-col>
      <el-col :span="16">
        <el-card class="realtime-chart" shadow="hover">
          <template #header>
            <span>近一小时数据</span>
          </template>
          <div ref="hourlyChart" class="chart-container"></div>
        </el-card>
      </el-col>
    </el-row>
  </el-card>
</template>
 
<script>
import * as echarts from 'echarts'
 
export default {
  name: 'RealTimeData',
  props: {
    currentDevice: {
      type: Object,
      default: null,
    },
    hourlyData: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      hourlyChart: null,
    }
  },
  mounted() {
    this.initChart()
  },
  beforeUnmount() {
    if (this.hourlyChart) {
      this.hourlyChart.dispose()
    }
  },
  watch: {
    hourlyData() {
      this.updateChart()
    },
  },
  methods: {
    initChart() {
      this.hourlyChart = echarts.init(this.$refs.hourlyChart)
      this.updateChart()
 
      window.addEventListener('resize', () => {
        this.hourlyChart.resize()
      })
    },
    updateChart() {
      if (!this.hourlyChart) return
 
      const option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985',
            },
          },
        },
        legend: {
          data: ['油烟浓度', '风机电流', '净化器电流'],
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true,
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: this.hourlyData.map((item) => item.time),
        },
        yAxis: [
          {
            type: 'value',
            name: '油烟浓度 (mg/m³)',
            position: 'left',
          },
          {
            type: 'value',
            name: '电流 (A)',
            position: 'right',
          },
        ],
        series: [
          {
            name: '油烟浓度',
            type: 'line',
            data: this.hourlyData.map((item) => parseFloat(item.油烟浓度)),
            yAxisIndex: 0,
          },
          {
            name: '风机电流',
            type: 'line',
            data: this.hourlyData.map((item) => parseFloat(item.风机电流)),
            yAxisIndex: 1,
          },
          {
            name: '净化器电流',
            type: 'line',
            data: this.hourlyData.map((item) => parseFloat(item.净化器电流)),
            yAxisIndex: 1,
          },
        ],
      }
 
      this.hourlyChart.setOption(option)
    },
  },
}
</script>
 
<style scoped>
.section {
  margin-bottom: 20px;
}
 
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.chart-container {
  height: 300px;
  width: 100%;
}
</style>