Commit 527f25d43ec54689258ace40dbedcf2f6330249c
Merge branch 'local_devbranch_byft' into 'main_dev'
fix: DEFECT-1800 物模型字段中不能包含逗号 See merge request yunteng/thingskit-front!1084
Showing
1 changed file
with
24 additions
and
0 deletions
| 1 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | 1 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; |
| 2 | import { findDictItemByCode } from '/@/api/system/dict'; | 2 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 3 | +import { Rule } from '/@/components/Form'; | ||
| 3 | import { FormSchema } from '/@/components/Table'; | 4 | import { FormSchema } from '/@/components/Table'; |
| 4 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; | 5 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; |
| 5 | import { isNullOrUnDef } from '/@/utils/is'; | 6 | import { isNullOrUnDef } from '/@/utils/is'; |
| @@ -27,6 +28,23 @@ interface StructFormSchemasParmasType { | @@ -27,6 +28,23 @@ interface StructFormSchemasParmasType { | ||
| 27 | isTcp?: boolean; | 28 | isTcp?: boolean; |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 31 | +//功能名称和标识符 输入框不能包含逗号 | ||
| 32 | +const validateExcludeComma = (field: string, errorName: string): Rule[] => { | ||
| 33 | + return [ | ||
| 34 | + { | ||
| 35 | + required: true, | ||
| 36 | + trigger: 'blur', | ||
| 37 | + validator: () => { | ||
| 38 | + const reg = /[,,]+/; | ||
| 39 | + if (reg.test(field)) { | ||
| 40 | + return Promise.reject(errorName); | ||
| 41 | + } | ||
| 42 | + return Promise.resolve(); | ||
| 43 | + }, | ||
| 44 | + }, | ||
| 45 | + ]; | ||
| 46 | +}; | ||
| 47 | + | ||
| 30 | export const formSchemas = ({ | 48 | export const formSchemas = ({ |
| 31 | hasStructForm, | 49 | hasStructForm, |
| 32 | hiddenAccessMode, | 50 | hiddenAccessMode, |
| @@ -45,6 +63,9 @@ export const formSchemas = ({ | @@ -45,6 +63,9 @@ export const formSchemas = ({ | ||
| 45 | maxLength: 32, | 63 | maxLength: 32, |
| 46 | placeholder: '请输入功能名称', | 64 | placeholder: '请输入功能名称', |
| 47 | }, | 65 | }, |
| 66 | + dynamicRules: ({ values }) => { | ||
| 67 | + return validateExcludeComma(values[FormField.FUNCTION_NAME], '功能名称不能包含逗号'); | ||
| 68 | + }, | ||
| 48 | }, | 69 | }, |
| 49 | { | 70 | { |
| 50 | field: FormField.IDENTIFIER, | 71 | field: FormField.IDENTIFIER, |
| @@ -58,6 +79,9 @@ export const formSchemas = ({ | @@ -58,6 +79,9 @@ export const formSchemas = ({ | ||
| 58 | maxLength: 128, | 79 | maxLength: 128, |
| 59 | placeholder: '请输入标识符', | 80 | placeholder: '请输入标识符', |
| 60 | }, | 81 | }, |
| 82 | + dynamicRules: ({ values }) => { | ||
| 83 | + return validateExcludeComma(values[FormField.IDENTIFIER], '标识符不能包含逗号'); | ||
| 84 | + }, | ||
| 61 | }, | 85 | }, |
| 62 | { | 86 | { |
| 63 | field: FormField.HAS_STRUCT_FROM, | 87 | field: FormField.HAS_STRUCT_FROM, |