DeviceDetailDrawer.vue
2.25 KB
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
<template>
<BasicDrawer
v-bind="$attrs"
isDetail
@register="register"
:destroyOnClose="true"
@close="closeDrawer"
:title="deviceDetail.name"
width="78%"
>
<Tabs v-model:activeKey="activeKey" :size="size" type="card">
<TabPane key="1" tab="详情"
><Detail ref="deviceDetailRef" :deviceDetail="deviceDetail"
/></TabPane>
<TabPane key="2" tab="实时数据" v-if="deviceDetail?.deviceType !== 'GATEWAY'"
><RealTimeData :deviceDetail="deviceDetail"
/></TabPane>
<TabPane key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane>
<TabPane key="4" tab="子设备" v-if="deviceDetail?.deviceType === 'GATEWAY'"
><ChildDevice
/></TabPane>
</Tabs>
</BasicDrawer>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { Tabs, TabPane } from 'ant-design-vue';
import Detail from '../tabs/Detail.vue';
import RealTimeData from '../tabs/RealTimeData.vue';
import Alarm from '../tabs/Alarm.vue';
import ChildDevice from '../tabs/ChildDevice.vue';
import { getDeviceDetail } from '/@/api/device/deviceManager';
export default defineComponent({
name: 'DeviceModal',
components: {
BasicDrawer,
Tabs,
TabPane,
Detail,
RealTimeData,
Alarm,
ChildDevice,
},
emits: ['reload', 'register'],
setup() {
const activeKey = ref('1');
const size = ref('small');
const deviceDetailRef = ref();
const deviceDetail = ref<any>({});
const tbDeviceId = ref('');
// 详情回显
const [register] = useDrawerInner(async (data) => {
const { id } = data;
// 设备详情
const res = await getDeviceDetail(id);
deviceDetail.value = res;
const { latitude, longitude, address } = res.deviceInfo;
if (latitude) {
deviceDetailRef.value.initMap(longitude, latitude, address);
}
});
const closeDrawer = () => {
activeKey.value = '1';
};
return {
size,
activeKey,
register,
closeDrawer,
deviceDetail,
deviceDetailRef,
tbDeviceId,
};
},
});
</script>