From ebc5edbdff6c8fc3796f2ccc2c66658e35b9eb04 Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Wed, 10 Jun 2020 17:48:53 +0800 Subject: [PATCH] =?UTF-8?q?wizard=20=E6=9C=80=E5=90=8E=E4=B8=80=E6=AD=A5?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=EF=BC=8C=E5=BA=94=E8=AF=A5=E7=BB=88=E6=AD=A2=20form?= =?UTF-8?q?=20=E4=B8=AD=E5=90=8E=E7=BB=AD=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E4=B8=8A=E6=B2=A1=E6=9C=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Form/index.tsx | 7 ++++++- src/renderers/Wizard.tsx | 8 +++++--- src/store/form.ts | 7 ++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/renderers/Form/index.tsx b/src/renderers/Form/index.tsx index d7067e1c..bedad0ee 100644 --- a/src/renderers/Form/index.tsx +++ b/src/renderers/Form/index.tsx @@ -603,7 +603,7 @@ export default class Form extends React.Component { store.setCurrentAction(action); return this.submit((values): any => { if (onSubmit && onSubmit(values, action) === false) { - return Promise.resolve(values); + return Promise.resolve(false); } if (target) { @@ -665,6 +665,11 @@ export default class Form extends React.Component { return Promise.resolve(values); }) .then(values => { + // 有可能 onSubmit return false 了,那么后面的就不应该再执行了。 + if (values === false) { + return store.data; + } + if (onFinished && onFinished(values, action) === false) { return values; } diff --git a/src/renderers/Wizard.tsx b/src/renderers/Wizard.tsx index cfaa2161..b6c1df86 100644 --- a/src/renderers/Wizard.tsx +++ b/src/renderers/Wizard.tsx @@ -552,12 +552,14 @@ export default class Wizard extends React.Component { return value; } - const finalRedirect = redirect && filter(redirect, store.data); + const finalRedirect = + (action.redirect || redirect) && + filter(action.redirect || redirect, store.data); if (finalRedirect) { env.jumpTo(finalRedirect, action); - } else if (reload) { - this.reloadTarget(reload, store.data); + } else if (action.reload || reload) { + this.reloadTarget(action.reload || reload, store.data); } return value; diff --git a/src/store/form.ts b/src/store/form.ts index 2b2ed1cc..b6bec6c9 100644 --- a/src/store/form.ts +++ b/src/store/form.ts @@ -335,7 +335,7 @@ export const FormStore = ServiceStore.named('FormStore') if (fn) { const diff = difference(self.data, self.pristine); - yield fn( + const result = yield fn( createObject( createObject(self.data.__super, { diff: diff, @@ -345,12 +345,13 @@ export const FormStore = ServiceStore.named('FormStore') self.data ) ); + return result ?? self.data; } + + return self.data; } finally { self.submiting = false; } - - return self.data; }); const validate: (