Commit 1ac70224d9ef5e88e271e7a5db80b4069f7525af

Authored by xp.Huang
2 parents 241476aa ca7bef62

Merge branch 'fix/edit-device-tcp-on-line' into 'main_dev'

fix: 编辑tcp网关子设备时,设备处于在线状态,不能编辑地址码code

See merge request yunteng/thingskit-front!1400
... ... @@ -136,7 +136,8 @@ export interface FormSchema {
136 136 helpMessage?:
137 137 | string
138 138 | string[]
139   - | ((renderCallbackParams: RenderCallbackParams) => string | string[]);
  139 + | ((renderCallbackParams: RenderCallbackParams) => string | string[])
  140 + | Boolean;
140 141 // BaseHelp component props
141 142 helpComponentProps?: Partial<HelpComponentProps>;
142 143 // Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid
... ...
... ... @@ -209,8 +209,22 @@ export const step1Schemas: FormSchema[] = [
209 209 defaultValue: 'HEX',
210 210 },
211 211 {
  212 + field: 'deviceState',
  213 + label: '',
  214 + component: 'Input',
  215 + show: false,
  216 + },
  217 + {
212 218 field: 'addressCode',
213 219 label: '地址码',
  220 + dynamicDisabled({ values }) {
  221 + return (
  222 + values.isUpdate &&
  223 + values.deviceType === DeviceTypeEnum.SENSOR &&
  224 + values.deviceState === 'ONLINE' &&
  225 + values.transportType === TransportTypeEnum.TCP
  226 + );
  227 + },
214 228 dynamicRules({ values }) {
215 229 return [
216 230 {
... ... @@ -222,7 +236,15 @@ export const step1Schemas: FormSchema[] = [
222 236 },
223 237 ];
224 238 },
225   - helpMessage: ['地址码范围为00~FF'],
  239 + helpMessage({ values }) {
  240 + return [
  241 + '地址码范围为00~FF',
  242 + values.transportType === TransportTypeEnum.TCP &&
  243 + values.deviceType === DeviceTypeEnum.SENSOR
  244 + ? 'tcp网关子设备在线时,不能修改设备标识或地址码'
  245 + : '',
  246 + ];
  247 + },
226 248 component: 'HexInput',
227 249 changeEvent: 'update:value',
228 250 valueField: 'value',
... ... @@ -256,6 +278,22 @@ export const step1Schemas: FormSchema[] = [
256 278 },
257 279 ];
258 280 },
  281 + dynamicDisabled({ values }) {
  282 + return (
  283 + values.isUpdate &&
  284 + values.deviceType === DeviceTypeEnum.SENSOR &&
  285 + values.deviceState === 'ONLINE' &&
  286 + values.transportType === TransportTypeEnum.TCP
  287 + );
  288 + },
  289 + helpMessage({ values }) {
  290 + return (
  291 + values.transportType === TransportTypeEnum.TCP &&
  292 + values.deviceType === DeviceTypeEnum.SENSOR
  293 + ? ['tcp网关子设备在线时,不能修改设备标识或地址码']
  294 + : false
  295 + ) as any;
  296 + },
259 297 component: 'Input',
260 298 componentProps: () => {
261 299 return {
... ...