import React from 'react';
import {Modal,Button} from 'antd';
import {observable}from 'mobx';
import {observer}from 'mobx-react';
@observer
export default class CustomModal extends React.Component{
    @observable
    visible=false;
    handleClick(){
        this.visible=true;
    }
    handleOk(){
        this.props.fun && this.props.fun()
        this.visible=false;
    }
    handleCancel(){
        this.visible=false;
    }
    buttonStyle(){
        if(this.props.val && this.props.val==1){
            return (<div>
                <Button onClick={()=>this.handleOk()}>确认</Button>
                <Button onClick={()=>this.handleCancel()}>取消</Button>
            </div>)
        }else{
            return (<div>
                <Button onClick={()=>this.handleCancel()}>取消</Button>
                <Button onClick={()=>this.handleOk()}>确认</Button>
            </div>)
        }
    }
    render(){
        const props = this.props;
        return (<div>
            <Button {...props} onClick={()=>this.handleClick()}>

            </Button>
            <Modal
                visible={this.visible}
                title={props.title}
                onOk={()=>this.handleOk()}
                onCancel={()=>this.handleCancel()}
                footer={this.buttonStyle()}
                width={900}            
            >
                <p>{props.message || ""}</p>
            </Modal>
        </div>)
    }
}