Commit 6c8c663414182a343191f74b4a167bf751ef7d89
1 parent
bdebc0d0
fix: only gateway subdevice disabled service and events panel on model of matter
Showing
3 changed files
with
27 additions
and
26 deletions
@@ -24,16 +24,8 @@ | @@ -24,16 +24,8 @@ | ||
24 | :size="size" | 24 | :size="size" |
25 | > | 25 | > |
26 | <TabPane :key="FunctionType.PROPERTIES" tab="属性" /> | 26 | <TabPane :key="FunctionType.PROPERTIES" tab="属性" /> |
27 | - <TabPane | ||
28 | - :key="FunctionType.SERVICE" | ||
29 | - :disabled="$props.record.transportType === 'TCP'" | ||
30 | - tab="服务" | ||
31 | - /> | ||
32 | - <TabPane | ||
33 | - :key="FunctionType.EVENTS" | ||
34 | - tab="事件" | ||
35 | - :disabled="$props.record.transportType === 'TCP'" | ||
36 | - /> | 27 | + <TabPane :key="FunctionType.SERVICE" :disabled="isTCPGatewaySubDevice" tab="服务" /> |
28 | + <TabPane :key="FunctionType.EVENTS" tab="事件" :disabled="isTCPGatewaySubDevice" /> | ||
37 | </Tabs> | 29 | </Tabs> |
38 | <Attribute v-if="activeKey === FunctionType.PROPERTIES" ref="AttrRef" /> | 30 | <Attribute v-if="activeKey === FunctionType.PROPERTIES" ref="AttrRef" /> |
39 | <Service | 31 | <Service |
@@ -51,7 +43,7 @@ | @@ -51,7 +43,7 @@ | ||
51 | </div> | 43 | </div> |
52 | </template> | 44 | </template> |
53 | <script lang="ts" setup> | 45 | <script lang="ts" setup> |
54 | - import { ref, unref, nextTick } from 'vue'; | 46 | + import { ref, unref, nextTick, computed } from 'vue'; |
55 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 47 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
56 | import { Tabs, TabPane, Typography, TypographyParagraph } from 'ant-design-vue'; | 48 | import { Tabs, TabPane, Typography, TypographyParagraph } from 'ant-design-vue'; |
57 | import Attribute from './cpns/Attribute.vue'; | 49 | import Attribute from './cpns/Attribute.vue'; |
@@ -59,7 +51,7 @@ | @@ -59,7 +51,7 @@ | ||
59 | import Events from './cpns/Events.vue'; | 51 | import Events from './cpns/Events.vue'; |
60 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | 52 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; |
61 | import { createModel, updateModel } from '/@/api/device/modelOfMatter'; | 53 | import { createModel, updateModel } from '/@/api/device/modelOfMatter'; |
62 | - import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 54 | + import { DeviceRecord, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; |
63 | import { useMessage } from '/@/hooks/web/useMessage'; | 55 | import { useMessage } from '/@/hooks/web/useMessage'; |
64 | import { OpenModelMode, OpenModelOfMatterModelParams } from './types/index'; | 56 | import { OpenModelMode, OpenModelOfMatterModelParams } from './types/index'; |
65 | import { FunctionType } from './cpns/config'; | 57 | import { FunctionType } from './cpns/config'; |
@@ -70,6 +62,12 @@ | @@ -70,6 +62,12 @@ | ||
70 | record: DeviceRecord; | 62 | record: DeviceRecord; |
71 | }>(); | 63 | }>(); |
72 | 64 | ||
65 | + const isTCPGatewaySubDevice = computed(() => { | ||
66 | + const { record } = props; | ||
67 | + const { deviceType, transportType } = record; | ||
68 | + return deviceType === DeviceTypeEnum.SENSOR && transportType === 'TCP'; | ||
69 | + }); | ||
70 | + | ||
73 | const blockContent = `属性一般是设备的运行状态,如当前温度等;服务是设备可被调用的方法,支持定义参数,如执行某项任务;事件则是设备上报的 | 71 | const blockContent = `属性一般是设备的运行状态,如当前温度等;服务是设备可被调用的方法,支持定义参数,如执行某项任务;事件则是设备上报的 |
74 | 通知,如告警,需要被及时处理。`; | 72 | 通知,如告警,需要被及时处理。`; |
75 | const activeKey = ref<FunctionType>(FunctionType.PROPERTIES); | 73 | const activeKey = ref<FunctionType>(FunctionType.PROPERTIES); |
@@ -155,6 +153,7 @@ | @@ -155,6 +153,7 @@ | ||
155 | closeModal(); | 153 | closeModal(); |
156 | emit('success'); | 154 | emit('success'); |
157 | } catch (error) { | 155 | } catch (error) { |
156 | + throw Error(error); | ||
158 | } finally { | 157 | } finally { |
159 | setModalProps({ loading: false, okButtonProps: { loading: false } }); | 158 | setModalProps({ loading: false, okButtonProps: { loading: false } }); |
160 | } | 159 | } |
@@ -28,7 +28,10 @@ | @@ -28,7 +28,10 @@ | ||
28 | //回显数据 | 28 | //回显数据 |
29 | const setFormData = (record: ModelOfMatterParams) => { | 29 | const setFormData = (record: ModelOfMatterParams) => { |
30 | const { functionJson = {}, functionName, identifier, remark, callType } = record; | 30 | const { functionJson = {}, functionName, identifier, remark, callType } = record; |
31 | - const { inputData, outputData, serviceCommand } = functionJson; | 31 | + const { inputData = [], outputData } = functionJson; |
32 | + const { serviceCommand } = | ||
33 | + (inputData.at(0) as unknown as { serviceCommand: string }) || | ||
34 | + ({} as { serviceCommand: string }); | ||
32 | const value = { | 35 | const value = { |
33 | functionName, | 36 | functionName, |
34 | identifier, | 37 | identifier, |
@@ -48,8 +51,8 @@ | @@ -48,8 +51,8 @@ | ||
48 | functionName, | 51 | functionName, |
49 | remark, | 52 | remark, |
50 | identifier, | 53 | identifier, |
51 | - inputData: _inputData, | ||
52 | - outputData: _outputData, | 54 | + inputData: _inputData = [], |
55 | + outputData: _outputData = [], | ||
53 | serviceCommand, | 56 | serviceCommand, |
54 | callType, | 57 | callType, |
55 | } = _values; | 58 | } = _values; |
@@ -71,7 +74,7 @@ | @@ -71,7 +74,7 @@ | ||
71 | functionJson: { | 74 | functionJson: { |
72 | inputData, | 75 | inputData, |
73 | outputData, | 76 | outputData, |
74 | - serviceCommand, | 77 | + ...(serviceCommand ? { inputData: [{ serviceCommand }] } : {}), |
75 | }, | 78 | }, |
76 | } as ModelOfMatterParams; | 79 | } as ModelOfMatterParams; |
77 | 80 |
@@ -113,6 +113,15 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | @@ -113,6 +113,15 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | ||
113 | }, | 113 | }, |
114 | }, | 114 | }, |
115 | { | 115 | { |
116 | + field: FormField.SERVICE_COMMAND, | ||
117 | + label: '输入参数', | ||
118 | + component: 'Input', | ||
119 | + ifShow: tcpDeviceFlag, | ||
120 | + componentProps: { | ||
121 | + placeholder: '请输入ASCII或HEX服务命令', | ||
122 | + }, | ||
123 | + }, | ||
124 | + { | ||
116 | field: FormField.INPUT_PARAM, | 125 | field: FormField.INPUT_PARAM, |
117 | label: '输入参数', | 126 | label: '输入参数', |
118 | component: 'StructForm', | 127 | component: 'StructForm', |
@@ -127,19 +136,9 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | @@ -127,19 +136,9 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | ||
127 | component: 'StructForm', | 136 | component: 'StructForm', |
128 | valueField: 'value', | 137 | valueField: 'value', |
129 | changeEvent: 'update:value', | 138 | changeEvent: 'update:value', |
130 | - ifShow: !tcpDeviceFlag, | ||
131 | colProps: { span: 24 }, | 139 | colProps: { span: 24 }, |
132 | }, | 140 | }, |
133 | { | 141 | { |
134 | - field: FormField.SERVICE_COMMAND, | ||
135 | - label: '服务命令', | ||
136 | - component: 'Input', | ||
137 | - ifShow: tcpDeviceFlag, | ||
138 | - componentProps: { | ||
139 | - placeholder: '请输入服务命令', | ||
140 | - }, | ||
141 | - }, | ||
142 | - { | ||
143 | field: FormField.REFARK, | 142 | field: FormField.REFARK, |
144 | label: '备注', | 143 | label: '备注', |
145 | component: 'InputTextArea', | 144 | component: 'InputTextArea', |