Commit 7f9724f4624be88eed89fe37357a40e976c3f9b5
Merge branch 'perf/command-delivery' into 'main_dev'
perf: 优化任务列表与物模型TCP命令移除空白字符 See merge request yunteng/thingskit-front!1299
Showing
4 changed files
with
11 additions
and
11 deletions
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | import { CommandDeliveryFormFieldType, CommandFieldsEnum, CommandSchemas } from './config'; | 26 | import { CommandDeliveryFormFieldType, CommandFieldsEnum, CommandSchemas } from './config'; |
27 | import { useMessage } from '/@/hooks/web/useMessage'; | 27 | import { useMessage } from '/@/hooks/web/useMessage'; |
28 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 28 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
29 | - import { CommandDeliveryWayEnum, TCPProtocolTypeEnum } from '/@/enums/deviceEnum'; | 29 | + import { CommandDeliveryWayEnum } from '/@/enums/deviceEnum'; |
30 | import { CommandTypeEnum, RPCCommandMethodEnum, TransportTypeEnum } from '/@/enums/deviceEnum'; | 30 | import { CommandTypeEnum, RPCCommandMethodEnum, TransportTypeEnum } from '/@/enums/deviceEnum'; |
31 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 31 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
32 | import { getDeviceActiveTime } from '/@/api/alarm/position'; | 32 | import { getDeviceActiveTime } from '/@/api/alarm/position'; |
@@ -88,13 +88,7 @@ | @@ -88,13 +88,7 @@ | ||
88 | if (commandType === CommandTypeEnum.CUSTOM) { | 88 | if (commandType === CommandTypeEnum.CUSTOM) { |
89 | if (isTcpDevice) { | 89 | if (isTcpDevice) { |
90 | const value = values.tcpCommandValue; | 90 | const value = values.tcpCommandValue; |
91 | - if ( | ||
92 | - unref(props.deviceDetail).deviceProfile.profileData.transportConfiguration.protocol === | ||
93 | - TCPProtocolTypeEnum.MODBUS_RTU | ||
94 | - ) { | ||
95 | - return value?.replaceAll(/\s/g, ''); | ||
96 | - } | ||
97 | - return value; | 91 | + return value?.replaceAll(/\s/g, ''); |
98 | } | 92 | } |
99 | return parseStringToJSON(values.commandValue!).json; | 93 | return parseStringToJSON(values.commandValue!).json; |
100 | } else { | 94 | } else { |
@@ -130,7 +130,11 @@ function handleServiceType( | @@ -130,7 +130,11 @@ function handleServiceType( | ||
130 | functionJson: { | 130 | functionJson: { |
131 | inputData: | 131 | inputData: |
132 | transportType === TransportTypeEnum.TCP | 132 | transportType === TransportTypeEnum.TCP |
133 | - ? [{ [FormFieldsEnum.SERVICE_COMMAND]: serviceCommand } as unknown as StructJSON] | 133 | + ? [ |
134 | + { | ||
135 | + [FormFieldsEnum.SERVICE_COMMAND]: serviceCommand?.replaceAll(/\s/g, ''), | ||
136 | + } as unknown as StructJSON, | ||
137 | + ] | ||
134 | : inputData, | 138 | : inputData, |
135 | outputData, | 139 | outputData, |
136 | }, | 140 | }, |
@@ -14,6 +14,7 @@ import { dateUtil } from '/@/utils/dateUtil'; | @@ -14,6 +14,7 @@ import { dateUtil } from '/@/utils/dateUtil'; | ||
14 | import { ProductPicker, validateProductPicker } from '../ProductPicker'; | 14 | import { ProductPicker, validateProductPicker } from '../ProductPicker'; |
15 | import { useGlobSetting } from '/@/hooks/setting'; | 15 | import { useGlobSetting } from '/@/hooks/setting'; |
16 | import { TransportTypeEnum } from '/@/enums/deviceEnum'; | 16 | import { TransportTypeEnum } from '/@/enums/deviceEnum'; |
17 | +import { validateTCPCustomCommand } from '/@/components/Form/src/components/ThingsModelForm'; | ||
17 | 18 | ||
18 | useComponentRegister('DevicePicker', DevicePicker); | 19 | useComponentRegister('DevicePicker', DevicePicker); |
19 | useComponentRegister('ProductPicker', ProductPicker); | 20 | useComponentRegister('ProductPicker', ProductPicker); |
@@ -218,7 +219,7 @@ export const formSchemas: FormSchema[] = [ | @@ -218,7 +219,7 @@ export const formSchemas: FormSchema[] = [ | ||
218 | const rules: Rule[] = [{ required: true, message: '请输入自定义数据流' }]; | 219 | const rules: Rule[] = [{ required: true, message: '请输入自定义数据流' }]; |
219 | return model[FormFieldsEnum.PUSH_WAY] === PushWayEnum.MQTT | 220 | return model[FormFieldsEnum.PUSH_WAY] === PushWayEnum.MQTT |
220 | ? [...rules, ...JSONEditorValidator()] | 221 | ? [...rules, ...JSONEditorValidator()] |
221 | - : rules; | 222 | + : [...rules, { validator: validateTCPCustomCommand }]; |
222 | }, | 223 | }, |
223 | ifShow: ({ model }) => model[FormFieldsEnum.EXECUTE_CONTENT_TYPE] === TaskTypeEnum.CUSTOM, | 224 | ifShow: ({ model }) => model[FormFieldsEnum.EXECUTE_CONTENT_TYPE] === TaskTypeEnum.CUSTOM, |
224 | valueField: 'value', | 225 | valueField: 'value', |
@@ -95,7 +95,8 @@ export const composeData = (result: Required<FormValueType>): CreateTaskRecordTy | @@ -95,7 +95,8 @@ export const composeData = (result: Required<FormValueType>): CreateTaskRecordTy | ||
95 | targetType, | 95 | targetType, |
96 | executeContent: { | 96 | executeContent: { |
97 | pushContent: { | 97 | pushContent: { |
98 | - rpcCommand: pushWay === PushWayEnum.MQTT ? JSON.parse(rpcCommand) : rpcCommand, | 98 | + rpcCommand: |
99 | + pushWay === PushWayEnum.TCP ? rpcCommand.replaceAll(/\s/g, '') : JSON.parse(rpcCommand), | ||
99 | }, | 100 | }, |
100 | pushWay, | 101 | pushWay, |
101 | type: executeContentType, | 102 | type: executeContentType, |