DeviceDetailDrawer.vue
5.43 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
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
<template>
<BasicDrawer
v-bind="$attrs"
isDetail
@register="register"
destroyOnClose
@close="closeDrawer"
:title="drawerTitle"
width="80%"
>
<Tabs v-model:activeKey="activeKey" :size="size">
<TabPane key="1" tab="详情">
<Detail
ref="deviceDetailRef"
:deviceDetail="deviceDetail"
@open-gateway-device="handleOpenGatewayDevice"
/>
</TabPane>
<TabPane v-if="!isTransportType" key="modelOfMatter" tab="物模型数据">
<ModelOfMatter :deviceDetail="deviceDetail" />
</TabPane>
<!-- <TabPane key="2" tab="实时数据" v-if="deviceDetail?.deviceType !== 'GATEWAY'">
<RealTimeData :deviceDetail="deviceDetail" />
</TabPane>
<TabPane key="7" tab="历史数据" v-if="deviceDetail?.deviceType !== 'GATEWAY'">
<HistoryData :deviceDetail="deviceDetail" />
</TabPane> -->
<!-- <TabPane key="5" tab="命令下发" v-if="deviceDetail?.deviceType !== 'SENSOR'">
<CommandIssuance :deviceDetail="deviceDetail" />
</TabPane> -->
<TabPane v-if="!isTransportType" key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane>
<TabPane
key="4"
tab="子设备"
v-if="deviceDetail?.deviceType === 'GATEWAY' && !isTransportType"
>
<ChildDevice
:fromId="deviceDetail?.tbDeviceId"
@openTbDeviceDetail="handleOpenTbDeviceDetail"
/>
</TabPane>
<TabPane v-if="!isTransportType" key="7" tab="命令下发记录">
<CommandRecord :deviceDetail="deviceDetail" :fromId="deviceDetail?.tbDeviceId" />
</TabPane>
<!-- 网关设备并且场家是TBox -->
<TabPane
key="6"
tab="TBox"
v-if="
deviceDetail?.deviceType === 'GATEWAY' &&
deviceDetail?.brand == 'TBox' &&
!isTransportType
"
>
<TBoxDetail :deviceDetail="deviceDetail" />
</TabPane>
<!-- 网关设备并且是TBox -->
<TabPane v-if="!isTransportType" key="eventManage" tab="事件管理">
<EventManage :tbDeviceId="deviceDetail.tbDeviceId" />
</TabPane>
<TabPane v-if="!isTransportType" key="task" tab="任务">
<Task :tbDeviceId="deviceDetail.tbDeviceId" />
</TabPane>
<!-- <TabPane v-if="false" key="videoChannel" tab="视频通道">
<VideoChannel :deviceDetail="deviceDetail" :fromId="deviceDetail?.tbDeviceId" />
</TabPane> -->
</Tabs>
</BasicDrawer>
</template>
<script lang="ts">
import { defineComponent, ref, computed } from 'vue';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { Tabs } 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 TBoxDetail from '../tabs/TBoxDetail.vue';
import { CommandRecord } from '../tabs/commandRecord/index';
import { getDeviceDetail } from '/@/api/device/deviceManager';
// import HistoryData from '../tabs/HistoryData.vue';
import ModelOfMatter from '../tabs/ModelOfMatter.vue';
import EventManage from '../tabs/EventManage/index.vue';
import { DeviceRecord } from '/@/api/device/model/deviceModel';
import Task from '../tabs/Task.vue';
// import { VideoChannel } from '../tabs/VideoChannel/index';
export default defineComponent({
name: 'DeviceModal',
components: {
BasicDrawer,
Tabs,
TabPane: Tabs.TabPane,
Detail,
// RealTimeData,
Alarm,
ChildDevice,
TBoxDetail,
// HistoryData,
ModelOfMatter,
CommandRecord,
EventManage,
Task,
// VideoChannel,
},
emits: ['reload', 'register', 'openTbDeviceDetail', 'openGatewayDeviceDetail'],
setup(_props, { emit }) {
const activeKey = ref('1');
const size = ref('small');
const deviceDetailRef = ref();
const deviceDetail = ref<DeviceRecord>({} as unknown as DeviceRecord);
const tbDeviceId = ref('');
const isTransportType = ref<Boolean>(false); //获取产品是不是GB/T 28181
// 详情回显
const [register] = useDrawerInner(async (data) => {
const { id, transportType, deviceType } = data;
isTransportType.value =
transportType == 'GB/T28181' && deviceType == 'DIRECT_CONNECTION' ? true : false;
// 设备详情
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';
};
const handleOpenTbDeviceDetail = (data: { id: string; tbDeviceId: string }) => {
emit('openTbDeviceDetail', data);
};
const handleOpenGatewayDevice = (data: { gatewayId: string; tbDeviceId: string }) => {
emit('openGatewayDeviceDetail', { id: data.gatewayId });
};
const drawerTitle = computed(() => {
return deviceDetail.value?.alias || deviceDetail.value?.name;
});
return {
size,
activeKey,
register,
closeDrawer,
deviceDetail,
deviceDetailRef,
tbDeviceId,
handleOpenTbDeviceDetail,
handleOpenGatewayDevice,
isTransportType,
drawerTitle,
};
},
});
</script>