Commit 1ac70224d9ef5e88e271e7a5db80b4069f7525af
Merge branch 'fix/edit-device-tcp-on-line' into 'main_dev'
fix: 编辑tcp网关子设备时,设备处于在线状态,不能编辑地址码code See merge request yunteng/thingskit-front!1400
Showing
2 changed files
with
41 additions
and
2 deletions
| @@ -136,7 +136,8 @@ export interface FormSchema { | @@ -136,7 +136,8 @@ export interface FormSchema { | ||
| 136 | helpMessage?: | 136 | helpMessage?: |
| 137 | | string | 137 | | string |
| 138 | | string[] | 138 | | string[] |
| 139 | - | ((renderCallbackParams: RenderCallbackParams) => string | string[]); | 139 | + | ((renderCallbackParams: RenderCallbackParams) => string | string[]) |
| 140 | + | Boolean; | ||
| 140 | // BaseHelp component props | 141 | // BaseHelp component props |
| 141 | helpComponentProps?: Partial<HelpComponentProps>; | 142 | helpComponentProps?: Partial<HelpComponentProps>; |
| 142 | // Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid | 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,8 +209,22 @@ export const step1Schemas: FormSchema[] = [ | ||
| 209 | defaultValue: 'HEX', | 209 | defaultValue: 'HEX', |
| 210 | }, | 210 | }, |
| 211 | { | 211 | { |
| 212 | + field: 'deviceState', | ||
| 213 | + label: '', | ||
| 214 | + component: 'Input', | ||
| 215 | + show: false, | ||
| 216 | + }, | ||
| 217 | + { | ||
| 212 | field: 'addressCode', | 218 | field: 'addressCode', |
| 213 | label: '地址码', | 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 | dynamicRules({ values }) { | 228 | dynamicRules({ values }) { |
| 215 | return [ | 229 | return [ |
| 216 | { | 230 | { |
| @@ -222,7 +236,15 @@ export const step1Schemas: FormSchema[] = [ | @@ -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 | component: 'HexInput', | 248 | component: 'HexInput', |
| 227 | changeEvent: 'update:value', | 249 | changeEvent: 'update:value', |
| 228 | valueField: 'value', | 250 | valueField: 'value', |
| @@ -256,6 +278,22 @@ export const step1Schemas: FormSchema[] = [ | @@ -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 | component: 'Input', | 297 | component: 'Input', |
| 260 | componentProps: () => { | 298 | componentProps: () => { |
| 261 | return { | 299 | return { |