index.jsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React, { Component } from "react";
  2. import ReactDom from "react-dom";
  3. import style from "./index.less";
  4. import Notify from '@commonComp/Notify';
  5. import close from '@common/images/icon_close.png';
  6. /**
  7. * title:标题
  8. * children:弹窗内容
  9. * onClose:弹窗关闭事件
  10. * shadeClose:点蒙层关闭,默认true
  11. *footer:固定在弹窗底部的内容如确定按钮
  12. *icon:标题前的图标
  13. *width:弹窗的宽度
  14. *height:弹窗的高度
  15. * **/
  16. class ComplexModal extends Component {
  17. constructor(props) {
  18. super(props)
  19. }
  20. render() {
  21. const { onclose,title,children,footer,shadeClose,icon,width,height} = this.props;
  22. const marginLeft = width? -parseInt(width)/2 : '';
  23. const marginTop = height? -parseInt(height)/2: '';
  24. const domNode = document.getElementById('root');
  25. return ReactDom.createPortal(<div className={style['container']}>
  26. <div className={style['shade']} onClick={shadeClose===false?'':onclose}></div>
  27. <div className={style['modal']} style = {{width: width?width:'auto', marginLeft:marginLeft, height:height?height:'auto', marginTop:marginTop}}>
  28. <div className={style['close']}>
  29. {icon?<img src={icon} />:''}
  30. {title}
  31. <img src={close} onClick={onclose} className={style['closeIcon']} />
  32. </div>
  33. <div className={style["content"]} style = {{width: width?width:'auto'}}>{children}</div>
  34. <div className={style['footer']} style = {{width: width?width:'auto'}}>{footer}</div>
  35. </div>
  36. </div>,domNode);
  37. }
  38. }
  39. export default ComplexModal;