import React, { Component } from "react";
import ReactDom from "react-dom";
import style from "./index.less";
import Notify from '@commonComp/Notify';
import close from '@common/images/icon_close.png';
import { dragBox } from '@utils/tools';

/**
 * title:标题
 * children：弹窗内容
 * onClose:弹窗关闭事件
 * shadeClose:点蒙层关闭，默认true
 *footer:固定在弹窗底部的内容如确定按钮
 *icon:标题前的图标
 *width:弹窗的宽度
 *height:弹窗的高度
 * **/


class ComplexModal extends Component {
  constructor(props) {
    super(props);
  }
  componentDidMount(){
    dragBox('complexModalWrap','complexModalTitle')
  }

  render() {
    const { onclose,title,children,footer,shadeClose,icon,width,top,bottom} = this.props;
    const marginLeft = width? -parseInt(width)/2 : '';
    //const marginTop = height? -parseInt(height)/2: '';
    const domNode = document.getElementById('root');
    return ReactDom.createPortal(<div className={style['container']}>
      <div className={style['shade']} onClick={shadeClose===false?'':onclose}></div>
      <div id="complexModalWrap" className={style['modal']} style={{width: width?width:'auto', marginLeft:marginLeft, top:top?top+'px':'',bottom:bottom?bottom+'px':''}}>
        <div className={`${style['close']} drag-title`} id="complexModalTitle">
          {icon?<img src={icon} />:''}
          {title}
          <img src={close} onClick={onclose} className={style['closeIcon']} />
        </div>
        <i className={style['flg']}>患者基本信息</i>
        <div className={style["content"]} style = {{width: width?width:'auto'}}>{children}</div>
        <div className={style['footer']} style = {{width: width?width:'auto'}}>{footer}</div>
      </div>
    </div>,domNode);
  }
}

export default ComplexModal;
