Commit ab71cfd74b2d6d3236c51ac68e1481de92517c50
1 parent
61ab426c
fix: DEFECT-1266 修复场景联动设备为TCP设备时选择服务未将服务命令保存
Showing
2 changed files
with
29 additions
and
12 deletions
@@ -607,9 +607,10 @@ export const actionSchema: FormSchema[] = [ | @@ -607,9 +607,10 @@ export const actionSchema: FormSchema[] = [ | ||
607 | span: 6, | 607 | span: 6, |
608 | }, | 608 | }, |
609 | componentProps: ({ formModel, formActionType }) => { | 609 | componentProps: ({ formModel, formActionType }) => { |
610 | - const { updateSchema } = formActionType; | 610 | + const { updateSchema, setFieldsValue } = formActionType; |
611 | const deviceProfileId = Reflect.get(formModel, 'deviceProfileId'); | 611 | const deviceProfileId = Reflect.get(formModel, 'deviceProfileId'); |
612 | const thingsModelId = Reflect.get(formModel, 'thingsModelId'); | 612 | const thingsModelId = Reflect.get(formModel, 'thingsModelId'); |
613 | + const transportType = Reflect.get(formModel, 'transportType'); | ||
613 | return { | 614 | return { |
614 | placeholder: '请选择服务', | 615 | placeholder: '请选择服务', |
615 | api: async (params: Recordable) => { | 616 | api: async (params: Recordable) => { |
@@ -640,12 +641,16 @@ export const actionSchema: FormSchema[] = [ | @@ -640,12 +641,16 @@ export const actionSchema: FormSchema[] = [ | ||
640 | onChange: (_, options: ModelOfMatterParams) => { | 641 | onChange: (_, options: ModelOfMatterParams) => { |
641 | if (options) { | 642 | if (options) { |
642 | // setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } }); | 643 | // setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } }); |
643 | - updateSchema({ | ||
644 | - field: 'serviceInputValue', | ||
645 | - componentProps: { | ||
646 | - inputData: options.functionJson.inputData, | ||
647 | - }, | ||
648 | - }); | 644 | + transportType === TransportTypeEnum.TCP |
645 | + ? setFieldsValue({ | ||
646 | + tcpServiceCommand: options.functionJson?.inputData?.[0]?.serviceCommand, | ||
647 | + }) | ||
648 | + : updateSchema({ | ||
649 | + field: 'serviceInputValue', | ||
650 | + componentProps: { | ||
651 | + inputData: options.functionJson.inputData, | ||
652 | + }, | ||
653 | + }); | ||
649 | } | 654 | } |
650 | }, | 655 | }, |
651 | }; | 656 | }; |
@@ -725,12 +730,22 @@ export const actionSchema: FormSchema[] = [ | @@ -725,12 +730,22 @@ export const actionSchema: FormSchema[] = [ | ||
725 | slot: 'clearAlarm', | 730 | slot: 'clearAlarm', |
726 | }, | 731 | }, |
727 | { | 732 | { |
733 | + field: 'tcpServiceCommand', | ||
734 | + component: 'Input', | ||
735 | + label: '服务命令', | ||
736 | + colProps: { span: 24 }, | ||
737 | + dynamicDisabled: true, | ||
738 | + show: ({ values }) => | ||
739 | + values['thingsModelId'] && values['transportType'] === TransportTypeEnum.TCP, | ||
740 | + }, | ||
741 | + { | ||
728 | field: 'serviceInputValue', | 742 | field: 'serviceInputValue', |
729 | component: 'ObjectModelValidateForm', | 743 | component: 'ObjectModelValidateForm', |
730 | label: '', | 744 | label: '', |
731 | changeEvent: 'update:value', | 745 | changeEvent: 'update:value', |
732 | valueField: 'value', | 746 | valueField: 'value', |
733 | - show: ({ values }) => values['thingsModelId'], | 747 | + show: ({ values }) => |
748 | + values['thingsModelId'] && values['transportType'] !== TransportTypeEnum.TCP, | ||
734 | colProps: { | 749 | colProps: { |
735 | span: 24, | 750 | span: 24, |
736 | }, | 751 | }, |
@@ -94,7 +94,7 @@ | @@ -94,7 +94,7 @@ | ||
94 | 94 | ||
95 | <script lang="ts"> | 95 | <script lang="ts"> |
96 | import { defineComponent } from 'vue'; | 96 | import { defineComponent } from 'vue'; |
97 | - import { isNumber } from '/@/utils/is'; | 97 | + import { isNumber, isObject, isString } from '/@/utils/is'; |
98 | import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | 98 | import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; |
99 | export default defineComponent({ | 99 | export default defineComponent({ |
100 | components: { | 100 | components: { |
@@ -272,12 +272,11 @@ | @@ -272,12 +272,11 @@ | ||
272 | const isTCPTransportType = value.transportType === TransportTypeEnum.TCP; | 272 | const isTCPTransportType = value.transportType === TransportTypeEnum.TCP; |
273 | const doContext = unref(jsonInstance)?.get() || {}; | 273 | const doContext = unref(jsonInstance)?.get() || {}; |
274 | const serviceInputValue = Reflect.get(value, 'serviceInputValue'); | 274 | const serviceInputValue = Reflect.get(value, 'serviceInputValue'); |
275 | - | ||
276 | return { | 275 | return { |
277 | ...value, | 276 | ...value, |
278 | ...(Number(value.commandType) === CommandTypeEnum.CUSTOM | 277 | ...(Number(value.commandType) === CommandTypeEnum.CUSTOM |
279 | ? { doContext: isTCPTransportType ? value.doContext : doContext } | 278 | ? { doContext: isTCPTransportType ? value.doContext : doContext } |
280 | - : { doContext: serviceInputValue }), | 279 | + : { doContext: isTCPTransportType ? value.tcpServiceCommand : serviceInputValue }), |
281 | clearRule, | 280 | clearRule, |
282 | }; | 281 | }; |
283 | }; | 282 | }; |
@@ -291,7 +290,10 @@ | @@ -291,7 +290,10 @@ | ||
291 | ? { commandType: String(fieldsValue.commandType) } | 290 | ? { commandType: String(fieldsValue.commandType) } |
292 | : {}), | 291 | : {}), |
293 | ...(commandType === CommandTypeEnum.SERVICE | 292 | ...(commandType === CommandTypeEnum.SERVICE |
294 | - ? { serviceInputValue: doContext.params || {} } | 293 | + ? { |
294 | + serviceInputValue: isObject(doContext.params) ? doContext.params : {}, | ||
295 | + tcpServiceCommand: isString(doContext.params) ? doContext.params : '', | ||
296 | + } | ||
295 | : { doContext: doContext.params }), | 297 | : { doContext: doContext.params }), |
296 | }); | 298 | }); |
297 | }; | 299 | }; |