This commit is contained in:
2021-07-02 17:56:34 +08:00

View File

@@ -15,8 +15,23 @@ function renderModal(props, on, childWithProps) {
onCancel: () => this.onClose(), onCancel: () => this.onClose(),
} }
const { buttons } = this.props
const _buttons = [
<Button onClick={() => on.onClose()}>取消</Button>,
<Button loading={props.confirmLoading} onClick={() => on.onOk()} type="primary">
确认
</Button>,
]
if (Array.isArray(buttons)) {
for (const { index, button } of buttons) {
_buttons.splice(index, 0, button(this.getData, this.close))
}
}
return ( return (
<Modal className="yo-modal-form" {...props} {...on}> <Modal className="yo-modal-form" {...props} {...on} footer={_buttons}>
{childWithProps} {childWithProps}
</Modal> </Modal>
) )
@@ -112,6 +127,13 @@ export default class ModalForm extends Component {
this.setState({ visible: false }) this.setState({ visible: false })
} }
getData = async () => {
const body = this.childNode.current
if (!body || !body.getData) throw Error('为获取到子表单')
return await body.getData()
}
/** /**
* 子元素创建后回调 * 子元素创建后回调
* 对子元素数据进行填充,(如需关闭时对比)之后再获取结构调整后的数据快照 * 对子元素数据进行填充,(如需关闭时对比)之后再获取结构调整后的数据快照