onAction 的代理模式整理

This commit is contained in:
2betop 2020-01-07 10:47:28 +08:00
parent dd5a08c663
commit 6c8949d8e2
4 changed files with 25 additions and 7 deletions

View File

@ -605,7 +605,7 @@ export class DialogRenderer extends Dialog {
if (action.from === this.$$id) {
return onAction
? onAction(e, action, data, throwErrors, this.context)
? onAction(e, action, data, throwErrors, delegate || this.context)
: false;
}
@ -668,7 +668,13 @@ export class DialogRenderer extends Dialog {
})
.catch(() => {});
} else if (onAction) {
let ret = onAction(e, action, data, throwErrors, this.context);
let ret = onAction(
e,
action,
data,
throwErrors,
delegate || this.context
);
action.close &&
(ret && ret.then
? ret.then(this.handleSelfClose)

View File

@ -628,7 +628,7 @@ export class DrawerRenderer extends Drawer {
if (action.from === this.$$id) {
return onAction
? onAction(e, action, data, throwErrors, this.context)
? onAction(e, action, data, throwErrors, delegate || this.context)
: false;
}
@ -665,7 +665,13 @@ export class DrawerRenderer extends Drawer {
})
.catch(() => {});
} else if (onAction) {
let ret = onAction(e, action, data, throwErrors, this.context);
let ret = onAction(
e,
action,
data,
throwErrors,
delegate || this.context
);
action.close &&
(ret && ret.then
? ret.then(this.handleSelfClose)

View File

@ -711,7 +711,7 @@ export default class Form extends React.Component<FormProps, object> {
action.target && this.reloadTarget(action.target, data);
} else if (onAction) {
// 不识别的丢给上层去处理。
return onAction(e, action, data, throwErrors, this.context);
return onAction(e, action, data, throwErrors, delegate || this.context);
}
}

View File

@ -357,7 +357,13 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
});
}
handleAction(e: React.UIEvent<any> | void, action: Action, data: object) {
handleAction(
e: React.UIEvent<any> | void,
action: Action,
data: object,
throwErrors: boolean = false,
delegate?: IScopedContext
) {
const {onAction, store, env} = this.props;
if (action.actionType === 'next' || action.type === 'submit') {
@ -401,7 +407,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
} else if (action.actionType === 'reload') {
action.target && this.reloadTarget(action.target, data);
} else if (onAction) {
onAction(e, action, data, false, this.context);
onAction(e, action, data, throwErrors, delegate || this.context);
}
}