DeviceProfileDrawer.vue
2.51 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
<template>
<BasicDrawer v-bind="$attrs" title="产品详情" @register="register" width="60%">
<Tabs :animated="true" v-model:activeKey="activeKey" @change="handlePanelChange">
<TabPane key="product" tab="产品">
<div class="relative">
<DeviceConfigurationStep :ifShowBtn="false" ref="DevConStRef" />
<div class="absolute w-full h-full top-0 cursor-not-allowed"></div>
</div>
</TabPane>
<TabPane key="transport" tab="传输配置">
<div class="relative">
<TransportConfigurationStep :ifShowBtn="false" ref="TransConStRef" />
<div class="absolute w-full h-full top-0 cursor-not-allowed"></div>
</div>
</TabPane>
<TabPane key="modelOfMatter" tab="物模型管理">
<PhysicalModelManagementStep :record="record" />
</TabPane>
</Tabs>
</BasicDrawer>
</template>
<script lang="ts" setup>
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { Tabs, TabPane } from 'ant-design-vue';
import DeviceConfigurationStep from './step/DeviceConfigurationStep.vue';
import TransportConfigurationStep from './step/TransportConfigurationStep.vue';
import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue';
import { ref, unref } from 'vue';
import { deviceConfigGetDetail } from '/@/api/device/deviceConfigApi';
import { DeviceRecord } from '/@/api/device/model/deviceModel';
defineEmits(['register']);
type ActiveKey = 'product' | 'transport' | 'modelOfMatter';
const activeKey = ref<ActiveKey>('modelOfMatter');
const record = ref<DeviceRecord>({} as unknown as DeviceRecord);
const DevConStRef = ref<InstanceType<typeof DeviceConfigurationStep>>();
const TransConStRef = ref<InstanceType<typeof TransportConfigurationStep>>();
// const PhysicalModManRef = ref<InstanceType<typeof PhysicalModelManagementStep>>();
const setDeviceConfFormData = async (res: Recordable) => {
unref(DevConStRef)?.setFormData(res);
};
const setTransConfFormData = async (res: Recordable) => {
unref(TransConStRef)?.setFormData(res);
};
const [register, {}] = useDrawerInner(async (data: { record: DeviceRecord }) => {
activeKey.value = 'product';
record.value = data.record;
record.value = await deviceConfigGetDetail(data.record.id);
setDeviceConfFormData(unref(record));
});
const handlePanelChange = (activeKey: ActiveKey) => {
if (activeKey === 'transport') setTransConfFormData(unref(record));
};
</script>
<style lang="less" scope></style>