import React, { Component } from "react";
import {getAllDataList,getAllDataStringList} from '@utils/tools';
import PreviewBody from '../PreviewBody';
import store from '@store';
import style from "./index.less";
import close from '../../common/images/icon_close.png';

class Preview extends Component {
  constructor(props) {
    super(props)
  }

  render() {
    const { onClose, visible,preInfo } = this.props;
    let baseList = store.getState();
    const dataJson = getAllDataList(baseList);
    const dataStr = getAllDataStringList(baseList);

    return <div className={style['container']} style={visible? {display: 'block'}: {display: 'none'}}>
      <div className={style['shade']} onClick={onClose}></div>
      <div className={style['modal']}>
        <div className={style['close']}>预览<img src={close} onClick={onClose} /></div>
        <PreviewBody
            preInfo={preInfo}
            dataJson={dataJson}
            dataStr={dataStr}
            show={false}
        ></PreviewBody>
      </div>
    </div>
  }
}

export default Preview;
