From 7233efaf6514e603c7511a924457cb1d9d06a227 Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Tue, 16 Jun 2020 22:39:32 +0800 Subject: [PATCH] =?UTF-8?q?modal=20=E6=B8=B2=E6=9F=93=20form=20=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Dialog.tsx | 9 ++++----- src/renderers/Drawer.tsx | 10 ++++------ src/renderers/Form/index.tsx | 1 + 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/renderers/Dialog.tsx b/src/renderers/Dialog.tsx index d1462af4..4f485446 100644 --- a/src/renderers/Dialog.tsx +++ b/src/renderers/Dialog.tsx @@ -306,7 +306,10 @@ export default class Dialog extends React.Component { disabled: (body && (body as any).disabled) || store.loading, onAction: this.handleAction, onFinished: this.handleChildFinished, - affixOffsetTop: 0 + affixOffsetTop: 0, + onChange: this.handleFormChange, + onInit: this.handleFormInit, + onSaved: this.handleFormSaved }; if (!(body as Schema).type) { @@ -322,10 +325,6 @@ export default class Dialog extends React.Component { submitText: null, ...schema }; - - subProps.onChange = this.handleFormChange; - subProps.onInit = this.handleFormInit; - subProps.onSaved = this.handleFormSaved; } return render(`body${key ? `/${key}` : ''}`, schema, subProps); diff --git a/src/renderers/Drawer.tsx b/src/renderers/Drawer.tsx index fdf900fb..95b1805b 100644 --- a/src/renderers/Drawer.tsx +++ b/src/renderers/Drawer.tsx @@ -276,7 +276,10 @@ export default class Drawer extends React.Component { disabled: store.loading, onAction: this.handleAction, onFinished: this.handleChildFinished, - popOverContainer: this.getPopOverContainer + popOverContainer: this.getPopOverContainer, + onChange: this.handleFormChange, + onInit: this.handleFormInit, + onSaved: this.handleFormSaved }; if (schema.type === 'form') { @@ -286,11 +289,6 @@ export default class Drawer extends React.Component { submitText: null, ...schema }; - - // 同步数据到 Dialog 层,方便 actions 根据表单数据联动。 - subProps.onChange = this.handleFormChange; - subProps.onInit = this.handleFormInit; - subProps.onSaved = this.handleFormSaved; } return render(`body${key ? `/${key}` : ''}`, schema, subProps); diff --git a/src/renderers/Form/index.tsx b/src/renderers/Form/index.tsx index 37b1339c..6a834362 100644 --- a/src/renderers/Form/index.tsx +++ b/src/renderers/Form/index.tsx @@ -158,6 +158,7 @@ export default class Form extends React.Component { 'onChange', 'onFailed', 'onFinished', + 'onSaved', 'canAccessSuperData', 'lazyChange', 'formLazyChange',