/*
 * @Author: your name
 * @Date: 2021-04-26 11:42:56
 * @LastEditTime: 2021-05-15 14:35:03
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /react-antd-admin-template/src/components/Modal/modal.js
 */
import React from 'react';
import { Modal } from 'antd';

class ModalWrap extends React.Component {
//   state = { visible: false };

  constructor(props){
      super(props);
      this.state = {
        visible:props.show
      }
      
  }

  showModal = () => {
    this.setState({
      visible: true,
    });
  };

  handleOk = e => {
    const {
        handleOkCallback=()=>{}
    } = this.props;

    handleOkCallback();
    // this.setState({
    //   visible: false,
    // });
  };

  handleCancel = e => {
    const {
      handleCancelCallback=()=>{}
  } = this.props;
    this.setState({
      visible: false,
    },()=>handleCancelCallback());
  };



  render() {
    
    return (
      <div>
        {/* <Button type="primary" onClick={this.showModal}>
          Open Modal
        </Button> */}
        <Modal
          title="表单"
          visible={this.state.visible}
          onOk={this.handleOk}
          onCancel={this.handleCancel}
          width={this.props.width}
        >
          {/* {
              this.props.component&&this.props.component()
          } */}
          {this.props.children}
        </Modal>
      </div>
    );
  }
}

export default ModalWrap;