fix: 修复 crud 中 actionType reload 其他组件失效问题 & submit配置required在弹窗中错误关闭问题 (#4593)

This commit is contained in:
RUNZE LU 2022-06-10 16:38:54 +08:00 committed by GitHub
parent 7a51e49b59
commit 48b759962d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -974,6 +974,9 @@ export default class Form extends React.Component<FormProps, object> {
if (!dispatcher?.prevented) {
env.notify('error', __('Form.validateFailed'));
}
/** 抛异常是为了在dialog中catch这个错误避免弹窗直接关闭 */
return Promise.reject(__('Form.validateFailed'));
} else {
dispatchEvent('validateSucc', this.props.data);
this.handleAction(

View File

@ -670,7 +670,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
throw e;
}
});
} else if (action.actionType === 'reload') {
} else if (action.actionType === 'reload' && !action.target) {
this.reload();
} else if (
pickerMode &&

View File

@ -2818,6 +2818,22 @@ export class TableRenderer extends Table {
return scoped.send(subPath, values);
}
}
reload(subPath?: string, query?: any, ctx?: any) {
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给Table这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.reload?.(subPath, query, ctx);
}
if (subPath) {
return scoped.reload(subPath, ctx);
}
}
}
export {TableCell};