Commit 21e79e8c57406f47f0790ca117216860d0461aab
1 parent
4b5ae137
wip: product profile detail update to description
Showing
15 changed files
with
552 additions
and
13 deletions
@@ -5,7 +5,13 @@ | @@ -5,7 +5,13 @@ | ||
5 | "public/resource/tinymce/langs" | 5 | "public/resource/tinymce/langs" |
6 | ], | 6 | ], |
7 | "cSpell.words": [ | 7 | "cSpell.words": [ |
8 | + "COAP", | ||
9 | + "edrx", | ||
10 | + "EFENTO", | ||
8 | "inited", | 11 | "inited", |
12 | + "MQTT", | ||
13 | + "PROTOBUF", | ||
14 | + "SNMP", | ||
9 | "unref", | 15 | "unref", |
10 | "VITE" | 16 | "VITE" |
11 | ] | 17 | ] |
@@ -3,6 +3,7 @@ import { | @@ -3,6 +3,7 @@ import { | ||
3 | TDeviceConfigParams, | 3 | TDeviceConfigParams, |
4 | IDeviceConfigAddOrEditModel, | 4 | IDeviceConfigAddOrEditModel, |
5 | ProfileRecord, | 5 | ProfileRecord, |
6 | + RuleChainRecord, | ||
6 | } from '/@/api/device/model/deviceConfigModel'; | 7 | } from '/@/api/device/model/deviceConfigModel'; |
7 | import { PaginationResult } from '/#/axios'; | 8 | import { PaginationResult } from '/#/axios'; |
8 | 9 | ||
@@ -36,7 +37,7 @@ export const deviceConfigGetDetail = (id: string) => { | @@ -36,7 +37,7 @@ export const deviceConfigGetDetail = (id: string) => { | ||
36 | * 获取规则链 | 37 | * 获取规则链 |
37 | */ | 38 | */ |
38 | export const deviceConfigGetRuleChain = () => { | 39 | export const deviceConfigGetRuleChain = () => { |
39 | - return defHttp.get({ | 40 | + return defHttp.get<RuleChainRecord[]>({ |
40 | url: EDeviceConfigApi.DEVICE_CONFIG_GET_RULECHAIN, | 41 | url: EDeviceConfigApi.DEVICE_CONFIG_GET_RULECHAIN, |
41 | }); | 42 | }); |
42 | }; | 43 | }; |
@@ -241,3 +241,21 @@ export interface ProfileRecord { | @@ -241,3 +241,21 @@ export interface ProfileRecord { | ||
241 | 241 | ||
242 | checked?: boolean; | 242 | checked?: boolean; |
243 | } | 243 | } |
244 | + | ||
245 | +export interface IDRecord { | ||
246 | + entityType: string; | ||
247 | + id: string; | ||
248 | +} | ||
249 | + | ||
250 | +export interface RuleChainRecord { | ||
251 | + id: IDRecord; | ||
252 | + createdTime: number; | ||
253 | + additionalInfo?: any; | ||
254 | + tenantId: IDRecord; | ||
255 | + name: string; | ||
256 | + type: string; | ||
257 | + firstRuleNodeId: IDRecord; | ||
258 | + root: boolean; | ||
259 | + debugMode: boolean; | ||
260 | + configuration?: any; | ||
261 | +} |
@@ -54,8 +54,33 @@ export interface Configuration { | @@ -54,8 +54,33 @@ export interface Configuration { | ||
54 | type: string; | 54 | type: string; |
55 | } | 55 | } |
56 | 56 | ||
57 | +export interface TransportPayloadTypeConfiguration { | ||
58 | + transportPayloadType: string; | ||
59 | + deviceTelemetryProtoSchema: string; | ||
60 | + deviceAttributesProtoSchema: string; | ||
61 | + deviceRpcRequestProtoSchema: string; | ||
62 | + deviceRpcResponseProtoSchema: string; | ||
63 | + enableCompatibilityWithJsonPayloadFormat: boolean; | ||
64 | + useJsonPayloadFormatForDefaultDownlinkTopics: boolean; | ||
65 | +} | ||
66 | + | ||
67 | +export interface ClientSettings { | ||
68 | + edrxCycle: string; | ||
69 | + pagingTransmissionWindow: string; | ||
70 | + powerMode: string; | ||
71 | + psmActivityTimer: number; | ||
72 | +} | ||
73 | + | ||
57 | export interface TransportConfiguration { | 74 | export interface TransportConfiguration { |
58 | type: string; | 75 | type: string; |
76 | + deviceTelemetryTopic: string; | ||
77 | + deviceAttributesTopic: string; | ||
78 | + transportPayloadTypeConfiguration: TransportPayloadTypeConfiguration; | ||
79 | + clientSettings: ClientSettings; | ||
80 | + coapDeviceTypeConfiguration: { | ||
81 | + coapDeviceType: string; | ||
82 | + transportPayloadTypeConfiguration: TransportPayloadTypeConfiguration; | ||
83 | + }; | ||
59 | } | 84 | } |
60 | 85 | ||
61 | export interface ProvisionConfiguration { | 86 | export interface ProvisionConfiguration { |
@@ -85,6 +110,7 @@ export interface DeviceRecord { | @@ -85,6 +110,7 @@ export interface DeviceRecord { | ||
85 | image: string; | 110 | image: string; |
86 | type: string; | 111 | type: string; |
87 | default: boolean; | 112 | default: boolean; |
113 | + defaultRuleChainId: string; | ||
88 | } | 114 | } |
89 | 115 | ||
90 | export interface DeviceModelOfMatterAttrs { | 116 | export interface DeviceModelOfMatterAttrs { |
1 | +import { ProfileRecord } from '../device/model/deviceConfigModel'; | ||
1 | import { | 2 | import { |
2 | CreateOtaPackageParams, | 3 | CreateOtaPackageParams, |
3 | DefaultDeviceProfileInfo, | 4 | DefaultDeviceProfileInfo, |
@@ -129,7 +130,7 @@ export const getDeviceProfileInfos = (params: GetDeviceProfileInfosParams) => { | @@ -129,7 +130,7 @@ export const getDeviceProfileInfos = (params: GetDeviceProfileInfosParams) => { | ||
129 | }; | 130 | }; |
130 | 131 | ||
131 | export const getDeviceProfileInfoById = (id: string) => { | 132 | export const getDeviceProfileInfoById = (id: string) => { |
132 | - return defHttp.get<DeviceProfileRecord>( | 133 | + return defHttp.get<ProfileRecord>( |
133 | { | 134 | { |
134 | url: `${Api.GET_DEVICE_PROFILE_INFO_BY_ID}/${id}`, | 135 | url: `${Api.GET_DEVICE_PROFILE_INFO_BY_ID}/${id}`, |
135 | }, | 136 | }, |
src/components/Widget/AuthDropDown.vue
0 → 100644
src/components/Widget/AuthIcon.vue
0 → 100644
@@ -3,14 +3,13 @@ | @@ -3,14 +3,13 @@ | ||
3 | <Tabs v-model:activeKey="activeKey" @change="handlePanelChange"> | 3 | <Tabs v-model:activeKey="activeKey" @change="handlePanelChange"> |
4 | <Tabs.TabPane key="product" tab="产品"> | 4 | <Tabs.TabPane key="product" tab="产品"> |
5 | <div class="relative"> | 5 | <div class="relative"> |
6 | - <DeviceConfigurationStep :ifShowBtn="false" ref="DevConStRef" /> | ||
7 | - <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> | 6 | + <ProductDescription ref="DevConStRef" :record="record" /> |
8 | </div> | 7 | </div> |
9 | </Tabs.TabPane> | 8 | </Tabs.TabPane> |
10 | <Tabs.TabPane key="transport" tab="传输配置"> | 9 | <Tabs.TabPane key="transport" tab="传输配置"> |
11 | - <div class="relative"> | ||
12 | - <TransportConfigurationStep :ifShowBtn="false" ref="TransConStRef" /> | ||
13 | - <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> | 10 | + <div> |
11 | + <TransportDescription :record="record" /> | ||
12 | + <!-- <TransportConfigurationStep :ifShowBtn="false" ref="TransConStRef" /> --> | ||
14 | </div> | 13 | </div> |
15 | </Tabs.TabPane> | 14 | </Tabs.TabPane> |
16 | <Tabs.TabPane key="topic" tab="Topic"> | 15 | <Tabs.TabPane key="topic" tab="Topic"> |
@@ -25,13 +24,14 @@ | @@ -25,13 +24,14 @@ | ||
25 | <script lang="ts" setup> | 24 | <script lang="ts" setup> |
26 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 25 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
27 | import { Tabs } from 'ant-design-vue'; | 26 | import { Tabs } from 'ant-design-vue'; |
28 | - import DeviceConfigurationStep from './step/DeviceConfigurationStep.vue'; | ||
29 | import TransportConfigurationStep from './step/TransportConfigurationStep.vue'; | 27 | import TransportConfigurationStep from './step/TransportConfigurationStep.vue'; |
30 | import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue'; | 28 | import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue'; |
31 | import { nextTick, ref, unref } from 'vue'; | 29 | import { nextTick, ref, unref } from 'vue'; |
32 | import { deviceConfigGetDetail } from '/@/api/device/deviceConfigApi'; | 30 | import { deviceConfigGetDetail } from '/@/api/device/deviceConfigApi'; |
33 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 31 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
34 | import TopicPanel from './step/TopicPanel.vue'; | 32 | import TopicPanel from './step/TopicPanel.vue'; |
33 | + import ProductDescription from './components/ProductDescription.vue'; | ||
34 | + import { TransportDescription } from './components/TransportDescript'; | ||
35 | 35 | ||
36 | defineEmits(['register']); | 36 | defineEmits(['register']); |
37 | 37 | ||
@@ -41,12 +41,11 @@ | @@ -41,12 +41,11 @@ | ||
41 | 41 | ||
42 | const record = ref<DeviceRecord>({} as unknown as DeviceRecord); | 42 | const record = ref<DeviceRecord>({} as unknown as DeviceRecord); |
43 | 43 | ||
44 | - const DevConStRef = ref<InstanceType<typeof DeviceConfigurationStep>>(); | 44 | + const DevConStRef = ref<InstanceType<typeof ProductDescription>>(); |
45 | const TransConStRef = ref<InstanceType<typeof TransportConfigurationStep>>(); | 45 | const TransConStRef = ref<InstanceType<typeof TransportConfigurationStep>>(); |
46 | - // const PhysicalModManRef = ref<InstanceType<typeof PhysicalModelManagementStep>>(); | ||
47 | 46 | ||
48 | - const setDeviceConfFormData = async (res: Recordable) => { | ||
49 | - unref(DevConStRef)?.setFormData(res); | 47 | + const setDeviceConfFormData = async () => { |
48 | + unref(DevConStRef)?.renderProductInfo(); | ||
50 | }; | 49 | }; |
51 | const setTransConfFormData = async (res: Recordable) => { | 50 | const setTransConfFormData = async (res: Recordable) => { |
52 | await nextTick(); | 51 | await nextTick(); |
@@ -57,7 +56,7 @@ | @@ -57,7 +56,7 @@ | ||
57 | activeKey.value = 'product'; | 56 | activeKey.value = 'product'; |
58 | record.value = data.record; | 57 | record.value = data.record; |
59 | record.value = await deviceConfigGetDetail(data.record.id); | 58 | record.value = await deviceConfigGetDetail(data.record.id); |
60 | - setDeviceConfFormData(unref(record)); | 59 | + setDeviceConfFormData(); |
61 | }); | 60 | }); |
62 | 61 | ||
63 | const handlePanelChange = (activeKey: ActiveKey) => { | 62 | const handlePanelChange = (activeKey: ActiveKey) => { |
1 | +<script lang="ts" setup> | ||
2 | + import { Spin, Image } from 'ant-design-vue'; | ||
3 | + import { ref, unref, h } from 'vue'; | ||
4 | + import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi'; | ||
5 | + import { RuleChainRecord } from '/@/api/device/model/deviceConfigModel'; | ||
6 | + import { DeviceRecord } from '/@/api/device/model/deviceModel'; | ||
7 | + import { findDictItemByCode } from '/@/api/system/dict'; | ||
8 | + import { SysDictItemResult } from '/@/api/system/model/dictModel'; | ||
9 | + import { Description, useDescription } from '/@/components/Description'; | ||
10 | + import { to } from '/@/utils/to'; | ||
11 | + import productDefaultImage from '/@/assets/icons/product-default.svg'; | ||
12 | + | ||
13 | + const loading = ref(false); | ||
14 | + | ||
15 | + const props = defineProps<{ | ||
16 | + record: DeviceRecord; | ||
17 | + }>(); | ||
18 | + | ||
19 | + const data = ref<DeviceRecord>({} as unknown as DeviceRecord); | ||
20 | + | ||
21 | + const [register, { setDescProps }] = useDescription({ | ||
22 | + layout: 'vertical', | ||
23 | + column: 2, | ||
24 | + schema: [ | ||
25 | + { | ||
26 | + field: 'image', | ||
27 | + label: '图片', | ||
28 | + span: 2, | ||
29 | + render: (val) => { | ||
30 | + return h(Image, { src: val || productDefaultImage, height: 200 }); | ||
31 | + }, | ||
32 | + }, | ||
33 | + { | ||
34 | + field: 'deviceType', | ||
35 | + label: '设备类型', | ||
36 | + }, | ||
37 | + { | ||
38 | + field: 'name', | ||
39 | + label: '产品名称', | ||
40 | + }, | ||
41 | + { | ||
42 | + field: 'ruleChain', | ||
43 | + label: '规则链', | ||
44 | + }, | ||
45 | + { | ||
46 | + field: 'queueName', | ||
47 | + label: '处理队列', | ||
48 | + }, | ||
49 | + { | ||
50 | + field: 'description', | ||
51 | + label: '描述', | ||
52 | + render(val) { | ||
53 | + return h('div', { class: 'min-h-6' }, val); | ||
54 | + }, | ||
55 | + }, | ||
56 | + ], | ||
57 | + }); | ||
58 | + | ||
59 | + const findDeviceType = async (deviceType: string) => { | ||
60 | + const [error, data] = await to<SysDictItemResult[]>( | ||
61 | + findDictItemByCode({ dictCode: 'device_type' }) | ||
62 | + ); | ||
63 | + if (!error) { | ||
64 | + const record = data.find((item) => item.itemValue === deviceType); | ||
65 | + return { deviceType: record?.itemText }; | ||
66 | + } | ||
67 | + return {}; | ||
68 | + }; | ||
69 | + | ||
70 | + const findHandleQueue = async (defaultQueueName: string) => { | ||
71 | + const [error, data] = await to<SysDictItemResult[]>( | ||
72 | + findDictItemByCode({ dictCode: 'queen_execute_sequence' }) | ||
73 | + ); | ||
74 | + if (!error) { | ||
75 | + const record = data.find((item) => item.itemValue === defaultQueueName); | ||
76 | + return { queueName: record?.itemText }; | ||
77 | + } | ||
78 | + return {}; | ||
79 | + }; | ||
80 | + | ||
81 | + const findRuleChain = async (ruleChain: string) => { | ||
82 | + const [error, data] = await to<RuleChainRecord[]>(deviceConfigGetRuleChain()); | ||
83 | + if (!error) { | ||
84 | + const record = data.find((item) => item.id.id === ruleChain); | ||
85 | + return { ruleChain: record?.name }; | ||
86 | + } | ||
87 | + return {}; | ||
88 | + }; | ||
89 | + | ||
90 | + const renderProductInfo = async () => { | ||
91 | + try { | ||
92 | + data.value = {} as unknown as DeviceRecord; | ||
93 | + loading.value = true; | ||
94 | + const { defaultRuleChainId, deviceType, defaultQueueName } = props.record; | ||
95 | + data.value = props.record; | ||
96 | + const values = await Promise.all([ | ||
97 | + findDeviceType(deviceType), | ||
98 | + findHandleQueue(defaultQueueName), | ||
99 | + findRuleChain(defaultRuleChainId), | ||
100 | + ]); | ||
101 | + const value = values.reduce((prev, next) => ({ ...prev, ...next }), {}); | ||
102 | + data.value = Object.assign(unref(data), value); | ||
103 | + setDescProps({ data: unref(data) }); | ||
104 | + } catch (error) { | ||
105 | + throw error; | ||
106 | + } finally { | ||
107 | + loading.value = false; | ||
108 | + } | ||
109 | + }; | ||
110 | + | ||
111 | + defineExpose({ | ||
112 | + renderProductInfo, | ||
113 | + }); | ||
114 | +</script> | ||
115 | + | ||
116 | +<template> | ||
117 | + <Spin :spinning="loading"> | ||
118 | + <Description class="product-description" @register="register" /> | ||
119 | + </Spin> | ||
120 | +</template> | ||
121 | + | ||
122 | +<style lang="less" scoped> | ||
123 | + .product-description:deep(.ant-image-img) { | ||
124 | + height: 200px !important; | ||
125 | + } | ||
126 | +</style> |
1 | +<script lang="ts" setup> | ||
2 | + import { DeviceRecord } from '/@/api/device/model/deviceModel'; | ||
3 | + import { useDescription, Description } from '/@/components/Description'; | ||
4 | + import { Input } from 'ant-design-vue'; | ||
5 | + import { h } from 'vue'; | ||
6 | + import { COAPDeviceTypeEnum, PowerModeNameEnum, TransportPayloadTypeEnum } from './const'; | ||
7 | + | ||
8 | + type TransportConfiguration = DeviceRecord['profileData']['transportConfiguration']; | ||
9 | + const props = defineProps<{ | ||
10 | + record: TransportConfiguration; | ||
11 | + }>(); | ||
12 | + | ||
13 | + const showProtoSchema = (data: TransportConfiguration) => { | ||
14 | + return ( | ||
15 | + data.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration.transportPayloadType === | ||
16 | + TransportPayloadTypeEnum.PROTOBUF && | ||
17 | + data.coapDeviceTypeConfiguration.coapDeviceType === COAPDeviceTypeEnum.DEFAULT | ||
18 | + ); | ||
19 | + }; | ||
20 | + | ||
21 | + const showPowerModeIsPSM = (data: TransportConfiguration) => { | ||
22 | + return data.clientSettings.powerMode === PowerModeNameEnum.PSM; | ||
23 | + }; | ||
24 | + | ||
25 | + const showPowerModeIsEDRX = (data: TransportConfiguration) => { | ||
26 | + return data.clientSettings.powerMode === PowerModeNameEnum.E_DRX; | ||
27 | + }; | ||
28 | + | ||
29 | + const [register] = useDescription({ | ||
30 | + layout: 'vertical', | ||
31 | + column: 2, | ||
32 | + data: props.record, | ||
33 | + schema: [ | ||
34 | + { | ||
35 | + field: 'type', | ||
36 | + label: '接入协议', | ||
37 | + }, | ||
38 | + { | ||
39 | + field: 'coapDeviceType', | ||
40 | + label: 'COAP设备类型', | ||
41 | + render: (_, data: TransportConfiguration) => | ||
42 | + data.coapDeviceTypeConfiguration.coapDeviceType, | ||
43 | + }, | ||
44 | + { | ||
45 | + field: 'coapDeviceType', | ||
46 | + label: 'COAP设备消息Payload', | ||
47 | + render: (_, data: TransportConfiguration) => | ||
48 | + data.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration.transportPayloadType, | ||
49 | + }, | ||
50 | + { | ||
51 | + field: 'powerMode', | ||
52 | + label: '节能模式', | ||
53 | + render: (_, data: TransportConfiguration) => | ||
54 | + PowerModeNameEnum[data.clientSettings.powerMode], | ||
55 | + }, | ||
56 | + { | ||
57 | + field: 'psmActivityTimer', | ||
58 | + label: 'PSM活动计时器', | ||
59 | + show: showPowerModeIsPSM, | ||
60 | + render: (_, data: TransportConfiguration) => data.clientSettings.psmActivityTimer, | ||
61 | + }, | ||
62 | + { | ||
63 | + field: 'edrxCycle', | ||
64 | + label: 'eDRX循环', | ||
65 | + show: showPowerModeIsEDRX, | ||
66 | + render: (_, data: TransportConfiguration) => data.clientSettings.edrxCycle, | ||
67 | + }, | ||
68 | + { | ||
69 | + field: 'edrxCycleTime', | ||
70 | + label: 'eDRX循环时间单位', | ||
71 | + show: showPowerModeIsEDRX, | ||
72 | + render: () => '秒', | ||
73 | + }, | ||
74 | + { | ||
75 | + field: 'pagingTransmissionWindow', | ||
76 | + label: '寻呼传输窗口', | ||
77 | + show: showPowerModeIsEDRX, | ||
78 | + render: (_, data: TransportConfiguration) => data.clientSettings.pagingTransmissionWindow, | ||
79 | + }, | ||
80 | + { | ||
81 | + field: 'pagingTransmissionWindowTime', | ||
82 | + label: '寻呼传输窗口时间单位', | ||
83 | + show: showPowerModeIsEDRX, | ||
84 | + render: () => '秒', | ||
85 | + }, | ||
86 | + { | ||
87 | + field: 'unit', | ||
88 | + label: '时间单位', | ||
89 | + show: showPowerModeIsPSM, | ||
90 | + render: () => '秒', | ||
91 | + }, | ||
92 | + { | ||
93 | + field: 'deviceTelemetryProtoSchema', | ||
94 | + label: '遥测数据 proto schema', | ||
95 | + span: 2, | ||
96 | + show: showProtoSchema, | ||
97 | + render(_, data: TransportConfiguration) { | ||
98 | + return h(Input.TextArea, { | ||
99 | + autoSize: true, | ||
100 | + value: | ||
101 | + data.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration | ||
102 | + .deviceTelemetryProtoSchema, | ||
103 | + }); | ||
104 | + }, | ||
105 | + }, | ||
106 | + { | ||
107 | + field: 'deviceAttributesProtoSchema', | ||
108 | + label: 'Attributes proto schema', | ||
109 | + span: 2, | ||
110 | + show: showProtoSchema, | ||
111 | + render(_, data: TransportConfiguration) { | ||
112 | + return h(Input.TextArea, { | ||
113 | + autoSize: true, | ||
114 | + value: | ||
115 | + data.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration | ||
116 | + .deviceAttributesProtoSchema, | ||
117 | + }); | ||
118 | + }, | ||
119 | + }, | ||
120 | + { | ||
121 | + field: 'deviceRpcRequestProtoSchema', | ||
122 | + label: 'RPC 请求 proto schema', | ||
123 | + span: 2, | ||
124 | + show: showProtoSchema, | ||
125 | + render(_, data: TransportConfiguration) { | ||
126 | + return h(Input.TextArea, { | ||
127 | + autoSize: true, | ||
128 | + value: | ||
129 | + data.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration | ||
130 | + .deviceRpcRequestProtoSchema, | ||
131 | + }); | ||
132 | + }, | ||
133 | + }, | ||
134 | + { | ||
135 | + field: 'deviceRpcResponseProtoSchema', | ||
136 | + label: 'RPC 响应 proto schema', | ||
137 | + span: 2, | ||
138 | + show: showProtoSchema, | ||
139 | + render(_, data: TransportConfiguration) { | ||
140 | + return h(Input.TextArea, { | ||
141 | + autoSize: true, | ||
142 | + value: | ||
143 | + data.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration | ||
144 | + .deviceRpcResponseProtoSchema, | ||
145 | + }); | ||
146 | + }, | ||
147 | + }, | ||
148 | + ], | ||
149 | + }); | ||
150 | +</script> | ||
151 | + | ||
152 | +<template> | ||
153 | + <Description @register="register" /> | ||
154 | +</template> |
1 | +<script lang="ts" setup> | ||
2 | + import { DeviceRecord } from '/@/api/device/model/deviceModel'; | ||
3 | + import { useDescription, Description } from '/@/components/Description'; | ||
4 | + | ||
5 | + const props = defineProps<{ | ||
6 | + record: DeviceRecord['profileData']['transportConfiguration']; | ||
7 | + }>(); | ||
8 | + | ||
9 | + const [register] = useDescription({ | ||
10 | + layout: 'vertical', | ||
11 | + column: 2, | ||
12 | + schema: [ | ||
13 | + { | ||
14 | + field: 'type', | ||
15 | + label: '接入协议', | ||
16 | + }, | ||
17 | + ], | ||
18 | + data: props.record, | ||
19 | + }); | ||
20 | +</script> | ||
21 | + | ||
22 | +<template> | ||
23 | + <Description @register="register" /> | ||
24 | +</template> |
1 | +<script lang="ts" setup> | ||
2 | + import { DeviceRecord } from '/@/api/device/model/deviceModel'; | ||
3 | + import { useDescription, Description } from '/@/components/Description'; | ||
4 | + import { Input } from 'ant-design-vue'; | ||
5 | + import { h } from 'vue'; | ||
6 | + import { TransportPayloadTypeEnum } from './const'; | ||
7 | + | ||
8 | + type TransportConfiguration = DeviceRecord['profileData']['transportConfiguration']; | ||
9 | + const props = defineProps<{ | ||
10 | + record: TransportConfiguration; | ||
11 | + }>(); | ||
12 | + | ||
13 | + const [register] = useDescription({ | ||
14 | + layout: 'vertical', | ||
15 | + column: 2, | ||
16 | + data: props.record, | ||
17 | + schema: [ | ||
18 | + { | ||
19 | + field: 'type', | ||
20 | + label: '接入协议', | ||
21 | + span: 2, | ||
22 | + }, | ||
23 | + { | ||
24 | + field: 'deviceTelemetryTopic', | ||
25 | + label: '遥测数据主题筛选器', | ||
26 | + }, | ||
27 | + { | ||
28 | + field: 'deviceAttributesTopic', | ||
29 | + label: '属性主题过滤器', | ||
30 | + }, | ||
31 | + { | ||
32 | + field: 'transportPayloadType', | ||
33 | + label: 'MQTT设备Payload', | ||
34 | + render(_, data: TransportConfiguration) { | ||
35 | + return data.transportPayloadTypeConfiguration.transportPayloadType; | ||
36 | + }, | ||
37 | + }, | ||
38 | + { | ||
39 | + field: 'enableCompatibilityWithJsonPayloadFormat', | ||
40 | + label: '启用与其他有效负载格式的兼容性', | ||
41 | + render(_, data: TransportConfiguration) { | ||
42 | + return data.transportPayloadTypeConfiguration.enableCompatibilityWithJsonPayloadFormat | ||
43 | + ? '启用' | ||
44 | + : '关闭'; | ||
45 | + }, | ||
46 | + }, | ||
47 | + { | ||
48 | + field: 'deviceTelemetryProtoSchema', | ||
49 | + label: '遥测数据 proto schema', | ||
50 | + span: 2, | ||
51 | + show: (data: TransportConfiguration) => | ||
52 | + data.transportPayloadTypeConfiguration.transportPayloadType === | ||
53 | + TransportPayloadTypeEnum.PROTOBUF, | ||
54 | + render(_, data: TransportConfiguration) { | ||
55 | + return h(Input.TextArea, { | ||
56 | + autoSize: true, | ||
57 | + value: data.transportPayloadTypeConfiguration.deviceTelemetryProtoSchema, | ||
58 | + }); | ||
59 | + }, | ||
60 | + }, | ||
61 | + { | ||
62 | + field: 'deviceAttributesProtoSchema', | ||
63 | + label: 'Attributes proto schema', | ||
64 | + span: 2, | ||
65 | + show: (data: TransportConfiguration) => | ||
66 | + data.transportPayloadTypeConfiguration.transportPayloadType === | ||
67 | + TransportPayloadTypeEnum.PROTOBUF, | ||
68 | + render(_, data: TransportConfiguration) { | ||
69 | + return h(Input.TextArea, { | ||
70 | + autoSize: true, | ||
71 | + value: data.transportPayloadTypeConfiguration.deviceAttributesProtoSchema, | ||
72 | + }); | ||
73 | + }, | ||
74 | + }, | ||
75 | + { | ||
76 | + field: 'deviceRpcRequestProtoSchema', | ||
77 | + label: 'RPC 请求 proto schema', | ||
78 | + span: 2, | ||
79 | + show: (data: TransportConfiguration) => | ||
80 | + data.transportPayloadTypeConfiguration.transportPayloadType === | ||
81 | + TransportPayloadTypeEnum.PROTOBUF, | ||
82 | + render(_, data: TransportConfiguration) { | ||
83 | + return h(Input.TextArea, { | ||
84 | + autoSize: true, | ||
85 | + value: data.transportPayloadTypeConfiguration.deviceRpcRequestProtoSchema, | ||
86 | + }); | ||
87 | + }, | ||
88 | + }, | ||
89 | + { | ||
90 | + field: 'deviceRpcResponseProtoSchema', | ||
91 | + label: 'RPC 响应 proto schema', | ||
92 | + span: 2, | ||
93 | + show: (data: TransportConfiguration) => | ||
94 | + data.transportPayloadTypeConfiguration.transportPayloadType === | ||
95 | + TransportPayloadTypeEnum.PROTOBUF, | ||
96 | + render(_, data: TransportConfiguration) { | ||
97 | + return h(Input.TextArea, { | ||
98 | + autoSize: true, | ||
99 | + value: data.transportPayloadTypeConfiguration.deviceRpcResponseProtoSchema, | ||
100 | + }); | ||
101 | + }, | ||
102 | + }, | ||
103 | + ], | ||
104 | + }); | ||
105 | +</script> | ||
106 | + | ||
107 | +<template> | ||
108 | + <Description @register="register" /> | ||
109 | +</template> |
1 | +<script lang="ts" setup> | ||
2 | + import { computed } from 'vue'; | ||
3 | + import COAPDescription from './COAPDescription.vue'; | ||
4 | + import { TransportTypeEnum } from './const'; | ||
5 | + import DefaultConfiguration from './DefaultConfiguration.vue'; | ||
6 | + import MQTTConfiguration from './MQTTConfiguration.vue'; | ||
7 | + import { DeviceRecord } from '/@/api/device/model/deviceModel'; | ||
8 | + | ||
9 | + const props = defineProps<{ | ||
10 | + record: DeviceRecord; | ||
11 | + }>(); | ||
12 | + | ||
13 | + const getTransportInfo = computed(() => { | ||
14 | + const { record } = props; | ||
15 | + return record.profileData.transportConfiguration; | ||
16 | + }); | ||
17 | +</script> | ||
18 | + | ||
19 | +<template> | ||
20 | + <section> | ||
21 | + <DefaultConfiguration | ||
22 | + :record="getTransportInfo" | ||
23 | + v-if="getTransportInfo.type === TransportTypeEnum.DEFAULT" | ||
24 | + /> | ||
25 | + | ||
26 | + <MQTTConfiguration | ||
27 | + :record="getTransportInfo" | ||
28 | + v-if="getTransportInfo.type === TransportTypeEnum.MQTT" | ||
29 | + /> | ||
30 | + | ||
31 | + <COAPDescription | ||
32 | + :record="getTransportInfo" | ||
33 | + v-if="getTransportInfo.type === TransportTypeEnum.COAP" | ||
34 | + /> | ||
35 | + </section> | ||
36 | +</template> |
1 | +export enum TransportTypeEnum { | ||
2 | + DEFAULT = 'DEFAULT', | ||
3 | + MQTT = 'MQTT', | ||
4 | + COAP = 'COAP', | ||
5 | + LWM2M = 'LWM2M', | ||
6 | + SNMP = 'SNMP', | ||
7 | +} | ||
8 | + | ||
9 | +export enum TransportPayloadTypeEnum { | ||
10 | + PROTOBUF = 'PROTOBUF', | ||
11 | + JSON = 'JSON', | ||
12 | +} | ||
13 | + | ||
14 | +export enum COAPDeviceTypeEnum { | ||
15 | + DEFAULT = 'DEFAULT', | ||
16 | + EFENTO = 'EFENTO', | ||
17 | +} | ||
18 | + | ||
19 | +export enum COAPDeviceTypeNameEnum { | ||
20 | + DEFAULT = '默认', | ||
21 | + EFENTO = 'Efento NB-IoT', | ||
22 | +} | ||
23 | + | ||
24 | +export enum PowerModeNameEnum { | ||
25 | + PSM = 'Power Saving Mode (PSM)', | ||
26 | + DRX = 'Discontinuous Reception (DRX)', | ||
27 | + E_DRX = 'Extended Discontinuous Reception (eDRX)', | ||
28 | +} | ||
29 | + | ||
30 | +export enum TimeUnitEnum { | ||
31 | + MILLISECONDS = 'milliseconds', | ||
32 | + SECOND = 'second', | ||
33 | + MINUTE = 'minute', | ||
34 | + HOUR = 'hour', | ||
35 | +} |
1 | +export { default as TransportDescription } from './TransportDescription.vue'; |