Commit c53e457b0ebadccf7ff538675b033ae9fbd636ef

Authored by xp.Huang
2 parents c7d1500f 8e7a4d67

Merge branch 'perf/command-delivery' into 'main_dev'

perf: 优化TCP modbus设备下发自定义命令时移除命令中的空白字符

See merge request yunteng/thingskit-front!1296
@@ -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 } from '/@/enums/deviceEnum'; 29 + import { CommandDeliveryWayEnum, TCPProtocolTypeEnum } 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';
@@ -87,7 +87,14 @@ @@ -87,7 +87,14 @@
87 const isTcpDevice = unref(props.deviceDetail)?.transportType === TransportTypeEnum.TCP; 87 const isTcpDevice = unref(props.deviceDetail)?.transportType === TransportTypeEnum.TCP;
88 if (commandType === CommandTypeEnum.CUSTOM) { 88 if (commandType === CommandTypeEnum.CUSTOM) {
89 if (isTcpDevice) { 89 if (isTcpDevice) {
90 - return 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 } 98 }
92 return parseStringToJSON(values.commandValue!).json; 99 return parseStringToJSON(values.commandValue!).json;
93 } else { 100 } else {