// 药品审核
import React from 'react';
import { Drawer, Row, Col, Button } from 'antd';
import PatientList from '../Patient/PatientList';
import DrugReviewSearch from './DrugReviewSearch';
import DrugReviewTabel from './DrugReviewTabel';
import './index.less';

export default class DrugReview extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            leftspan: 5,
            rightspan: 19,
            patient: [],
            iconType: "double-left",
            display: false
        }
    }
    componentDidMount() {

    }
    onBtnClick = () => {
        this.setState({
            leftspan: 5 - this.state.leftspan,
        });
    }
    onClose = () => {
        this.setState({
            visible: true,
        });
    }
    updateState = (state) => {
        this.setState(state);
        this.handleQueryTop();
    }

    loadData = (dataSource) => {
        this.setState(dataSource, () => {
            if(this.child){
                this.child.getdetail(null);
            }
        });
    }
    // 调用公共组件的连接事件
    onRef = (ref) => {
        this.child = ref
    }

    topOnRef = (ref) => {
        this.topChild = ref
    }

    handleQueryTop = () => {
        this.topChild.handleQuery()
    }
    // 清除明细信息
    clearDetail = () => {
        this.setState({
            display: false
        })
    }
    render() {
        return (
            <div className='aaaa' style={{ width: '100%', height: '100%' }}>
                <Row style={{ border: "2px solid #cccccc", height: "100%", width: "100%", overflowY: "hidden" }}>
                    <Col className={this.state.iconType == "double-left" ? "" : "visibleIcon"} span={this.state.leftspan} style={{ border: this.state.iconType == "double-left" ? "1px solid #cccccc" : "0px", height: "100%", overflowY: 'hidden', background: '#ffffff', boxSizing: 'border-box' }}>
                        <PatientList updateState={this.updateState} iconType={this.state.iconType} />
                    </Col>
                    <Col span={this.state.rightspan}>
                        <Row style={{ height: "15%" }}>
                            <DrugReviewSearch
                                updateState={this.updateState}
                                patient={this.state.patient}
                                loadData={this.loadData}
                                onRef={this.topOnRef}
                                clearDetail={this.clearDetail}
                            />
                        </Row>
                        <Row style={{ height: "85%" }}>
                            <DrugReviewTabel
                                updateState={this.updateState}
                                dataSource={this.state.dataSource}
                                patient={this.state.patient}
                                pharmacyAry={this.state.pharmacyAry}
                                drugColumnAry={this.state.drugColumnAry}
                                orderColumnAry={this.state.orderColumnAry}
                                process={this.state.process}
                                update={this.state.update}
                                isDoubelClickTab={this.state.display}
                                handleThis={this}
                                onRef={this.onRef}                                
                            />
                        </Row>
                    </Col>
                </Row>
            </div>

        )
    }
}
