fix 修复问题
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { message as Message, Modal } from 'antd'
|
||||
import { Button, Drawer, message as Message, Modal } from 'antd'
|
||||
import { cloneDeep, isEqual } from 'lodash'
|
||||
|
||||
export default class ModalForm extends Component {
|
||||
@@ -74,7 +74,7 @@ export default class ModalForm extends Component {
|
||||
|
||||
await body.fillData(this.data)
|
||||
// 保存此时的form内容为快照
|
||||
if (this.compareOnClose) {
|
||||
if (this.compareOnClose && body.form && body.form.current) {
|
||||
this.snapshot = cloneDeep(body.form.current.getFieldsValue())
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export default class ModalForm extends Component {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.compareOnClose) {
|
||||
if (this.compareOnClose && body.form && body.form.current) {
|
||||
const formData = body.form.current.getFieldsValue()
|
||||
if (!isEqual(this.snapshot, formData)) {
|
||||
Modal.confirm({
|
||||
@@ -146,7 +146,7 @@ export default class ModalForm extends Component {
|
||||
|
||||
on = {
|
||||
...on,
|
||||
onCancel: () => this.onClose(this.compareOnClose)
|
||||
onCancel: () => this.onClose()
|
||||
}
|
||||
|
||||
return <Modal className="yo-modal-form" {...props} {...on}>
|
||||
@@ -163,7 +163,20 @@ export default class ModalForm extends Component {
|
||||
* @returns
|
||||
*/
|
||||
renderDrawer(props, on, childWithProps) {
|
||||
return <div></div>
|
||||
on = {
|
||||
...on,
|
||||
onClose: () => this.onClose()
|
||||
}
|
||||
|
||||
return <Drawer className="yo-drawer-form" {...props} {...on}>
|
||||
<div class="yo-drawer-form--body">
|
||||
{childWithProps}
|
||||
</div>
|
||||
<div className="ant-drawer-footer">
|
||||
<Button onClick={on.onClose}>取消</Button>
|
||||
<Button loading={this.state.confirmLoading} onClick={on.onOk} type="primary">确定</Button>
|
||||
</div>
|
||||
</Drawer>
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user