mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:48:32 +08:00
fix: 表单项使用表达式默认值时联动计算结果无法触发校验问题 (#6104)
This commit is contained in:
parent
7c2fcdfb6a
commit
a4e2890309
@ -185,6 +185,7 @@ export function wrapControl<
|
||||
required,
|
||||
unique,
|
||||
value,
|
||||
isValueSchemaExp: isExpression(value),
|
||||
rules: validations,
|
||||
messages: validationErrors,
|
||||
multiple,
|
||||
@ -319,6 +320,7 @@ export function wrapControl<
|
||||
id: props.$schema.id,
|
||||
unique: props.$schema.unique,
|
||||
value: props.$schema.value,
|
||||
isValueSchemaExp: isExpression(props.$schema.value),
|
||||
rules: props.$schema.validations,
|
||||
multiple: props.$schema.multiple,
|
||||
delimiter: props.$schema.delimiter,
|
||||
|
@ -581,14 +581,18 @@ export const FormStore = ServiceStore.named('FormStore')
|
||||
item.resetValidationStatus();
|
||||
}
|
||||
|
||||
// 验证过,或者是 unique 的表单项,或者强制验证,或者有远端校验api
|
||||
/**
|
||||
* 1. 验证过,或者是 unique 的表单项,或者强制验证,或者有远端校验api
|
||||
* 2. 如果Schema的默认值为表达式,则需要基于联动计算结果重新校验
|
||||
*/
|
||||
if (
|
||||
!item.validated ||
|
||||
item.rules.equals ||
|
||||
item.rules.equalsField ||
|
||||
item.unique ||
|
||||
forceValidate ||
|
||||
!!item.validateApi
|
||||
!!item.validateApi ||
|
||||
item.isValueSchemaExp
|
||||
) {
|
||||
yield item.validate(self.data);
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ export const FormItemStore = StoreNode.named('FormItemStore')
|
||||
unique: false,
|
||||
loading: false,
|
||||
required: false,
|
||||
/** Schema默认值是否为表达式格式 */
|
||||
isValueSchemaExp: types.optional(types.boolean, false),
|
||||
tmpValue: types.frozen(),
|
||||
emitedValue: types.frozen(),
|
||||
rules: types.optional(types.frozen(), {}),
|
||||
@ -216,6 +218,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
|
||||
required,
|
||||
unique,
|
||||
value,
|
||||
isValueSchemaExp,
|
||||
rules,
|
||||
messages,
|
||||
delimiter,
|
||||
@ -238,6 +241,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
|
||||
required?: boolean;
|
||||
unique?: boolean;
|
||||
value?: any;
|
||||
isValueSchemaExp: boolean;
|
||||
rules?: string | {[propName: string]: any};
|
||||
messages?: {[propName: string]: string};
|
||||
multiple?: boolean;
|
||||
@ -284,6 +288,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
|
||||
typeof validateOnChange !== 'undefined' &&
|
||||
(self.validateOnChange = !!validateOnChange);
|
||||
typeof label === 'string' && (self.label = label);
|
||||
self.isValueSchemaExp = !!isValueSchemaExp;
|
||||
|
||||
rules = {
|
||||
...rules,
|
||||
|
Loading…
Reference in New Issue
Block a user