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 | 607 | span: 6, |
| 608 | 608 | }, |
| 609 | 609 | componentProps: ({ formModel, formActionType }) => { |
| 610 | - const { updateSchema } = formActionType; | |
| 610 | + const { updateSchema, setFieldsValue } = formActionType; | |
| 611 | 611 | const deviceProfileId = Reflect.get(formModel, 'deviceProfileId'); |
| 612 | 612 | const thingsModelId = Reflect.get(formModel, 'thingsModelId'); |
| 613 | + const transportType = Reflect.get(formModel, 'transportType'); | |
| 613 | 614 | return { |
| 614 | 615 | placeholder: '请选择服务', |
| 615 | 616 | api: async (params: Recordable) => { |
| ... | ... | @@ -640,12 +641,16 @@ export const actionSchema: FormSchema[] = [ |
| 640 | 641 | onChange: (_, options: ModelOfMatterParams) => { |
| 641 | 642 | if (options) { |
| 642 | 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 | 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 | 742 | field: 'serviceInputValue', |
| 729 | 743 | component: 'ObjectModelValidateForm', |
| 730 | 744 | label: '', |
| 731 | 745 | changeEvent: 'update:value', |
| 732 | 746 | valueField: 'value', |
| 733 | - show: ({ values }) => values['thingsModelId'], | |
| 747 | + show: ({ values }) => | |
| 748 | + values['thingsModelId'] && values['transportType'] !== TransportTypeEnum.TCP, | |
| 734 | 749 | colProps: { |
| 735 | 750 | span: 24, |
| 736 | 751 | }, | ... | ... |
| ... | ... | @@ -94,7 +94,7 @@ |
| 94 | 94 | |
| 95 | 95 | <script lang="ts"> |
| 96 | 96 | import { defineComponent } from 'vue'; |
| 97 | - import { isNumber } from '/@/utils/is'; | |
| 97 | + import { isNumber, isObject, isString } from '/@/utils/is'; | |
| 98 | 98 | import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; |
| 99 | 99 | export default defineComponent({ |
| 100 | 100 | components: { |
| ... | ... | @@ -272,12 +272,11 @@ |
| 272 | 272 | const isTCPTransportType = value.transportType === TransportTypeEnum.TCP; |
| 273 | 273 | const doContext = unref(jsonInstance)?.get() || {}; |
| 274 | 274 | const serviceInputValue = Reflect.get(value, 'serviceInputValue'); |
| 275 | - | |
| 276 | 275 | return { |
| 277 | 276 | ...value, |
| 278 | 277 | ...(Number(value.commandType) === CommandTypeEnum.CUSTOM |
| 279 | 278 | ? { doContext: isTCPTransportType ? value.doContext : doContext } |
| 280 | - : { doContext: serviceInputValue }), | |
| 279 | + : { doContext: isTCPTransportType ? value.tcpServiceCommand : serviceInputValue }), | |
| 281 | 280 | clearRule, |
| 282 | 281 | }; |
| 283 | 282 | }; |
| ... | ... | @@ -291,7 +290,10 @@ |
| 291 | 290 | ? { commandType: String(fieldsValue.commandType) } |
| 292 | 291 | : {}), |
| 293 | 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 | 297 | : { doContext: doContext.params }), |
| 296 | 298 | }); |
| 297 | 299 | }; | ... | ... |