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
| <!-- 空白页 -->
|
|
| <script setup>
| import { ref, onMounted } from 'vue'
| import * as echarts from 'echarts'
| import request from '@/utils/request'
|
| const energyData = ref([])
|
| // 获取能耗数据
| const loadEnergyData = async () => {
| try {
| const res = await request({
| url: '/deviceInteraction/energy/consumption/chartEnergy',
| method: 'post'
| })
| if (res.code === 200) {
| energyData.value = res.data.actual || [];
| updateEnergyChart()
| }
| } catch (error) {
| console.error('获取能耗数据失败:', error)
| }
| }
|
| const draw = (name, Option) => {
| var myChart = echarts.init(document.getElementById(name));
| myChart.setOption(Option);
| }
|
| const drawDay = (name, Option) => {
| Option.title.text = "能耗管理";
| draw(name, Option);
| }
|
| // 更新能耗图表
| const updateEnergyChart = () => {
| // 按日期排序并格式化日期
| const sortedData = [...energyData.value].sort((a, b) =>
| new Date(a.recordDate) - new Date(b.recordDate)
| ).map(item => {
| const date = new Date(item.recordDate);
| return {
| ...item,
| recordDate: `${date.getMonth() + 1}-${date.getDate().toString().padStart(2, '0')}`
| };
| });
|
| const energyoption = {
| title: {
| text: '能耗管理'
| },
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'cross',
| label: {
| backgroundColor: '#6a7985'
| }
| }
| },
| legend: {
| data: ['能耗值']
| },
| toolbox: {
| feature: {
| saveAsImage: {}
| }
| },
| grid: {
| left: '3%',
| right: '4%',
| bottom: '3%',
| containLabel: true
| },
| xAxis: [
| {
| type: 'category',
| boundaryGap: false,
| data: sortedData.map(item => item.recordDate)
| }
| ],
| yAxis: [
| {
| type: 'value'
| }
| ],
| series: [
| {
| name: '能耗值',
| type: 'line',
| areaStyle: {},
| label: {
| show: true,
| position: 'top'
| },
| data: sortedData.map(item => item.energyValue)
| }
| ]
| }
|
| drawDay('drawLineChart_day71', energyoption);
| }
|
| onMounted(() => {
| loadEnergyData()
| })
| </script>
| <script>
| export default {
| mounted() {
| const OptionDay={ // 绘制图表
| title: {
| text: '产量看板示例'
| },
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'cross',
| label: {
| backgroundColor: '#6a7985'
| }
| }
| },
| legend: {
| data: ['计划产量', '实际产量']
| },
| toolbox: {
| feature: {
| saveAsImage: {}
| }
| },
| grid: {
| left: '3%',
| right: '4%',
| bottom: '3%',
| containLabel: true
| },
| xAxis: [
| {
| type: 'category',
| boundaryGap: false,
| data: ['1-01', '1-02', '1-03', '1-04', '1-05',
| '1-06', '1-07', '1-08', '1-09', '1-10',
| '1-11', '1-12', '1-13', '1-14', '1-15',
| '1-16', '1-17', '1-18', '1-19', '1-20',
| '1-21', '1-22', '1-23', '1-24', '1-25',
| '1-26', '1-27', '1-28', '1-29', '1-30', '1-31']
| }
| ],
| yAxis: [
| {
| type: 'value'
| }
| ],
| series: [
| {
| name: '计划产量',
| type: 'line',
| areaStyle: {},
| label: {
| show: true,
| position: 'top'
| },
| data: [120, 132, 101, 134, 90, 230, 210,
| 120, 132, 101, 134, 90, 230, 210,
| 120, 132, 101, 134, 90, 230, 210,
| 120, 132, 101, 134, 90, 230, 210,
| 120, 132, 101]
| },
| {
| name: '实际产量',
| type: 'line',
| areaStyle: {},
| emphasis: {
| focus: 'series'
| },
| data: [100, 122, 101, 124, 90, 200, 180,
| 100, 122, 101, 124, 90, 200, 180,
| 100, 122, 101, 124, 90, 200, 180,
| 100, 122, 101, 124, 90, 200, 180,
| 100, 122, 101]
| }
| ]
|
| }
| this.drawDay('drawLineChart_day11',OptionDay, 1);
| // this.drawLineChart('drawLineChart_day11', 1);
| // this.drawLineChart('drawLineChart_day21', 1);
| // this.drawLineChart('drawLineChart_day31', 1);
| // this.drawLineChart('drawLineChart_day41', 1);
| // this.drawLineChart('drawLineChart_day51', 1);
| //this.drawLineChart('drawLineChart_week', 1);
| //this.drawBarchart('drawBarchart', 1);
| },
| methods: {
| draw(name, Option, data) {
| var myChart = echarts.init(document.getElementById(name));
| myChart.setOption(Option);
| },
| drawDay(name, Option, data) {
| Option.title.text="日看板";
| console.log(Option);
| this.draw(name, Option, data);
| },
| drawLineChart(name, Option, data) {
| console.log(name);
| console.log(data);
| var myChart = echarts.init(document.getElementById(name));
| myChart.setOption(Option);
| },
| drawBarchart(name, data) {
| var myChart = echarts.init(document.getElementById(name));
| myChart.setOption({ // 绘制图表
| title: {
| text: '总产量看板示例'
| },
| tooltip: {
| trigger: 'item'
| },
| legend: {
| top: '5%',
| left: 'center'
| },
| series: [
| {
| name: 'Access From',
| type: 'pie',
| radius: ['40%', '70%'],
| avoidLabelOverlap: false,
| label: {
| show: false,
| position: 'center'
| },
| emphasis: {
| label: {
| show: true,
| fontSize: 40,
| fontWeight: 'bold'
| }
| },
| labelLine: {
| show: false
| },
| data: [
| { value: 1000, name: '计划总片数' },
| { value: 900, name: '实际总片数' },
| { value: 10, name: '破损片数' }
| ]
| , label: {
| formatter: '{b}:{c}'
| }
| }
| ]
|
|
| });
| }
| }
| }
| </script>
|
| <template>
| <div>
| <div style="font-size: 30px;height: 70px;line-height: 70px;border: 1px solid #ccc;text-align: center;">
| JOOMO镜片制造中心驾驶舱
| </div>
| <div style="margin-left: 20px;">
| <el-button type="primary" @click="drawPieChart">标准品</el-button>
| <el-button type="primary" @click="drawPieChart">定制品</el-button>
| </div>
| <div style="width:100% ;height: 880px;">
| <div style="width:33.3% ;height: 100%;border: 1px solid #ccc;float: left;">
| <div id="drawLineChart_day11" style="height: 50%;width: 100%;border: 1px solid #ccc;">日单达成率-片数</div>
| <div id="drawLineChart_day21" style="height: 50%;width: 100%;border: 1px solid #ccc;">月单达成率-片数</div>
| </div>
| <div style="width:33.3% ;height: 100%;border: 1px solid #ccc;float: left;">
| <div id="drawLineChart_day31" style="height: 50%;width: 100%;border: 1px solid #ccc;">日单达成率-平方</div>
| <div id="drawLineChart_day41" style="height: 50%;width: 100%;border: 1px solid #ccc;">月单达成率-平方</div>
| </div>
| <div style="width:33.3% ;height: 100%;border: 1px solid #ccc;float: left;">
| <div id="drawLineChart_day51" style="height: 33.3%;width: 100%;border: 1px solid #ccc;">合格率-显示当天</div>
| <div id="drawLineChart_day61" style="height: 33.3%;width: 100%;border: 1px solid #ccc;">设备稼动率</div>
| <div id="drawLineChart_day71" style="height: 33.3%;width: 100%;border: 1px solid #ccc;">能耗管理-按天显示(手输)</div>
| </div>
| </div>
|
| <!-- <div style="width:33% ;height: 880px;border: 1px solid #ccc;">
| <div id="drawLineChart_day1" style="height: 300px;width: 25%;border: 1px solid #ccc;float: left;"></div>
| <div id="drawLineChart_day2" style="height: 300px;width: 25%;border: 1px solid #ccc;float: left;"></div>
| </div> -->
| </div>
| </template>
| <style scoped>
| .float{
| float: left;
| }
| .style{
| width: 600px;
| height: 400px;
| border: 1px solid #ccc;
| }
| .chart {
| height: 400px;
| }
| </style>
|
|