Showing
1 changed file
with
6 additions
and
13 deletions
| @@ -12,16 +12,9 @@ export interface BasicCreateFormParams { | @@ -12,16 +12,9 @@ export interface BasicCreateFormParams { | ||
| 12 | 12 | ||
| 13 | useComponentRegister('JSONEditor', JSONEditor); | 13 | useComponentRegister('JSONEditor', JSONEditor); |
| 14 | 14 | ||
| 15 | -const validateDouble = ( | ||
| 16 | - value: number, | ||
| 17 | - type: DataTypeEnum, | ||
| 18 | - min?: number | string, | ||
| 19 | - max?: number | string | ||
| 20 | -) => { | ||
| 21 | - min = | ||
| 22 | - Number(min) || type === DataTypeEnum.NUMBER_INT ? Number.MIN_SAFE_INTEGER : Number.MIN_VALUE; | ||
| 23 | - max = | ||
| 24 | - Number(max) || type === DataTypeEnum.NUMBER_INT ? Number.MAX_SAFE_INTEGER : Number.MAX_VALUE; | 15 | +const validateDouble = (value: number, min?: number | string, max?: number | string) => { |
| 16 | + min = Number(min) || Number.MIN_SAFE_INTEGER; | ||
| 17 | + max = Number(max) || Number.MAX_SAFE_INTEGER; | ||
| 25 | 18 | ||
| 26 | return { | 19 | return { |
| 27 | flag: value < min || value > max, | 20 | flag: value < min || value > max, |
| @@ -47,7 +40,7 @@ export const useGenDynamicForm = () => { | @@ -47,7 +40,7 @@ export const useGenDynamicForm = () => { | ||
| 47 | type: 'number', | 40 | type: 'number', |
| 48 | trigger: 'change', | 41 | trigger: 'change', |
| 49 | validator: (_rule, value) => { | 42 | validator: (_rule, value) => { |
| 50 | - const { flag, message } = validateDouble(value, type, min, max); | 43 | + const { flag, message } = validateDouble(value, min, max); |
| 51 | if (flag) { | 44 | if (flag) { |
| 52 | return Promise.reject(`${functionName}${message}`); | 45 | return Promise.reject(`${functionName}${message}`); |
| 53 | } | 46 | } |
| @@ -56,8 +49,8 @@ export const useGenDynamicForm = () => { | @@ -56,8 +49,8 @@ export const useGenDynamicForm = () => { | ||
| 56 | }, | 49 | }, |
| 57 | ], | 50 | ], |
| 58 | componentProps: { | 51 | componentProps: { |
| 59 | - max: max ?? type === DataTypeEnum.NUMBER_INT ? Number.MAX_SAFE_INTEGER : Number.MAX_VALUE, | ||
| 60 | - min: min ?? type === DataTypeEnum.NUMBER_INT ? Number.MIN_SAFE_INTEGER : Number.MIN_VALUE, | 52 | + max: max ?? Number.MAX_SAFE_INTEGER, |
| 53 | + min: min ?? Number.MIN_SAFE_INTEGER, | ||
| 61 | step, | 54 | step, |
| 62 | placeholder: `请输入${functionName}`, | 55 | placeholder: `请输入${functionName}`, |
| 63 | precision: type === DataTypeEnum.NUMBER_INT ? 0 : 2, | 56 | precision: type === DataTypeEnum.NUMBER_INT ? 0 : 2, |