/**
 * 徐立
 * 2019年9月16日
 * Modal定制样式
 */
import React, {Component} from 'react';
import { Button } from 'antd';
import { getModal } from '@/webPublic/one_stop_public/utils/utils';
import stylesList from '@/webPublic/one_stop_public/AffairButton/AuditButton/Modal/stylesList';

const Modal = getModal();

export default class WebModal extends Component {
  constructor(props) {
    super(props);
    this.state = {
      top: 0,
    };
  }

  /**
   * 钟是志
   * 2020年4月22日 17:07:53
   * 修改Iframe打开弹窗的时候 弹窗定位错误的bug
   * */
  componentDidMount() {
    // setTimeout(() => {
    //   let dom = document.getElementById('detailInfoDiv');
    //   if (dom && dom.offsetHeight) {
    //     let height = dom.offsetHeight;
    //     if (height > 700) {
    //       this.setState({
    //         top: height - 700,
    //       });
    //     }
    //     //  console.log(height, 'Iframe页面的高度');
    //   }
    // }, 1500);
  }

  render() {
    let {visible, handleCancel, title, width, getContainer} = this.props;
    const {top} = this.state;
    const style = {
      borderRadius: 4,
    };
    if (top) {
      style.top = top;
    }
    let dom = document.getElementsByClassName('antd-pro-web-public-one_stop_public-affair-button-audit-button-user-table-styles-btn_page');
    if(dom && dom.length){
      dom = dom[0];
    }
    return (
        <Modal
          closable={false}
          visible={visible}
          footer={null}
          destroyOnClose={true}
          width={!!width ? width : 800}
          handleCancel={handleCancel}
          style={style}>
          <div style={stylesList.content_div}>
            <div style={stylesList.title}>
              {title}
              <Button style={stylesList.button}
                      onClick={handleCancel}>
                X
              </Button>
            </div>
            {this.props.children}
          </div>
        </Modal>
    );
  }
}
