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


class PrintPreview extends Component {
    constructor(props) {
        super(props)
    }
    surePrint(jsonStr){
        if(JSON.parse(jsonStr.chief).length == 1 && JSON.parse(jsonStr.chief)[0].trim() ==''){
          Notify.info('主诉不能为空');
            return false;
        }else if(jsonStr.chief && JSON.parse(jsonStr.chief).length < 1){
            Notify.info('主诉不能为空');
            return false;
        }else if(!jsonStr.diag || jsonStr.diag.trim().length < 1){
            Notify.info('诊断不能为空');
            return false;
        }else{
            this.onPrint();
            this.props.save(true)
        }
    }
    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']}></div>
            <div className={style['modal']}>
                <div className={style['close']}>打印<img src={close} onClick={onClose} /></div>
                {/* <div id="content"> */}
                    <PreviewBody
                        preInfo={preInfo}
                        dataJson={dataJson}
                        dataStr={dataStr}
                        show={true}
                        onClose={onClose}
                    ></PreviewBody>
                {/* </div> */}
            </div>
        </div>
    }
}

export default PrintPreview;
