fix: input-table 修改内容为合法值后校验仍无法通过问题 (#5518)

* fix: input-table 内部检验问题
This commit is contained in:
sansiro 2022-10-24 14:36:53 +08:00 committed by GitHub
parent 79c5bb1b0f
commit f66da125d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -78,7 +78,9 @@ export const FormStore = ServiceStore.named('FormStore')
const current = pool.shift()!;
if (current.storeType === 'FormItemStore') {
formItems.push(current);
} else if (current.storeType !== 'ComboStore') {
} else if (
!['ComboStore', 'TableStore'].includes(current.storeType)
) {
pool.push(...current.children);
}
}

View File

@ -20,6 +20,7 @@ import {
ApiObject,
autobind,
isExpression,
ITableStore,
generateIcon
} from 'amis-core';
import {Button, Icon} from 'amis-ui';
@ -237,6 +238,8 @@ export default class FormTable extends React.Component<TableProps, TableState> {
subForms: any = {};
rowPrinstine: Array<any> = [];
editting: any = {};
tableStore?: ITableStore;
constructor(props: TableProps) {
super(props);
@ -346,6 +349,17 @@ export default class FormTable extends React.Component<TableProps, TableState> {
return msg;
}
}
if (!this.tableStore) return;
// 校验子项
const children = this.tableStore.children.filter(
item => item?.storeType === 'FormItemStore'
);
const results = await Promise.all(
children.map(item => item.validate(this.props.value))
);
}
emitValue() {
@ -1163,6 +1177,13 @@ export default class FormTable extends React.Component<TableProps, TableState> {
return String(this.entries.get(entry));
}
tableRef(ref: any) {
while (ref && ref.getWrappedInstance) {
ref = ref.getWrappedInstance();
}
this.tableStore = ref?.props?.store;
}
render() {
const {
className,
@ -1225,6 +1246,7 @@ export default class FormTable extends React.Component<TableProps, TableState> {
tableContentClassName
},
{
ref: this.tableRef.bind(this),
value: undefined,
saveImmediately: true,
disabled,