form 也支持 feedback

This commit is contained in:
2betop 2021-01-22 08:29:33 +08:00
parent 20c56d654e
commit e8c13f94aa

View File

@ -49,6 +49,7 @@ import {
} from '../../Schema';
import {ActionSchema} from '../Action';
import {ButtonGroupControlSchema} from './ButtonGroup';
import {DialogSchemaBase} from '../Dialog';
export interface FormSchemaHorizontal {
left?: number;
@ -161,6 +162,11 @@ export interface FormSchema extends BaseSchema {
*/
api?: SchemaApi;
/**
* Form feedback
*/
feedback?: DialogSchemaBase;
/**
* finished true
*/
@ -889,16 +895,14 @@ export default class Form extends React.Component<FormProps, object> {
})
.then(async response => {
onSaved && onSaved(values, response);
const feedback = action.feedback || this.props.feedback;
// submit 也支持 feedback
if (action.feedback && isVisible(action.feedback, store.data)) {
const confirmed = await this.openFeedback(
action.feedback,
store.data
);
if (feedback && isVisible(feedback, store.data)) {
const confirmed = await this.openFeedback(feedback, store.data);
// 如果 feedback 配置了,取消就跳过原有逻辑。
if (action.feedback.skipRestOnCancel && !confirmed) {
if (feedback.skipRestOnCancel && !confirmed) {
throw new SkipOperation();
}
}