// 出院患者 - 出院患者查询
import React from 'react';
import { Select, Row, Col, Button, Spin, Radio, DatePicker, Input, Tooltip, message, Form } from 'antd';
import { $http } from '../../../containers/config/https';
import store from 'store';
import PubilcTablePagination from '../../common/PubilcTablePagination.jsx'; // 公共table组件
import moment from 'moment';
import ColumnAuthoritysModel from '../../columnAuthority/ColumnAuthoritysModel';
import { handleExcel } from 'tools/handleExcel.js';
import { Util } from 'tools/index';
import PublicModalFormHooks from 'pages/common/PublicModalFormHooks';

let user;
const OutPatientQuery = Form.create()(
    class OutPatientQuery extends React.Component {
        constructor({ history }) {
            super();
            this.history = history;
            this.state = {
                categoryData: {},
                value: 'nurConfirm',
                tableData: [], //出院患者列表
                columns: [],//列
                showLoading: true,//加载
                checked: false,
                tableType: 'C',
                consultationInfo: {},
                stopDate: '',
                startDate: '',
                locList: [],         //科室
                wardList: [],        //病区
                docList: [],         //医生
                locInfo: [], // 科室名称下拉框
                wardInfo: [],//病区
                wardBedAry: [],//床号
                userInfo: [],//医生
                admReason: [],//费别
                // 主菜单分页数据
                total: 0,
                page: 1,
                pageSize: 10,
                selectData: [],
                locID: '',
                defaultWardID: '',//默认病区
                loading: false,
                allPatData: '',
                exportLoading: false,//导出请求
                queryLoading: false,
                admID: '',
                admInfoFormData: [], // 修改就诊信息
                admInfoRowData: {},
                admInfoSelectData: {},
            };
            user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        }

        componentDidMount() {
            let newCategory;
            if ('paras' in this.props && this.props.paras && this.props.paras.params) { // 侧菜单获取类别参数
                newCategory = this.props.paras.params;
            } else {
                if ('location' in this.props && this.props.location.state && this.props.location.state.params) { // 头菜单获取类别参数
                    newCategory = this.props.location.state.params;
                    React.$setSessionData('OutPatientQuery', newCategory, false);
                } else { // 头菜单刷新界面时获取类别
                    newCategory = React.$getSessionData('OutPatientQuery', false);
                }
            }
            let categoryData = Util.getObjByUrlStr(newCategory);
            console.log('OutPatientQuery', categoryData);
            this.setState({ categoryData }, () => {
                this.loadColumn();
                this.getDepartmentInformation();
                this.getLocList('locList', '');
                this.setState({ showLoading: false });
            });
        }

        componentWillUnmount() {
            // 组件销毁前将静止让setState修改state的状态
            this.setState = (state, callback) => { return; }
        }

        // 3.13.23.获取科室信息
        getDepartmentInformation() {
            let data = {
                params: [{}]
            }
            $http.post('urlS', this, {
                code: '04090022',
                data: data,
                success: function (res) {
                    if (res.errorCode == '0') {
                        this.setState({
                            admInfoSelectData: res?.result || {},
                            locInfo: res.result.locInfo, //科室
                            userInfo: res.result.userInfo, // 医生
                            wardInfo: res.result.wardInfo, // 病区
                            admReason: res.result.admReason, // 费别
                            wardBedAry: res.result.wardBedAry, // 床号
                            defaultWardID: res.result.defaultWardID, // 默认病区
                            defaultLocID: res.result.defaultLocID, // 默认科室
                        })
                    } else {
                        this.setState({ DepartmentInformation: [] })
                    }
                }
            })
        }

        //查询列头数据
        loadColumn = () => {
            let data = {
                params: [{
                    compontName: 'OutPatientQuery',
                    type: this.state.tableType,
                }]
            }
            $http.post('urlDeault', this, {
                code: '01040073',
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        let resData = res.result[this.state.tableType];
                        var exportColumn = []
                        if (!Util.isEmpty(resData)) {
                            for (var i = 0; i < resData.length; i++) {
                                if (resData[i].exportFlag == 'Y') {
                                    exportColumn.push(resData[i])
                                }
                            }
                        }
                        for (let index = 0; index < resData.length; index++) {
                            let columnCode = resData[index].code;
                            if ((columnCode == 'admDiag')) {
                                resData[index].onCell = () => {
                                    return {
                                        style: {
                                            maxWidth: 150,
                                            overflow: 'hidden',
                                            whiteSpace: 'nowrap',
                                            textOverflow: 'ellipsis',
                                            cursor: 'pointer'
                                        }
                                    }
                                }
                                resData[index].render = (text) => <Tooltip placement='topLeft' title={text}>{text}</Tooltip>
                            }
                        }
                        this.setState({
                            columns: resData,
                            tableWidth: res.totalWidth,
                            exportColumn: exportColumn,
                            admInfoFormData: res?.result?.formData || []
                        }, () => {
                            this.handleQuery();
                        })
                    }
                }
            })
        }

        //导出
        handleExport() {
            const formData = this.props.form.getFieldsValue();
            this.setState({ loading: true })
            let data = {
                params: [{
                    hospID: user.hospID,
                    startDate: formData.startDate ? moment(formData.startDate).utcOffset(480).format('YYYY-MM-DD') : '',
                    stopDate: formData.stopDate ? moment(formData.stopDate).utcOffset(480).format('YYYY-MM-DD') : '',
                    patNo: formData.patNo,//登记号
                    patName: formData.patName,//登记号
                    patMedicalNo: formData.patMedicalNo,//住院号
                    admLocBedID: formData.admLocBedID,//床号
                    admReasonDesc: formData.admReasonDesc,//费别
                    admDocID: formData.admDocID,//管床医生
                    locID: formData.locID,//科室
                    wardID: formData.wardID,//病区
                    nurConfirm: this.state.value == 'nurConfirm' ? 'Y' : '',//护士确认,
                    docConfirm: this.state.value == 'docConfirm' ? 'Y' : '',//医生确认,
                    chargeConfirm: this.state.value == 'chargeConfirm' ? 'Y' : '',//财务结算
                    currentInHosp: this.state.value == 'currentInHosp' ? 'Y' : '',//当前在院
                }]
            };
            $http.post('urlS', this, {
                code: '04100001',
                data: data,
                success: (res) => {
                    if (res.errorCode === '0') {
                        for (let index = 0; index < res.result.Data.length; index++) {
                            res.result.Data[index].key = index + 1;
                        }
                        this.setState({
                            exportData: res.result.Data,
                            loading: false
                        }, () => {
                            handleExcel.exportExcel(this.state.exportColumn, this.state.exportData, '出院患者导出列表')
                        });
                    } else {
                        this.setState({ loading: false });
                    }
                },
                error: function () {
                    this.setState({ loading: false });
                }
            });
        }

        exportData = () => {
            console.log('1233')
            this.setState({
                exportLoading: true,
            })
            const formData = this.props.form.getFieldsValue();
            let data = {
                params: [{
                    hospID: user.hospID,
                    startDate: formData.startDate ? moment(formData.startDate).utcOffset(480).format('YYYY-MM-DD') : '',
                    stopDate: formData.stopDate ? moment(formData.stopDate).utcOffset(480).format('YYYY-MM-DD') : '',
                    patNo: formData.patNo, // 登记号
                    patName: formData.patName, // 登记号
                    patMedicalNo: formData.patMedicalNo, // 住院号
                    admLocBedID: formData.admLocBedID, // 床号
                    admReasonDesc: formData.admReasonDesc, // 费别
                    admDocID: formData.admDocID, // 管床医生
                    locID: formData.locID, // 科室
                    wardID: formData.wardID, // 病区
                    nurConfirm: this.state.value == 'nurConfirm' ? 'Y' : '', // 护士确认,
                    docConfirm: this.state.value == 'docConfirm' ? 'Y' : '', // 医生确认,
                    chargeConfirm: this.state.value == 'chargeConfirm' ? 'Y' : '', // 财务结算
                    currentInHosp: this.state.value == 'currentInHosp' ? 'Y' : '', // 当前在院
                }],
                pagination: [{
                    pageSize: this.state.pageSize,
                    currentPage: this.state.page,
                    sortColumn: 'Date',
                    sortOrder: 'desc'
                }]
            };
            $http.post('urlS', this, {
                code: '0410003',
                data: data,
                success: function (res) {
                    if (res.errorCode == '0') {
                        this.setState({
                            allPatData: res.FileURL,
                            exportLoading: false,
                        }, () => {
                            // columns && columns.map((item, index) => {
                            //   if (item.title.props && item.title.props) {
                            //     columns[index].title = columns[index].title.props.children
                            //   }
                            // })
                            //请求
                            setTimeout(() => {
                                this.setState({
                                    exportLoading: false,
                                }, () => {
                                    this.downloadFile()
                                })
                                // handleExcel.exportExcel(columns, this.state.allPatData, '门诊日志表格')
                            }, 1000)
                        })
                    } else {
                        this.setState({
                            exportLoading: false,
                        })
                    }
                },
            })
        }

        downloadFile() {
            let windowHost = window.location && window.location.origin ? window.location.origin : (window.location && window.location.protocol ? (window.location.protocol + '//' + window.location.hostname) : '');
            try {
                var elemIF = document.createElement('iframe');
                elemIF.src = windowHost + this.state.allPatData;
                elemIF.style.display = 'none';
                document.body.appendChild(elemIF);
                // 防止下载两次
                setTimeout(function () {
                    document.body.removeChild(elemIF)
                }, 1000);
            } catch (e) {
                console.log(e);
            }
        }

        //查询出院患者
        handleQuery = () => {
            this.setState({ queryLoading: true });
            const formData = this.props.form.getFieldsValue();
            let data = {
                params: [{
                    hospID: user.hospID,
                    startDate: formData.startDate ? moment(formData.startDate).utcOffset(480).format('YYYY-MM-DD') : '',
                    stopDate: formData.stopDate ? moment(formData.stopDate).utcOffset(480).format('YYYY-MM-DD') : '',
                    patNo: formData.patNo,//登记号
                    patName: formData.patName,//登记号
                    patMedicalNo: formData.patMedicalNo,//住院号
                    admLocBedID: formData.admLocBedID,//床号
                    admReasonDesc: formData.admReasonDesc,//费别
                    admDocID: formData.admDocID,//管床医生
                    locID: formData.locID,//科室
                    wardID: formData.wardID,//病区
                    nurConfirm: this.state.value == 'nurConfirm' ? 'Y' : '', // 护士确认,
                    docConfirm: this.state.value == 'docConfirm' ? 'Y' : '', // 医生确认,
                    chargeConfirm: this.state.value == 'chargeConfirm' ? 'Y' : '', // 财务结算
                    currentInHosp: this.state.value == 'currentInHosp' ? 'Y' : '', // 当前在院
                }],
                pagination: [{
                    pageSize: this.state.pageSize,
                    currentPage: this.state.page,
                    sortColumn: 'Date',
                    sortOrder: 'desc'
                }]
            };
            $http.post('urlS', this, {
                code: '04100001',
                data: data,
                success: (res) => {
                    if (res.errorCode === '0') {
                        for (let index = 0; index < res.result.Data.length; index++) {
                            res.result.Data[index].key = index + 1;
                        }
                        this.setState({
                            total: res.result.TotalCount,
                            tableData: res.result.Data,
                            queryLoading: false
                        });
                        this.child.handleLoading();
                    } else {
                        this.setState({
                            total: 0,
                            tableData: [],
                            queryLoading: false
                        });
                        this.child.handleLoading();
                    }
                },
                error: function () {
                    this.setState({
                        queryLoading: false
                    });
                }
            });
            this.child.handleLoading();
        }

        // 调用公共组件的连接事件
        onRef = (ref) => {
            this.child = ref
        }

        // 提供修改page和pageSize的回调函数
        compilePage(page, pageSize) {
            // 修改page，或者pageSize
            this.setState({ page: page, pageSize: pageSize }, () => {
                // 重新调用查询方法
                this.handleQuery();
            })
        }

        handleStDateChange = (date, datetimeString) => {
            this.setState({
                startDate: datetimeString
            })
        }

        handleEndDateChange = (date, datetimeString) => {
            // console.log('结束时间1', datetimeString)
            this.setState({
                stopDate: datetimeString
            })
        }

        //登记号
        patNotEnter = (e) => {
            if (e.keyCode = '13') {
                this.setState({
                    patNo: ''
                }, () => {
                    this.handleQuery();
                })
            }
        }

        //住院号
        patMedicalNoEnter = (e) => {
            if (e.keyCode = '13') {
                this.setState({
                    patMedicalNo: ''
                }, () => {
                    this.handleQuery();
                })
            }
        }

        //姓名
        patNameEnter = (e) => {
            if (e.keyCode = '13') {
                this.setState({
                    patName: ''
                }, () => {
                    this.handleQuery();
                })
            }
        }

        checked = (e) => {
            this.setState({
                value: e.target.value,
            });
        };

        // 重置表单
        resetFields = () => {
            this.props.form.resetFields(); //清空所有
        };

        getLocList = (flag, locID) => {
            let linkFlag = '', docFlag = '';
            if (flag === 'locList') {
                linkFlag = '';
            } else {
                linkFlag = '1';
                docFlag = '1';
            }
            let data = {
                params: [{
                    type: 'I',
                    hospID: user.hospID,
                    locID: locID,
                    detailFlag: '',
                    linkFlag: linkFlag,
                    docFlag: docFlag,
                    linkType: 'W',
                }]
            }
            $http.post('urlDeault', this, {
                code: '04020008', data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        if (flag === 'locList') {
                            this.setState({
                                [flag]: res.result.Data,
                            })
                        } else {
                            if (res.result.Data.length > 0) {
                                this.setState({
                                    userInfo: res.result.Data[0].locDoctor,
                                    wardInfo: res.result.Data[0].linkLoc,
                                    [flag]: res.result.Data[0].linkLoc
                                }, () => {
                                    //清空form表单的值
                                    this.props.form.setFieldsValue({
                                        admDocID: '',
                                        wardID: '',
                                        admLocBedID: ''

                                    })
                                })
                            }
                        }
                    }
                }
            })
        }

        loadBedList = (wardID) => {
            let data = {
                params: [{
                    wardID: wardID,
                }]
            }
            $http.post('urlDeault', this, {
                code: '04090022',
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        this.setState({
                            wardBedAry: res.result.wardBedAry,//床号
                        }, () => {
                            //清空form表单的值
                            this.props.form.setFieldsValue({
                                admLocBedID: ''
                            })
                        })
                    }
                }
            })
        }

        //科室改变
        onInLocChange = (value, option) => {
            this.props.form.setFieldsValue({
                inWardID: undefined,
            });
            if (value) {
                this.getLocList('wardList', value);
            } else {
                this.getDepartmentInformation();
                this.props.form.setFieldsValue({
                    admDocID: '',
                    wardID: '',
                    admLocBedID: ''
                })
            }
        }

        //病区改变
        onInWardChange = (value, option) => {
            if (value) {
                this.loadBedList(value);
                // this.onInLocChange(value);
            } else {
                this.props.form.setFieldsValue({
                    admLocBedID: ''
                })
            }
        }

        //查询床位
        BedChange = (locID) => {
            let data = {
                params: [{
                    locID: locID,
                }]
            }
            $http.post('urlS', this, {
                code: '01050021',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({ selectData: res.result.Data })
                    } else {
                        message.error('查询失败：' + res.errorMessage);
                    }
                }
            })
        }

        //床位改变
        onLocBedChange = (value, option) => {
            if (value) {
                this.BedChange(value);
                // this.onInLocChange(value);
            }
        }

        //床位获取焦点
        onLocBedFocus = (flag, e) => {
            const locID = this.props.form.getFieldValue('inLocID');
            if (this.state.wardList.length === 0) {
                this.getLocList('wardList', locID);
            }
            let tips = 'tips' + this.firstToUp(flag);
            this.setState({
                [tips]: '',
            })
        }

        //科室获取焦点
        onLocFocus = () => {
            if (this.state.locList.length === 0) {
                this.getLocList('locList', '');
            }
            let tipsFlag = 'tips' + this.firstToUp('inLocID');
            this.setState({
                [tipsFlag]: '',
            })
        }
        //病区获取焦点
        onWardFocus = (flag, e) => {
            const locID = this.props.form.getFieldValue('inLocID');
            if ((this.state.wardList.length === 0) && (locID) && (locID !== '')) {
                this.getLocList('wardList', locID);
            }
            let tips = 'tips' + this.firstToUp(flag);
            this.setState({
                [tips]: '',
            })
        }

        //首字母大写
        firstToUp = (str) => {
            return str.substring(0, 1).toUpperCase() + str.substring(1);
        }

        onColumnRef = (ref) => {
            this.columnRef = ref;
        }

        //点击行
        onClickRowPublic = (record) => {
            return {
                onClick: () => {
                    let admID = '', patID = '';

                    if (this.state.admID != record.admID) {
                        admID = record.admID;
                        patID = record.patID;
                    }
                    this.setState({
                        admID: admID,
                    })
                    var patientData = {}
                    patientData = {
                        admID: admID,
                        patID: patID,
                    }
                    sessionStorage.setItem('patientData', JSON.stringify(patientData));
                },
            }
        }

        setRowClassNamePublic = (record) => {
            return record.admID == this.state.admID ? 'clickRowStyle' : '';
        };

        // 修改就诊数据
        handleModifyAdmInfo = record => {
            this.setState({ admInfoRowData: record }, () => {
                this.admInfoRef.modifyVisible(true);
            })
        };

        // 保存
        handleAdmInfoSave = async values => {
            try {
                let { admInfoRowData, categoryData } = this.state;
                let data = {
                    params: [{
                        admID: admInfoRowData?.admID || '',
                        patID: admInfoRowData?.patID || '',
                        ...values
                    }]
                }
                let res = await React.$asyncPost(this, categoryData?.saveCode || '03030116', data);
                message.success(res.errorMessage ? res.errorMessage : '保存成功');
                this.setState({ admInfoRowData: {} });
                this.admInfoRef.modifyVisible(false, 'Y');
                this.handleQuery();
            } catch (error) {
                console.log(error)
            }
        }

        render() {
            const { admInfoFormData, admInfoSelectData, admInfoRowData, queryLoading, categoryData, columns } = this.state;
            const formItemInput = {
                labelCol: { span: 8 },
                wrapperCol: { span: 16 },
            };
            const formItemLayout = {    // label 和input宽度
                labelCol: { span: 10 },
                wrapperCol: { span: 14 },
            };
            const { getFieldDecorator } = this.props.form;
            const consultationInfo = this.state.consultationInfo;
            // 列表操作
            const operationObj = {
                width: 110,
                title: '操作',
                align: 'center',
                fixed: 'right',
                key: 'operation',
                render: (text, record) => (
                    <span className={record?.admID ? 'span' : 'common-color999'} onClick={record?.admID ? (e) => this.handleModifyAdmInfo(record, e) : null}>{categoryData?.modifyAmdModalTitle || '修改就诊数据'}</span>
                ),
            };
            // 组件所需参数
            const param = {
                // 表头配置
                isOnRow: true,
                isOnHeadRow: true,
                rowClassName: true,
                columns: categoryData?.saveCode ? [...columns, operationObj] : columns,
                // 表格数据state
                data: this.state.tableData,
                // 数据总条数
                total: this.state.total,
                // 当前页数
                loading: queryLoading,
                page: this.state.page,
                x: this.state.tableWidth,
                y: store.getState().tableHeight.y - 10,
                height: store.getState().tableHeight.y + 40 + 'px',
            }
            return (
                <Spin tip="加载中..." spinning={this.state.showLoading} className="department" >
                    <div style={{ width: '100%', height: '100%' }} >
                        <ColumnAuthoritysModel
                            clientWidth='800px'
                            compontName="OutPatientQuery"
                            configType="C"
                            onRef={this.onColumnRef}
                            reloadData={this.loadColumn}
                        />
                        <div style={{ paddingTop: '12px' }} className="department-header">
                            <Form>
                                <Row>
                                    <Col span={18} className="top-form">
                                        <Row style={{ padding: '0 20px' }}>
                                            <Col span={4}>
                                                <Form.Item label="开始日期：" {...formItemInput}>
                                                    {getFieldDecorator('startDate', {
                                                        initialValue: moment(new Date(), 'YYYY-MM-DD'),
                                                    })(

                                                        <DatePicker style={{ width: '100%' }} disabledDate={(curDate) => {
                                                            return curDate && curDate > moment().endOf('day');
                                                        }} />
                                                    )}
                                                </Form.Item>
                                            </Col>
                                            <Col span={4}>
                                                <Form.Item label="登记号：" {...formItemInput}>
                                                    {getFieldDecorator('patNo', {
                                                        initialValue: undefined,
                                                        rules: [{ required: false, message: '请输入登记号' }]
                                                    })(
                                                        <Input onPressEnter={this.patNotEnter} />
                                                    )}
                                                </Form.Item>
                                            </Col>
                                            <Col span={4}>
                                                <Form.Item {...formItemLayout} label="住院号">
                                                    {getFieldDecorator('patMedicalNo', {
                                                        initialValue: undefined,
                                                        rules: [{ required: false, message: '请输入住院号' }]
                                                    })(
                                                        <Input onPressEnter={this.patMedicalNoEnter} />
                                                    )}
                                                </Form.Item>
                                            </Col>
                                            <Col span={4}>
                                                <Form.Item {...formItemLayout} label="科室">
                                                    {getFieldDecorator('locID', {
                                                        initialValue: consultationInfo.locID ? consultationInfo.locID : this.state.defaultLocID,
                                                    })(
                                                        <Select
                                                            allowClear
                                                            showSearch
                                                            optionFilterProp='role'
                                                            onFocus={this.onLocFocus}
                                                            onChange={this.onInLocChange}
                                                        >
                                                            {this.state.locInfo.map(data => (
                                                                <Select.Option role={data.descripts + '^' + data.descriptsSPCode} key={data.id}>{data.descripts}</Select.Option>
                                                            ))}
                                                        </Select>
                                                    )}
                                                </Form.Item>
                                            </Col>
                                            <Col span={4}>
                                                <Form.Item {...formItemLayout} label="管床医生">
                                                    {getFieldDecorator('admDocID', {
                                                        initialValue: consultationInfo.admDocID ? consultationInfo.admDocID : "",
                                                    })(
                                                        <Select
                                                            allowClear
                                                            showSearch
                                                            optionFilterProp='role'
                                                            onFocus={this.onWardFocus.bind(this, "mainDocID")}
                                                        >
                                                            {this.state.userInfo.map(data => (
                                                                <Select.Option role={data.descripts + '^' + data.descriptsSPCode} key={data.id}>{data.descripts}</Select.Option>
                                                            ))}
                                                        </Select>
                                                    )}
                                                </Form.Item>
                                            </Col>
                                            <Col span={4}>
                                                <Radio.Group onChange={this.checked} value={this.state.value} style={{ position: "absolute", right: "0" }}>
                                                    <div style={{ marginBottom: "-26px", height: "88px", paddingTop: "9px" }}>
                                                        <Radio value="nurConfirm">护士确认</Radio>
                                                        <Radio value="docConfirm">医生确认</Radio>
                                                    </div>
                                                    <Radio value="chargeConfirm">财务结算</Radio>
                                                    <Radio value="currentInHosp">当前在院</Radio>
                                                </Radio.Group>
                                            </Col>
                                        </Row>
                                        <Row style={{ padding: '0 24px' }}>
                                            <Col span={4}>
                                                <Form.Item label="结束日期：" {...formItemInput}>
                                                    {getFieldDecorator('stopDate', {
                                                        initialValue: moment(new Date(), 'YYYY-MM-DD'),
                                                    })(
                                                        <DatePicker style={{ width: '100%' }} disabledDate={(curDate) => {
                                                            return curDate && curDate > moment().endOf('day');
                                                        }} />
                                                    )}
                                                </Form.Item>
                                            </Col>
                                            <Col span={4}>
                                                <Form.Item label="姓名：" {...formItemInput}>
                                                    {getFieldDecorator('patName', {
                                                        initialValue: undefined,
                                                        rules: [{ required: false, message: '请输入姓名' }]
                                                    })(
                                                        <Input onPressEnter={this.patNameEnter} />
                                                    )}

                                                </Form.Item>
                                            </Col>
                                            <Col span={4}>
                                                <Form.Item {...formItemLayout} label="费别">
                                                    {getFieldDecorator('admReasonDesc', {
                                                        initialValue: consultationInfo.admReasonDesc ? consultationInfo.admReasonDesc : "",
                                                    })(
                                                        <Select
                                                            allowClear
                                                            showSearch
                                                            optionFilterProp='role'
                                                        >
                                                            {this.state.admReason.map(data => (
                                                                <Select.Option role={data.descripts + '^' + data.descriptsSPCode} key={data.id}>{data.descripts}</Select.Option>
                                                            ))}
                                                        </Select>
                                                    )}
                                                </Form.Item>

                                            </Col>
                                            <Col span={4}>
                                                <Form.Item {...formItemLayout} label="病区">
                                                    {getFieldDecorator('wardID', {
                                                        initialValue: consultationInfo.wardID ? consultationInfo.wardID : this.state.defaultWardID,
                                                    })(
                                                        <Select
                                                            allowClear
                                                            showSearch
                                                            optionFilterProp='role'
                                                            onFocus={this.onWardFocus.bind(this, "inWardID")}
                                                            onChange={this.onInWardChange}
                                                        >
                                                            {this.state.wardInfo.map(data => (
                                                                <Select.Option role={data.descripts + '^' + data.descriptsSPCode} key={data.id}>{data.descripts}</Select.Option>
                                                            ))}
                                                        </Select>
                                                    )}
                                                </Form.Item>

                                            </Col>
                                            <Col span={4}>
                                                <Form.Item {...formItemLayout} label="床号">
                                                    {getFieldDecorator('admLocBedID', {
                                                        initialValue: consultationInfo.admLocBedID ? consultationInfo.admLocBedID : "",
                                                    })(
                                                        <Select
                                                            allowClear
                                                            showSearch
                                                            optionFilterProp='role'
                                                            onChange={this.onLocBedChange}
                                                        >
                                                            {this.state.wardBedAry.map(data => (
                                                                <Select.Option role={data.descripts + '^' + data.descriptsSPCode} key={data.id}>{data.descripts}</Select.Option>
                                                            ))}
                                                        </Select>
                                                    )}
                                                </Form.Item>

                                            </Col>

                                        </Row>
                                    </Col>
                                    <Col span={5} style={{ marginLeft: '33px' }}>
                                        <Row style={{ marginBottom: '12px', marginTop: '5px' }}>
                                            <Button type="primary" onClick={this.handleQuery} style={{ marginRight: '30px' }}>查询</Button>
                                            <Button style={{ marginRight: '30px' }} onClick={this.resetFields}>清屏</Button>
                                        </Row>
                                    </Col>
                                    <Col span={5} style={{ marginLeft: '33px' }}>
                                        <Row style={{ marginTop: '5px' }}>
                                            <Button type="primary" style={{ marginRight: '30px' }} disabled={Util.isEmpty(this.state.tableData)} loading={this.state.loading}
                                                onClick={this.exportData}>导出</Button>
                                            {/* <Button style={{marginRight: '30px'}} onClick={this.resetFields}>费用明细</Button> */}
                                        </Row>
                                    </Col>
                                </Row>
                            </Form>
                        </div>
                        <div className="common-query-split-line" style={{ height: 8 }}></div>
                        <div className="table-body-height" style={{ padding: '20px 20px 0 20px' }}>
                            {/* handelThis将夫组件的属性与方法给子组件访问 */}
                            <PubilcTablePagination
                                param={param}
                                setRowClassNamePublic={this.setRowClassNamePublic}
                                onClickRowPublic={this.onClickRowPublic}
                                onClickHeadRowPublic={() => {
                                    return {
                                        onDoubleClick: () => {
                                            this.columnRef.onOpenModel();
                                        },
                                    };
                                }}
                                handelThis={this}
                                onRef={this.onRef}
                            />
                        </div>

                        {/* 修改责任医生和责任护士 */}
                        <PublicModalFormHooks
                            idField="admID"
                            width={categoryData?.modifyAmdModalWidth || '520px'}
                            title={categoryData?.modifyAmdModalTitle || '修改就诊数据'}
                            onRef={ref => this.admInfoRef = ref}
                            selectData={admInfoSelectData}
                            formData={admInfoFormData}
                            rowData={admInfoRowData}
                            handleSave={this.handleAdmInfoSave}
                        />
                    </div>
                </Spin>
            )
        }
    }
)
export default OutPatientQuery;
