From f8e2952727ac9ba8657c3c0c62383997cb984e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?= <188633308@qq.com> Date: Fri, 2 Jul 2021 16:01:22 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=85=81=E8=AE=B8=E5=90=91modal?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-react/src/components/modal-form/index.jsx | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/web-react/src/components/modal-form/index.jsx b/web-react/src/components/modal-form/index.jsx index 5b86f51..ff78981 100644 --- a/web-react/src/components/modal-form/index.jsx +++ b/web-react/src/components/modal-form/index.jsx @@ -15,8 +15,23 @@ function renderModal(props, on, childWithProps) { onCancel: () => this.onClose(), } + const { buttons } = this.props + + const _buttons = [ + , + , + ] + + if (Array.isArray(buttons)) { + for (const { index, button } of buttons) { + _buttons.splice(index, 0, button(this.getData, this.close)) + } + } + return ( - + {childWithProps} ) @@ -112,6 +127,13 @@ export default class ModalForm extends Component { this.setState({ visible: false }) } + getData = async () => { + const body = this.childNode.current + if (!body || !body.getData) throw Error('为获取到子表单') + + return await body.getData() + } + /** * 子元素创建后回调 * 对子元素数据进行填充,(如需关闭时对比)之后再获取结构调整后的数据快照