index.jsx 1.6 KB
/**
 * 徐立
 * 2019年9月16日
 * Modal定制样式
 */
import React, { Component } from 'react'
import { Modal, Button } from 'antd';
import styles from './index.less'
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  } =this.props;
        const { top } = this.state;
        const style = {
          borderRadius:4,
        };
        if(top){
          style.top = top;
        }
        return (
            <div>
            <Modal
            closable={false}
            visible={visible}
            footer={null}
            destroyOnClose={true}
            width={!!width ? width : 800}
            handleCancel={handleCancel}
            style={style}
            >
                <div className={styles.content_div}>
                    <div className={styles.title}>{title}<Button className={styles.button} onClick={handleCancel}>X</Button></div>
                    {this.props.children}
                </div>
            </Modal>
            </div>
        )
    }
}