1
|
<template>
|
1
|
<template>
|
2
|
- <div class="wrapper">
|
2
|
+ <div class="wrapper123">
|
3
|
<div ref="wrapRef" :style="{ height, width }"> </div>
|
3
|
<div ref="wrapRef" :style="{ height, width }"> </div>
|
4
|
<div class="right-wrap">
|
4
|
<div class="right-wrap">
|
5
|
<BasicTable @register="registerTable" @rowClick="deviceRowClick">
|
5
|
<BasicTable @register="registerTable" @rowClick="deviceRowClick">
|
|
@@ -25,16 +25,16 @@ |
|
@@ -25,16 +25,16 @@ |
25
|
</template>
|
25
|
</template>
|
26
|
</BasicTable>
|
26
|
</BasicTable>
|
27
|
</div>
|
27
|
</div>
|
28
|
- <a-button type="primary" @click="openHistoryModal">打开弹窗</a-button>
|
|
|
29
|
<BasicModal
|
28
|
<BasicModal
|
30
|
@register="registerModal"
|
29
|
@register="registerModal"
|
31
|
title="历史数据"
|
30
|
title="历史数据"
|
32
|
width="70%"
|
31
|
width="70%"
|
33
|
:footer="null"
|
32
|
:footer="null"
|
34
|
@cancel="cancelHistoryModal"
|
33
|
@cancel="cancelHistoryModal"
|
|
|
34
|
+ :canFullscreen="false"
|
35
|
>
|
35
|
>
|
36
|
<BasicForm @register="registerForm" />
|
36
|
<BasicForm @register="registerForm" />
|
37
|
- <div ref="chartRef" :style="{ height: '300px', width }"></div>
|
37
|
+ <div ref="chartRef" :style="{ height: '400px', width }"></div>
|
38
|
</BasicModal>
|
38
|
</BasicModal>
|
39
|
</div>
|
39
|
</div>
|
40
|
</template>
|
40
|
</template>
|
|
@@ -50,10 +50,9 @@ |
|
@@ -50,10 +50,9 @@ |
50
|
import { useModal, BasicModal } from '/@/components/Modal';
|
50
|
import { useModal, BasicModal } from '/@/components/Modal';
|
51
|
import { BasicForm, useForm } from '/@/components/Form';
|
51
|
import { BasicForm, useForm } from '/@/components/Form';
|
52
|
import { schemas } from './config.data';
|
52
|
import { schemas } from './config.data';
|
53
|
-
|
|
|
54
|
import { useECharts } from '/@/hooks/web/useECharts';
|
53
|
import { useECharts } from '/@/hooks/web/useECharts';
|
55
|
- import { getLineData } from './data';
|
|
|
56
|
-
|
54
|
+ import { getDeviceHistoryInfo } from '/@/api/alarm/position';
|
|
|
55
|
+ import moment from 'moment';
|
57
|
export default defineComponent({
|
56
|
export default defineComponent({
|
58
|
name: 'BaiduMap',
|
57
|
name: 'BaiduMap',
|
59
|
components: {
|
58
|
components: {
|
|
@@ -75,7 +74,7 @@ |
|
@@ -75,7 +74,7 @@ |
75
|
setup() {
|
74
|
setup() {
|
76
|
const wrapRef = ref<HTMLDivElement | null>(null);
|
75
|
const wrapRef = ref<HTMLDivElement | null>(null);
|
77
|
const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
|
76
|
const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
|
78
|
-
|
77
|
+ const entityId = ref('');
|
79
|
async function initMap() {
|
78
|
async function initMap() {
|
80
|
await toPromise();
|
79
|
await toPromise();
|
81
|
await nextTick();
|
80
|
await nextTick();
|
|
@@ -101,6 +100,7 @@ |
|
@@ -101,6 +100,7 @@ |
101
|
});
|
100
|
});
|
102
|
// 点击表格某一行触发
|
101
|
// 点击表格某一行触发
|
103
|
const deviceRowClick = (record) => {
|
102
|
const deviceRowClick = (record) => {
|
|
|
103
|
+ entityId.value = record.tbDeviceId;
|
104
|
const BMap = (window as any).BMap;
|
104
|
const BMap = (window as any).BMap;
|
105
|
const wrapEl = unref(wrapRef);
|
105
|
const wrapEl = unref(wrapRef);
|
106
|
const map = new BMap.Map(wrapEl);
|
106
|
const map = new BMap.Map(wrapEl);
|
|
@@ -117,28 +117,29 @@ |
|
@@ -117,28 +117,29 @@ |
117
|
// 创建信息窗口对象
|
117
|
// 创建信息窗口对象
|
118
|
let infoWindow = new BMap.InfoWindow(
|
118
|
let infoWindow = new BMap.InfoWindow(
|
119
|
`
|
119
|
`
|
120
|
- <div style="display:flex;justify-content:space-between; margin:20px 0px;">
|
|
|
121
|
- <div style="font-size:16px;font-weight:bold">${name}</div>
|
|
|
122
|
- ${
|
|
|
123
|
- deviceState === 'INACTIVE'
|
|
|
124
|
- ? '<div style="display:flex;align-items:center"><img style="width:15px;height:15px" src="/src/assets/images/djh.png">待激活</div>'
|
|
|
125
|
- : deviceState === 'ONLINE'
|
|
|
126
|
- ? '<div style="display:flex;align-items:center"><img style="width:15px;height:15px" src="/src/assets/images/online1.png">在线</div>'
|
|
|
127
|
- : '<div style="display:flex;align-items:center"><img style="width:15px;height:15px" src="/src/assets/images/lx1.png">离线</div>'
|
|
|
128
|
- }
|
|
|
129
|
- </div>
|
|
|
130
|
- <div>所属组织:${organizationDTO.name}</div>
|
|
|
131
|
- <div style="margin-top:6px;">接入协议:${deviceProfile.transportType}</div>
|
|
|
132
|
- <div style="margin-top:6px;">设备位置:${address}</div>
|
|
|
133
|
- <div style="margin-top:6px;">下线时间:${updateTime}</div>
|
|
|
134
|
- <div style="display:flex;justify-content:space-between; margin-top:10px">
|
|
|
135
|
- <button style="color:#fff;background-color:#409eff;padding:4px; border-radius:4px;">设备信息</button>
|
|
|
136
|
- <button style="color:#fff;background-color:#409eff;padding:4px; border-radius:4px;">报警记录</button>
|
|
|
137
|
- <button onclick="historyClick()"style="color:#fff;background-color:#409eff;padding:4px; border-radius:4px;">历史数据</button>
|
|
|
138
|
- </div>
|
|
|
139
|
- `,
|
120
|
+ <div style="display:flex;justify-content:space-between; margin:20px 0px;">
|
|
|
121
|
+ <div style="font-size:16px;font-weight:bold">${name}</div>
|
|
|
122
|
+ ${
|
|
|
123
|
+ deviceState === 'INACTIVE'
|
|
|
124
|
+ ? '<div style="display:flex;align-items:center"><img style="width:15px;height:15px" src="/src/assets/images/djh.png">待激活</div>'
|
|
|
125
|
+ : deviceState === 'ONLINE'
|
|
|
126
|
+ ? '<div style="display:flex;align-items:center"><img style="width:15px;height:15px" src="/src/assets/images/online1.png">在线</div>'
|
|
|
127
|
+ : '<div style="display:flex;align-items:center"><img style="width:15px;height:15px" src="/src/assets/images/lx1.png">离线</div>'
|
|
|
128
|
+ }
|
|
|
129
|
+ </div>
|
|
|
130
|
+ <div>所属组织:${organizationDTO.name}</div>
|
|
|
131
|
+ <div style="margin-top:6px;">接入协议:${deviceProfile.transportType}</div>
|
|
|
132
|
+ <div style="margin-top:6px;">设备位置:${address}</div>
|
|
|
133
|
+ <div style="margin-top:6px;">下线时间:${updateTime}</div>
|
|
|
134
|
+ <div style="display:flex;justify-content:space-between; margin-top:10px">
|
|
|
135
|
+ <button style="color:#fff;background-color:#409eff;padding:4px; border-radius:4px;">设备信息</button>
|
|
|
136
|
+ <button style="color:#fff;background-color:#409eff;padding:4px; border-radius:4px;">报警记录</button>
|
|
|
137
|
+ <button onclick="openHistoryModal()" style="color:#fff;background-color:#409eff;padding:4px; border-radius:4px;">历史数据</button>
|
|
|
138
|
+ </div>
|
|
|
139
|
+ `,
|
140
|
options
|
140
|
options
|
141
|
);
|
141
|
);
|
|
|
142
|
+
|
142
|
map.openInfoWindow(infoWindow, map.getCenter());
|
143
|
map.openInfoWindow(infoWindow, map.getCenter());
|
143
|
let preMarker = null;
|
144
|
let preMarker = null;
|
144
|
const rivet =
|
145
|
const rivet =
|
|
@@ -170,35 +171,168 @@ |
|
@@ -170,35 +171,168 @@ |
170
|
};
|
171
|
};
|
171
|
|
172
|
|
172
|
const [registerModal, { openModal }] = useModal();
|
173
|
const [registerModal, { openModal }] = useModal();
|
173
|
- const [registerForm, { resetFields }] = useForm({
|
174
|
+ const [registerForm, { resetFields, getFieldsValue, validate }] = useForm({
|
174
|
labelWidth: 120,
|
175
|
labelWidth: 120,
|
175
|
schemas,
|
176
|
schemas,
|
|
|
177
|
+ async submitFunc() {
|
|
|
178
|
+ await validate();
|
|
|
179
|
+ let { endTs, interval, agg } = getFieldsValue();
|
|
|
180
|
+ if (!endTs) return;
|
|
|
181
|
+ const startTs = Date.now() - endTs;
|
|
|
182
|
+ endTs = Date.now();
|
|
|
183
|
+ console.log(startTs, endTs);
|
|
|
184
|
+ const res = await getDeviceHistoryInfo({
|
|
|
185
|
+ entityId: entityId.value,
|
|
|
186
|
+ keys: 'co,co2',
|
|
|
187
|
+ interval,
|
|
|
188
|
+ startTs,
|
|
|
189
|
+ endTs,
|
|
|
190
|
+ agg,
|
|
|
191
|
+ });
|
|
|
192
|
+ const dateArray: { key: string; time: string }[] = [];
|
|
|
193
|
+ const valueArray: { key: string; value: string }[] = [];
|
|
|
194
|
+ for (const key in res) {
|
|
|
195
|
+ for (const item1 of res[key]) {
|
|
|
196
|
+ let { ts, value } = item1;
|
|
|
197
|
+ const time = moment(ts).format('YYYY-MM-DD');
|
|
|
198
|
+ dateArray.push({
|
|
|
199
|
+ key,
|
|
|
200
|
+ time,
|
|
|
201
|
+ });
|
|
|
202
|
+ valueArray.push({
|
|
|
203
|
+ key,
|
|
|
204
|
+ value,
|
|
|
205
|
+ });
|
|
|
206
|
+ }
|
|
|
207
|
+ }
|
|
|
208
|
+ console.log(dateArray, valueArray);
|
|
|
209
|
+ const keys = ['co', 'co2'];
|
|
|
210
|
+ const series: any = keys.map((item) => {
|
|
|
211
|
+ return {
|
|
|
212
|
+ name: item,
|
|
|
213
|
+ type: 'line',
|
|
|
214
|
+ smooth: true,
|
|
|
215
|
+ showAllSymbol: 'auto',
|
|
|
216
|
+ symbol: 'emptyCircle',
|
|
|
217
|
+ symbolSize: 15,
|
|
|
218
|
+ data: valueArray.filter((item1) => item1.key === item).map((item1) => item1.value),
|
|
|
219
|
+ };
|
|
|
220
|
+ });
|
|
|
221
|
+ setOptions({
|
|
|
222
|
+ tooltip: {
|
|
|
223
|
+ trigger: 'axis',
|
|
|
224
|
+ axisPointer: {
|
|
|
225
|
+ lineStyle: {
|
|
|
226
|
+ width: 1,
|
|
|
227
|
+ color: '#019680',
|
|
|
228
|
+ },
|
|
|
229
|
+ },
|
|
|
230
|
+ },
|
|
|
231
|
+ xAxis: {
|
|
|
232
|
+ type: 'category',
|
|
|
233
|
+ boundaryGap: false,
|
|
|
234
|
+ data: dateArray.map((item) => item.time),
|
|
|
235
|
+ splitLine: {
|
|
|
236
|
+ show: true,
|
|
|
237
|
+ lineStyle: {
|
|
|
238
|
+ width: 1,
|
|
|
239
|
+ type: 'solid',
|
|
|
240
|
+ color: 'rgba(226,226,226,0.5)',
|
|
|
241
|
+ },
|
|
|
242
|
+ },
|
|
|
243
|
+ axisTick: {
|
|
|
244
|
+ show: false,
|
|
|
245
|
+ },
|
|
|
246
|
+ },
|
|
|
247
|
+ yAxis: [
|
|
|
248
|
+ {
|
|
|
249
|
+ type: 'value',
|
|
|
250
|
+ max: 1000,
|
|
|
251
|
+ splitNumber: 4,
|
|
|
252
|
+ axisTick: {
|
|
|
253
|
+ show: false,
|
|
|
254
|
+ },
|
|
|
255
|
+ splitArea: {
|
|
|
256
|
+ show: true,
|
|
|
257
|
+ areaStyle: {
|
|
|
258
|
+ color: ['rgba(255,255,255,0.2)', 'rgba(226,226,226,0.2)'],
|
|
|
259
|
+ },
|
|
|
260
|
+ },
|
|
|
261
|
+ },
|
|
|
262
|
+ ],
|
|
|
263
|
+ grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
|
|
|
264
|
+ series,
|
|
|
265
|
+ });
|
|
|
266
|
+ },
|
176
|
});
|
267
|
});
|
177
|
|
268
|
|
178
|
const chartRef = ref<HTMLDivElement | null>(null);
|
269
|
const chartRef = ref<HTMLDivElement | null>(null);
|
179
|
- const { setOptions, echarts } = useECharts(chartRef as Ref<HTMLDivElement>);
|
|
|
180
|
- const { lineData, category } = getLineData;
|
|
|
181
|
- const openHistoryModal = () => {
|
|
|
182
|
- openModal(true);
|
270
|
+ const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
|
|
|
271
|
+
|
|
|
272
|
+ const openHistoryModal = async () => {
|
|
|
273
|
+ const startTs = Date.now() - 86400000;
|
|
|
274
|
+ const endTs = Date.now();
|
|
|
275
|
+ console.log(startTs, endTs);
|
|
|
276
|
+ const res = await getDeviceHistoryInfo({
|
|
|
277
|
+ entityId: entityId.value,
|
|
|
278
|
+ keys: 'co,co2',
|
|
|
279
|
+ startTs,
|
|
|
280
|
+ endTs,
|
|
|
281
|
+ });
|
|
|
282
|
+ const dateArray: { key: string; time: string }[] = [];
|
|
|
283
|
+ const valueArray: { key: string; value: string }[] = [];
|
|
|
284
|
+ for (const key in res) {
|
|
|
285
|
+ for (const item1 of res[key]) {
|
|
|
286
|
+ let { ts, value } = item1;
|
|
|
287
|
+ const time = moment(ts).format('YYYY-MM-DD HH:mm:ss');
|
|
|
288
|
+ dateArray.push({
|
|
|
289
|
+ key,
|
|
|
290
|
+ time,
|
|
|
291
|
+ });
|
|
|
292
|
+ valueArray.push({
|
|
|
293
|
+ key,
|
|
|
294
|
+ value,
|
|
|
295
|
+ });
|
|
|
296
|
+ }
|
|
|
297
|
+ }
|
|
|
298
|
+
|
|
|
299
|
+ const keys = ['co', 'co2'];
|
|
|
300
|
+ const series: any = keys.map((item) => {
|
|
|
301
|
+ return {
|
|
|
302
|
+ smooth: true,
|
|
|
303
|
+ data: valueArray.filter((item1) => item1.key === item).map((item1) => item1.value),
|
|
|
304
|
+ type: 'line',
|
|
|
305
|
+ name: item,
|
|
|
306
|
+ itemStyle: {
|
|
|
307
|
+ color: '#5ab1ef',
|
|
|
308
|
+ },
|
|
|
309
|
+ };
|
|
|
310
|
+ });
|
183
|
setOptions({
|
311
|
setOptions({
|
184
|
- backgroundColor: '#0f375f',
|
|
|
185
|
tooltip: {
|
312
|
tooltip: {
|
186
|
trigger: 'axis',
|
313
|
trigger: 'axis',
|
187
|
axisPointer: {
|
314
|
axisPointer: {
|
188
|
- type: 'shadow',
|
|
|
189
|
- label: {
|
|
|
190
|
- show: true,
|
|
|
191
|
- backgroundColor: '#333',
|
315
|
+ lineStyle: {
|
|
|
316
|
+ width: 1,
|
|
|
317
|
+ color: '#019680',
|
192
|
},
|
318
|
},
|
193
|
},
|
319
|
},
|
194
|
},
|
320
|
},
|
195
|
xAxis: {
|
321
|
xAxis: {
|
196
|
- data: category,
|
|
|
197
|
- axisLine: {
|
322
|
+ type: 'category',
|
|
|
323
|
+ boundaryGap: false,
|
|
|
324
|
+ data: dateArray.map((item) => item.time),
|
|
|
325
|
+ splitLine: {
|
|
|
326
|
+ show: true,
|
198
|
lineStyle: {
|
327
|
lineStyle: {
|
199
|
- color: '#ccc',
|
328
|
+ width: 1,
|
|
|
329
|
+ type: 'solid',
|
|
|
330
|
+ color: 'rgba(226,226,226,0.5)',
|
200
|
},
|
331
|
},
|
201
|
},
|
332
|
},
|
|
|
333
|
+ axisTick: {
|
|
|
334
|
+ show: false,
|
|
|
335
|
+ },
|
202
|
},
|
336
|
},
|
203
|
yAxis: {
|
337
|
yAxis: {
|
204
|
splitLine: { show: false },
|
338
|
splitLine: { show: false },
|
|
@@ -208,41 +342,18 @@ |
|
@@ -208,41 +342,18 @@ |
208
|
},
|
342
|
},
|
209
|
},
|
343
|
},
|
210
|
},
|
344
|
},
|
211
|
- series: [
|
|
|
212
|
- {
|
|
|
213
|
- name: '当日数据',
|
|
|
214
|
- type: 'line',
|
|
|
215
|
- smooth: true,
|
|
|
216
|
- showAllSymbol: 'auto',
|
|
|
217
|
- symbol: 'emptyCircle',
|
|
|
218
|
- symbolSize: 15,
|
|
|
219
|
- data: lineData,
|
|
|
220
|
- },
|
|
|
221
|
- {
|
|
|
222
|
- name: 'line',
|
|
|
223
|
- type: 'bar',
|
|
|
224
|
- barGap: '-100%',
|
|
|
225
|
- barWidth: 10,
|
|
|
226
|
- itemStyle: {
|
|
|
227
|
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
228
|
- { offset: 0, color: 'rgba(20,200,212,0.5)' },
|
|
|
229
|
- { offset: 0.2, color: 'rgba(20,200,212,0.2)' },
|
|
|
230
|
- { offset: 1, color: 'rgba(20,200,212,0)' },
|
|
|
231
|
- ]),
|
|
|
232
|
- },
|
|
|
233
|
- z: -12,
|
|
|
234
|
- data: lineData,
|
|
|
235
|
- },
|
|
|
236
|
- ],
|
345
|
+ grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
|
|
|
346
|
+ series,
|
237
|
});
|
347
|
});
|
|
|
348
|
+ openModal(true);
|
238
|
};
|
349
|
};
|
239
|
const cancelHistoryModal = () => {
|
350
|
const cancelHistoryModal = () => {
|
240
|
resetFields();
|
351
|
resetFields();
|
241
|
};
|
352
|
};
|
242
|
onMounted(() => {
|
353
|
onMounted(() => {
|
243
|
initMap();
|
354
|
initMap();
|
|
|
355
|
+ (window as any).openHistoryModal = openHistoryModal;
|
244
|
});
|
356
|
});
|
245
|
-
|
|
|
246
|
return {
|
357
|
return {
|
247
|
wrapRef,
|
358
|
wrapRef,
|
248
|
registerTable,
|
359
|
registerTable,
|
|
@@ -251,7 +362,6 @@ |
|
@@ -251,7 +362,6 @@ |
251
|
registerModal,
|
362
|
registerModal,
|
252
|
registerForm,
|
363
|
registerForm,
|
253
|
chartRef,
|
364
|
chartRef,
|
254
|
- openHistoryModal,
|
|
|
255
|
cancelHistoryModal,
|
365
|
cancelHistoryModal,
|
256
|
};
|
366
|
};
|
257
|
},
|
367
|
},
|