/**
 *居民健康管理

 */
import React from 'react';
import {
    Card, Table, Input, Form, Select, Row, Col, Checkbox, Tabs,
    DatePicker, Button, Popconfirm, Icon, Divider, message, Cascader,
} from 'antd';
import { Util, dayFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import RangeDatePicker from 'components/rangePicker/index';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import ShowInformationModal from './component/ShowInformationModal';
import ShowQueryAdvancedModal from './component/ShowQueryAdvancedModal';
import ShowPeddingExceptionModal from './component/ShowPeddingExceptionModal';
import ShowConsultationModal from './component/ShowConsultationModal';
import { handleExcel } from 'tools/handleExcel.js';
import ShowToDealWithTodayModal from './component/ShowToDealWithTodayModal';
import ShowImportModal from './component/ShowImportModal';
import ShowSendGroupModal from './component/ShowSendGroupModal';
import { PAGE_NUM_MORE_STATUS } from 'tools/statusConstants';
import CommonPagination from 'components/pagination/index';
import store from 'store';
import moment from 'moment';
import './style/index.less';

const { RangePicker } = DatePicker;
const Option = Select.Option;
const Search = Input.Search;
class HealthControlPage extends React.Component {
    constructor(props) {
        super(props)
        var userData = JSON.parse(sessionStorage.getItem('userData'))
        this.state = {
            dataSource: [],
            total: 0,
            page: 1,
            pageSize: 10,
            size: 'small',
            curPageDetail: PAGE_NUM_MORE_STATUS[0].code,
            userData: userData,
            ids: [],
            searchBase: true,
            originColumn:[]
        }
    }

    componentDidMount() {
        this.initData()
        this.loadData(1)
        this.loadCardType()
        this.loadSelectData()
        this.loadContractStatus()
        this.loadTotalCount()//统计
        this.loadDiseaseType()//疾病类型
        document.querySelector('.ant-table-body').style.height = store.getState().tableHeight.y - 100 + 'px'
    }

    loadData(page, pageSize, e) {
        this.setState({
            searchBase: true,
            dataSource: []
        })
        var date = new Date();
        var params = {
            params: [{
                userID: this.state.userData.userID,
                hospID: this.state.userData.hospID,
                locID: this.state.userData.locID,
                cardTypeID: this.state.patCardTypeID ? this.state.patCardTypeID : (this.state.cardStatus),
                cardNo: this.state.cardNo,
                number: this.state.number,
                address: this.state.address,
                signStatusID: this.state.signStatusID,
                diseaseID: this.state.diseaseID,
                sexID: this.state.sexID,
                ageFrom: this.state.ageFrom,
                ageTo: this.state.ageTo,
                dateFrom: this.state.regDateFrom ? this.state.regDateFrom : '',
                dateTo: this.state.regDateTo ? this.state.regDateTo : '',
            }],
            pagination: [{
                pageSize: this.state.size == 'small' ? this.state.pageSize : PAGE_NUM_MORE_STATUS[0].code,
                currentPage: page,
                sortColumn: this.state.sortColumn,
                sortOrder: this.state.sortOrder,
                
            }]
        }
        $http.post('urlDeault', this, {
            code: "03070034",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        dataSource: res.result.data,
                        total: res.result.totalCount,
                        page: page,
                        search: 'search',
                        // column:this.state.originColumn,
                    })

                }
            }
        });
    }

    loadDiseaseType() {
        var params = {
            params: [{}]
        }
        $http.post('urlDeault', this, {
            code: "03070018",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        diseaseType: res.result.fatherArr,
                    })
                }
            }
        });
    }

    loadSelectData() {
        var params = {
            params: [{
                logonHospID: this.state.userData.hospID,
                logonGroupID: this.state.userData.groupID,
                sexFlag: 'Y'
            }]
        }
        $http.post('urlDeault', this, {
            code: "03010037",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        sex: res.result.sex,
                    })
                }
            }
        });
    }

    loadContractStatus() {
        var params = {
            params: [{}]
        }
        $http.post('urlDeault', this, {
            code: "03070017",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        contractData: res.result,
                    })
                }
            }
        });
    }

    loadTotalCount() {
        var params = {
            params: [{
                doctorID: this.state.userData.userID,
                hospID: this.state.userData.hospID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03070006",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        totalCount: res.result.data,
                    })
                }
            }
        });
    }
    //数组对象去重
     deWeightThree = (allColumns) => {
        let dataIndex = 'dataIndex';
        let map = new Map();
        for (let item of allColumns) {
            if (!map.has(item.dataIndex)) {
                map.set(item.dataIndex, item);
            }
        }
        return [...map.values()];
    }
    //高级查询条件检索
    handleMaxSearch = (data, totalCount, titleData) => {
        // console.log("originDynColumns",originDynColumns)
        let totalWidth = 0
        let allColumns = [...this.state.originColumn]
        titleData&&titleData.map((item,i)=>{
            allColumns.push(item)
        }) 
        this.setState({
            dataSource: [],
            total: totalCount,
            page: this.state.page,
            pageSize: this.state.pageSize,
            search: ''
        }, () => {
            let arr = this.deWeightThree(allColumns)
            arr&&arr.map((j,index)=>{
                totalWidth += j.width
            })
            this.setState({
                dataSource: data,
                column:arr ,
                totalWidth:totalWidth+"px",
                exportColumn:arr,
            },()=>{
                console.log("colum---",this.state.column,totalWidth)
                // console.log("this.state.originColumn",this.state.originColumn)
            })
            // this.setState({
            //     column: dynColumns,
            //     exportColumn:columns,
            //     totalWidth: res.totalWidth
            // })
        })
    }
    onQuery = (ref) => {
        this.onQueryChild = ref
    }

    handleSortData(name, type, sortColumn, sortOrder) {
        this.setState({
            [name]: type,
            sortColumn: sortColumn,
            sortOrder: sortOrder,
        }, () => {
            this.initData()
            this.loadData()
        })
    }

    initData() {
        // var date = new Date();
        let data = {
            params: [{
                compontName: "HealthControlPage",
                type: "C",
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040073",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    var columns = res.result.C;
                    var dynColumns = []
                    for (var i = 0; i < columns.length; i++) {
                        if (columns[i].dataIndex == 'signStatus') {
                            dynColumns.push({
                                title: this.state.downType == 'caret-down' ?
                                    <span style={{ cursor: 'pointer' }}
                                        onClick={this.handleSortData.bind(this, 'downType', 'caret-up', 'signStatus', 'desc')}>
                                        {columns[i].title}<Icon type="caret-down" theme="filled" style={{ cursor: 'pointer', marginLeft: 5 }} />
                                    </span> :
                                    <span style={{ cursor: 'pointer' }} onClick={this.handleSortData.bind(this, 'downType', 'caret-down', 'signStatus', 'asc')} >
                                        {columns[i].title}<Icon type="caret-up" theme="filled" style={{ cursor: 'pointer', marginLeft: 5 }} />
                                    </span>,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data) => {
                                    return <span style={{ color: data.signStatusCode == 'Y' ? '#1999db' : '#fa541c' }}>{data.signStatus}</span>
                                }
                            })
                        } else if (columns[i].dataIndex == 'patSexDesc') {
                            dynColumns.push({
                                title: this.state.downSexType == 'caret-down' ?
                                    <span style={{ cursor: 'pointer' }}
                                        onClick={this.handleSortData.bind(this, 'downSexType', 'caret-up', 'patSexDesc', 'desc')}>
                                        {columns[i].title}<Icon type="caret-down" theme="filled" style={{ cursor: 'pointer', marginLeft: 5 }} />
                                    </span> :
                                    <span style={{ cursor: 'pointer' }} onClick={this.handleSortData.bind(this, 'downSexType', 'caret-down', 'patSexDesc', 'asc')} >
                                        {columns[i].title}<Icon type="caret-up" theme="filled" style={{ cursor: 'pointer', marginLeft: 5 }} />
                                    </span>,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                            })
                        } else if (columns[i].dataIndex == 'patAge') {
                            dynColumns.push({
                                title: this.state.downAgeType == 'caret-down' ?
                                    <span style={{ cursor: 'pointer' }}
                                        onClick={this.handleSortData.bind(this, 'downAgeType', 'caret-up', 'patAge', 'desc')}>
                                        {columns[i].title}<Icon type="caret-down" theme="filled" style={{ cursor: 'pointer', marginLeft: 5 }} />
                                    </span> :
                                    <span style={{ cursor: 'pointer' }} onClick={this.handleSortData.bind(this, 'downAgeType', 'caret-down', 'patAge', 'asc')} >
                                        {columns[i].title}<Icon type="caret-up" theme="filled" style={{ cursor: 'pointer', marginLeft: 5 }} />
                                    </span>,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                            })
                        } else {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                            })
                        }
                    }
                    this.setState({
                        originColumn: dynColumns,
                        column: dynColumns,
                        exportColumn:columns,
                        totalWidth: res.totalWidth
                    })
                    this.props.hanlderThis.setState({
                        reload: false,
                    })
                }
            }
        })
    }


    //获取卡类型
    loadCardType() {
        var params = {
            params: [{
                cardTypeFlag: '1',//卡类型
                patTypeFlag: '1',
            }]
        }
        $http.post('urlDeault', this, {
            code: "03030005",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    var cardStatus = ''
                    var replaceZero = ''
                    var cardLength = 0
                    var readMode = ''
                    if (res.cardType && res.cardType.length > 0) {
                        var cardType = res.cardType;
                        for (var i = 0; i < cardType.length; i++) {
                            if (cardType[i].defaultFlag == 'Y') {
                                cardStatus = cardType[i].id,
                                    replaceZero = cardType[i].replenishZero
                                cardLength = cardType[i].cardLength
                                readMode = cardType[i].readMode
                            }
                        }
                    }
                    this.setState({
                        cardTypeData: res.cardType,
                        credTypeData: res.credType,
                        patTypeData: res.patType,
                        sexData: res.sex,
                        socialStatusData: res.patSocialStatusDesc,
                        cardStatus: cardStatus,
                        readMode: readMode,
                        cardLength: cardLength,
                        replaceZero: replaceZero,
                    })
                }
            }
        });
    }

    //切换卡类型
    changeCardType(name, e) {
        var { cardTypeData } = this.state;
        for (var i = 0; i < cardTypeData.length; i++) {
            if (e == cardTypeData[i].id) {
                this.setState({
                    cardLength: cardTypeData[i].cardLength,
                    replaceZero: cardTypeData[i].replenishZero,
                    cardTypeId: cardTypeData[i].id,
                    readMode: cardTypeData[i].readMode,
                    [name]: e,
                    inputStatus: true
                })
            }
        }
    }

    loadEnterData(page, e) {
        if (e.keyCode == '13') {
            this.setState({//自动补0，渲染到组件中
                cardNo: this.state.replaceZero == 'Y' ? (Array(parseInt(this.state.cardLength)).join(0) + this.state.cardNo).slice(-parseInt(this.state.cardLength)) : this.state.cardNo
            })
        }
    }

    handleReadCard() {
        var cardType = this.state.carTypeDr ? this.state.carTypeDr : (this.state.cardStatus);
        this.readCard.ReadCard(cardType, "R", (json) => {
            this.setState({ readPatID: json && json.patInfo ? json.patInfo.patID : '', patCardNo: json.cardNo, readStatus: 'read' }, () => {
                this.loadData()
            })
        })
    }

    startChange(date) {
        this.setState({
            regDateFrom: date,
        })
    }

    endChange(date) {
        this.setState({
            regDateTo: date,
        })
    }

    loadStartDate() {
        var date = new Date()
        this.setState({
            regDateFrom: moment(date).startOf('year').format(dayFormat),
            regDateTo: moment(date).endOf('year').format(dayFormat),
        })
    }

    loadLastDate() {
        var date = new Date()
        this.setState({
            regDateFrom: this.state.regDateFrom ?
                moment(this.state.regDateFrom).add(-1, 'y').startOf('year').format(dayFormat) : moment(date).add(-1, 'y').startOf('year').format(dayFormat),
            regDateTo: this.state.regDateTo ?
                moment(this.state.regDateTo).add(-1, 'y').endOf('year').format(dayFormat) : moment(date).add(-1, 'y').endOf('year').format(dayFormat)
        })
    }

    //分页切换
    onChange(e) {
        this.setState({ page: e }, () => {
            // console.log("page----", e)
            if (this.state.searchBase) {
                this.loadData(e);
            } else {
                this.onQueryChild.onSubmit()
            }

        });
    }

    //分页切换
    changePageSize(current, pageSize) {
        this.setState({ pageSize: pageSize, page: current }, () => {
            if (this.state.searchBase) {
                this.loadData(current, pageSize, 'search');
            } else {
                this.onQueryChild.onSubmit()
            }
        });
    }

    handleComponent = (refs) => {
        this.componentRef = refs
    }

    //点击行，渲染当前行样式
    onClickRow = (record) => {
        return {
            onDoubleClick: () => {
                this.loadPersonMessage(record)
            },
            onClick: () => {
                sessionStorage.setItem('patID', JSON.stringify(record.patID))
                if (!Util.isEmpty(this.state.patID) && this.state.patID == record.patID) {
                    this.setState({
                        patID: ''
                    });
                } else {
                    this.setState({
                        patID: record.patID
                    });
                }

            }
        };
    }

    //点击行，渲染当前行样式 
    setRowClassName = (record) => {
        return record.patID === this.state.patID ? 'clickRowStyle' : '';
    }

    loadPersonMessage() {
        this.props.history.push('./09090003')
    }

    handleShowInformationModal() {
        this.setState({
            patID: '',
            isShowInformationModal: true
        })
    }

    //编辑
    editInformationModal() {
        var params = {
            params: [{
                patID: this.state.patID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03070019",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    var source = res.result[0];
                    var editData = {}
                    editData = {
                        patName: source.personInfo && source.personInfo.patName,
                        patSexID: source.personInfo && source.personInfo.patSexID,
                        patAge: source.personInfo && source.personInfo.patAge,
                        patCredTypeID: source.personInfo && source.personInfo.patCredTypeID,
                        patCredNo: source.personInfo && source.personInfo.patCredNo,
                        patBirthDate: source.personInfo && source.personInfo.patBirthDate,
                        patNationID: source.personInfo && source.personInfo.patNationID,
                        patMobile: source.personInfo && source.personInfo.patMobile,
                        patCityID: source.personInfo && source.personInfo.nativeCityID,
                        patAreaID: source.personInfo && source.personInfo.nativeAreaID,
                        patAddress: source.personInfo && source.personInfo.nativeAddress,
                        patVillageID: source.personInfo && source.personInfo.nativeVillageID,
                        patProvinceID: source.personInfo && source.personInfo.nativeProvinceID,
                        receiveCityID: source.personInfo && source.personInfo.presentCityID,
                        receiveAreaID: source.personInfo && source.personInfo.presentAreaID,
                        receiveVillageID: source.personInfo && source.personInfo.presentVillageID,
                        receiveProvinceID: source.personInfo && source.personInfo.presentProvinceID,
                        receiveAddress: source.personInfo && source.personInfo.presentAddress,
                        patMaritalID: source.personInfo && source.personInfo.patMaritalID ? parseInt(source.personInfo.patMaritalID) : '',
                        patEduID: source.personInfo && source.personInfo.patEduID ? parseInt(source.personInfo.patEduID) : '',
                        patOccupationID: source.personInfo && source.personInfo.patOccupationID ? parseInt(source.personInfo.patOccupationID) : '',
                        patCompany: source.personInfo && source.personInfo.patCompany,
                        payWayID: source.personInfo && source.personInfo.payWayID,
                        patInsuNo: source.personInfo && source.personInfo.patInsuNo,
                        healthRecord: source.ohterInfo && source.ohterInfo.healthRecord,
                        signHospID: source.ohterInfo && source.ohterInfo.signHospID,
                        radioCode: source.ohterInfo && source.ohterInfo.healthRecordCode,
                        signDoctorID: source.ohterInfo && source.ohterInfo.signDoctorID,
                        family: source.familyInfo && source.familyInfo,
                    }
                    this.setState({
                        editData: editData,
                        isShowInformationModal: true
                    }, () => {
                        //处理联动数据
                        this.ChildPage.getProviceOther(this.state.editData && this.state.editData.patProvinceID)
                        this.ChildPage.getAreas(this.state.editData && this.state.editData.patCityID)
                        this.ChildPage.getVillages(this.state.editData && this.state.editData.patAreaID)
                        this.ChildPage.getProviceOtherNow(this.state.editData && this.state.editData.receiveProvinceID)
                        this.ChildPage.getVillagesNow(this.state.editData && this.state.editData.receiveAreaID)
                        this.ChildPage.getAreasNow(this.state.editData && this.state.editData.receiveCityID)
                        this.ChildPage.loadDoctorData(this.state.editData && this.state.editData.signHospID)
                    })
                }
            }
        });
    }

    hideModal(name) {
        this.setState({
            [name]: false,
            editData: {}
        })
    }
    hideImportModal(name) {
        this.setState({
            [name]: false,
        }, () => {
            this.loadData()
        })
    }

    hideModals(name) {
        this.setState({
            [name]: false,
            editData: {}
        }, () => {
            this.loadTotalCount()
        })
    }

    //高级查询弹框
    handleAdvanceQuery() {
        this.setState({
            isShowQueryAdvancedModal: true
        })
    }
    closeIsShowQueryAdvancedModal=()=>{
        this.setState({
            isShowQueryAdvancedModal: false
        }) 
    }

    //待处理异常
    handlePeddingExceptionModal() {
        this.setState({
            isShowPeddingExceptionModal: true
        })
    }

    //待处理咨询
    handleConsultationModal() {
        this.setState({
            isShowConsultationModal: true
        })
    }

    //今日待办弹框
    handleToDealWithModal() {
        this.setState({
            isShowToDealWithTodayModal: true
        })
    }

    //级联选择
    onChangeDisease(e, selectedOptions) {
        if (selectedOptions.length > 1) {
            this.setState({
                diseaseID: selectedOptions[1].id
            });
        } else if (selectedOptions.length === 1) {
            this.setState({
                diseaseID: selectedOptions[0].id
            });
        }
        else {
            this.setState({
                diseaseID: ''
            });
        }
    }

    //导出
    onExportData() {
        var params = {
            params: [{
                userID: this.state.userData.userID,
                hospID: this.state.userData.hospID,
                locID: this.state.userData.locID,
                cardTypeID: this.state.patCardTypeID ? this.state.patCardTypeID : (this.state.cardStatus),
                cardNo: this.state.patCardNo,
                number: this.state.number,
                address: this.state.address,
                signStatusID: this.state.signStatusID,
                diseaseID: this.state.diseaseID,
                sexID: this.state.sexID,
                ageFrom: this.state.ageFrom,
                ageTo: this.state.ageTo,
                dateFrom: this.state.regDateFrom ? this.state.regDateFrom : '',
                dateTo: this.state.regDateTo ? this.state.regDateTo : '',
            }]
        }
        $http.post('urlDeault', this, {
            code: "03070034",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        exportData: res.result.data,
                    }, () => {
                        handleExcel.exportExcel(this.state.exportColumn, this.state.exportData, '患者列表')
                        message.success('导出成功！')
                    })
                }
            }
        });
    }

    handleSubmitInformation(params) {
        var params = {
            params: [params]
        }
        $http.post('urlDeault', this, {
            code: "03070031",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    message.success('操作成功')
                    this.hideModal('isShowInformationModal')
                    this.loadData(1)
                }
            }
        });
    }

    onRef = (ref) => {
        this.ChildPage = ref
    }

    onSelectChange(ids, selectData) {
        this.setState({
            ids: ids,
            selectData: selectData
        })
    }

    //动态表头
    onColumnRef = (ref) => {
        this.columnRef = ref;
    }

    //群发
    showSendGroupModal() {
        this.setState({
            isShowSendGroupModal: true
        })
    }

    //群发内容
    handleSendGroupMessage(id, consultText) {
        var params = {
            params: [{
                signRecordID: this.state.signRecordID || '1',
                consultText: consultText,
                createUserID: this.state.userData.userID,
                receiveValue: [id],
                receiveType: '2',
                sendType: '1',
                sendValue: this.state.userData.userID,
            }]
        }
        $http.post('urlDeault', this, {
            code: "03070010",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.loadData(1)
                    this.hideModal('isShowSendGroupModal')
                    this.setState({
                        ids: []
                    })
                }
            }
        });
    }

    loadAllData(e) {
        if (e.keyCode == '13') {
            this.loadData(1)
        }
    }

    //整数校验
    commonInputChangeAge(name, e) {
        var value = e.target.value;
        if (!(/(^[0-9]\d*$)/.test(value)) && value.length > 0) {
            return
        }
        this.setState({
            [name]: value
        })
    }

    showImportModal() {
        this.setState({
            isShowImportModal: true
        })
    }
    //改变搜索方式
    changeSearch = () => {
        this.setState({
            searchBase: false
        })
    }
    //点击普通条件查询 重置column
    loadInitData=()=>{
        this.initData()
        this.loadData( '1')
    }
    render() {
        var { sex, diseaseType, contractData, ids } = this.state;

        const rowSelection = {
            ids,
            onChange: this.onSelectChange.bind(this),
            selectedRowKeys: ids,
        }

        //卡类型
        let cardTypeOption = []
        this.state.cardTypeData && this.state.cardTypeData.map((item, index) => {
            cardTypeOption.push(<Option key={index} value={item.id} code={item.descriptsSPCode}>{item.descripts}</Option>)
        })

        //性别
        var sexOption = []
        sex && sex.map((item, index) => {
            sexOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
        })
        //疾病类型
        var diseaseTypeOption = []
        diseaseType && diseaseType.map((item, index) => {
            diseaseTypeOption.push(<Option key={index} value={item.id} name={item.descriptsSPCode}
                code={item.descripts}>{item.descripts}</Option>)
        })
        //签约状态
        var contractDataOption = []
        contractData && contractData.map((item, index) => {
            contractDataOption.push(<Option key={index} value={item.id} name={item.descriptsSPCode}
                code={item.descripts}>{item.descripts}</Option>)
        })

        return <div className='health-control-body'>
            <ColumnAuthoritysModel
                clientWidth='800px'
                compontName="HealthControlPage"
                configType="C"
                onRef={this.onColumnRef}
                reloadData={this.initData}
            />

            {/**基本信息采集 */}
            < ShowInformationModal isShow={this.state.isShowInformationModal}
                onRef={this.onRef}
                onSubmit={this.handleSubmitInformation.bind(this)}
                patID={this.state.patID}
                {...this.state.editData}
                localProvince={this.state.localProvince}
                localProvinceNow={this.state.localProvinceNow}
                areaData={this.state.areaData}
                areaDataNow={this.state.areaDataNow}
                villageDataNow={this.state.villageDataNow}
                villageData={this.state.villageData}
                localCity={this.state.localCity}
                localCityNow={this.state.localCityNow}
                doctorData={this.state.doctorData}
                radioCode={this.state.editData && this.state.editData.radioCode}
                onHide={this.hideModal.bind(this, 'isShowInformationModal')}>
            </ShowInformationModal>

            {/**高级查询 */}
            <ShowQueryAdvancedModal handleMaxSearch={this.handleMaxSearch} onQuery={this.onQuery} searchBase={this.state.searchBase} changeSearch={this.changeSearch} size={this.state.pageSize} page={this.state.page} closeIsShowQueryAdvancedModal={this.closeIsShowQueryAdvancedModal} isShow={this.state.isShowQueryAdvancedModal}
                onHide={this.hideModal.bind(this, 'isShowQueryAdvancedModal')}>
            </ShowQueryAdvancedModal>

            {/**待处理异常 */}
            <ShowPeddingExceptionModal isShow={this.state.isShowPeddingExceptionModal}
                onHide={this.hideModals.bind(this, 'isShowPeddingExceptionModal')}>
            </ShowPeddingExceptionModal>

            {/**待处理咨询 */}
            <ShowConsultationModal isShow={this.state.isShowConsultationModal}
                onHide={this.hideModals.bind(this, 'isShowConsultationModal')}>
            </ShowConsultationModal>

            {/**今日待办 */}
            <ShowToDealWithTodayModal isShow={this.state.isShowToDealWithTodayModal}
                today={true}
                onHide={this.hideModals.bind(this, 'isShowToDealWithTodayModal')}>
            </ShowToDealWithTodayModal>

            {/**群发 */}
            <ShowSendGroupModal isShow={this.state.isShowSendGroupModal}
                ids={this.state.ids}
                selectData={this.state.selectData}
                onSubmit={this.handleSendGroupMessage.bind(this)}
                onHide={this.hideModal.bind(this, 'isShowSendGroupModal')}>
            </ShowSendGroupModal>

            {/**is导入 */}
            <ShowImportModal isShow={this.state.isShowImportModal}
                onHide={this.hideImportModal.bind(this, 'isShowImportModal')}>
            </ShowImportModal>

            <div style={{ height: '10%', display: 'flex' }}>
                <Card style={{ height: '100%', width: '19.5%', marginLeft: 8 }}>
                    <div className='splice-cumulative' style={{ float: 'left' }}></div><Divider type="vertical" style={{ marginLeft: '10%', height: 80 }} />
                    <div style={{ float: 'right', marginRight: '10%', marginTop: '13%', fontWeight: 'bold', color: '#333333' }}>人</div>
                    <div style={{ marginRight: '13%', float: 'right', marginTop: 10 }}>
                        <div style={{ fontSize: '16px', fontWeight: 'bold', color: '#333333' }}>累计服务：</div>
                        <div style={{ marginTop: 10 }}><span style={{ fontSize: '20px', fontWeight: 'bold' }}>
                            {!Util.isEmpty(this.state.totalCount) ? this.state.totalCount[0].cumulative : 0}</span>&nbsp;
                        </div>
                    </div>
                </Card>
                <Card style={{ height: '100%', width: '19.5%', marginLeft: 8 }}>
                    <div className='splice-inService' style={{ float: 'left' }}></div><Divider type="vertical" style={{ marginLeft: '10%', height: 80 }} />
                    <div style={{ float: 'right', marginRight: '10%', marginTop: '13%', fontWeight: 'bold', color: '#333333' }}>人</div>
                    <div style={{ marginRight: '17%', float: 'right', marginTop: 10 }}>
                        <div style={{ fontSize: '16px', fontWeight: 'bold', color: '#333333' }}>服务中：</div>
                        <div style={{ marginTop: 10 }}><span style={{ fontSize: '20px', fontWeight: 'bold' }}>
                            {!Util.isEmpty(this.state.totalCount) ? this.state.totalCount[0].inService : 0}</span>&nbsp;
                        </div>
                    </div>
                </Card>
                <Card style={{ height: '100%', width: '19.5%', marginLeft: 8 }}>
                    <div className='splice-pendingConsultation' style={{ float: 'left' }}></div><Divider type="vertical" style={{ marginLeft: '10%', height: 80 }} />
                    {/* <div style={{ float: 'right', marginRight: '10%', marginTop: '13%' }}>人</div> */}
                    <div style={{ float: 'right', marginRight: '10%' }}>
                        <div style={{ fontSize: '16px', fontWeight: 'bold', color: '#333333' }}>待处理咨询：
                        <span style={{ fontSize: '20px', fontWeight: 'bold' }}>
                                {!Util.isEmpty(this.state.totalCount) ? this.state.totalCount[0].pendingConsultation : 0}</span>&nbsp;人</div>
                        <div style={{ marginTop: 10 }}><span style={{ fontSize: '20px', fontWeight: 'bold' }}>

                            {!Util.isEmpty(this.state.totalCount) && parseInt(this.state.totalCount[0].pendingConsultation) > 0 ?
                                <span style={{ color: '#0099FF', paddingRight: 10, cursor: 'pointer' }}
                                    onClick={this.handleConsultationModal.bind(this)}>处理</span>
                                : <span style={{ color: '#cccccc', paddingRight: 10, cursor: 'not-allowed' }}>处理</span>}</span>
                        </div>
                    </div>
                </Card>
                <Card style={{ height: '100%', width: '19.5%', marginLeft: 8 }}>
                    <div className='splice-pendingException' style={{ float: 'left' }}></div><Divider type="vertical" style={{ marginLeft: '10%', height: 80 }} />
                    {/* <div style={{ float: 'right', marginRight: '10%', marginTop: '13%' }}>条</div> */}
                    <div style={{ marginRight: '10%', float: 'right' }}>
                        <div style={{ fontSize: '16px', fontWeight: 'bold', color: '#333333' }}>待处理异常：<span style={{ fontSize: '20px', fontWeight: 'bold' }}>
                            {!Util.isEmpty(this.state.totalCount) ? this.state.totalCount[0].pendingException : 0}</span>&nbsp;条</div>
                        <div style={{ marginTop: 10 }}><span style={{ fontSize: '20px', fontWeight: 'bold' }}>

                            {!Util.isEmpty(this.state.totalCount) && parseInt(this.state.totalCount[0].pendingException) > 0 ?
                                <span style={{ color: '#0099FF', paddingRight: 10, cursor: 'pointer' }}
                                    onClick={this.handlePeddingExceptionModal.bind(this)}>处理</span> :
                                <span style={{ color: '#cccccc', paddingRight: 10, cursor: 'not-allowed' }}>处理</span>} </span>
                        </div>
                    </div>
                </Card>
                <Card style={{ height: '100%', width: '19.5%', marginLeft: 8 }}>
                    <div className='splice-todoToday' style={{ float: 'left' }}></div><Divider type="vertical" style={{ marginLeft: '10%', height: 80 }} />
                    {/* <div style={{ float: 'right', marginRight: '10%', marginTop: '13%' }}>条</div> */}
                    <div style={{ marginRight: '10%', float: 'right' }}>
                        <div style={{ fontSize: '16px', fontWeight: 'bold', color: '#333333' }}>今日待办：<span style={{ fontSize: '20px', fontWeight: 'bold' }}>
                            {!Util.isEmpty(this.state.totalCount) ? this.state.totalCount[0].todoToday : 0}</span>&nbsp;条</div>
                        <div style={{ marginTop: 10 }}><span style={{ fontSize: '20px', fontWeight: 'bold' }}>

                            {/* {!Util.isEmpty(this.state.totalCount) && parseInt(this.state.totalCount[0].todoToday) > 0 ? */}
                            <span style={{ color: '#0099FF', paddingRight: 10, cursor: 'pointer' }}
                                onClick={this.handleToDealWithModal.bind(this)}>处理</span>
                            {/* : null} */}

                        </span>
                        </div>
                    </div>
                </Card>
            </div>

            <div style={{ marginTop: 5, height: '89%' }}>
                <Card>
                    <Row>
                        <Col span={6}>
                            卡类型：<Select style={{ width: '20%' }} placeholder='请选择卡类型'
                                allowClear showSearch
                                value={this.state.carTypeDr ? this.state.carTypeDr : (this.state.cardStatus)}
                                filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                }
                                getPopupContainer={triggerNode => triggerNode.parentNode}
                                onChange={this.changeCardType.bind(this, 'carTypeDr')}>
                                {cardTypeOption}
                            </Select>
                            <Search className={this.state.readMode == 'R' ? 'disable-input-title' : ''}
                                placeholder={'请输入卡号或读卡'} style={{ width: '50%', marginLeft: 10 }}
                                onChange={Util.commonInputChange.bind(this, 'cardNo')}
                                value={this.state.cardNo}
                                enterButton={'读卡'}
                                readOnly={this.state.readMode == 'R' ? true : false}
                                onPressEnter={(e) => console.dir(e)}
                                onKeyDown={this.loadEnterData.bind(this, '1')}
                                onSearch={this.handleReadCard.bind(this)}
                            />
                        </Col>

                        <Col span={5}>
                            人员标识：<Input onChange={Util.commonInputChange.bind(this, 'number')} allowClear={true}
                                onKeyDown={this.loadAllData.bind(this)}
                                placeholder='病人ID/姓名/身份证号码/手机号码' style={{ width: '77%' }} />
                        </Col>
                        <Col span={4}>
                            现住地址：<Input onChange={Util.commonInputChange.bind(this, 'address')} allowClear={true}
                                placeholder='请输入现住地址' style={{ width: '70%' }} />
                        </Col>
                        <Col span={4}>
                            签约状态：<Select style={{ width: '70%' }} placeholder='请选择签约状态' allowClear
                                onChange={Util.handleSelectChange.bind(this, 'signStatusID')}>{contractDataOption}</Select>
                        </Col>
                        <Col span={5} style={{ marginTop: 1 }}>
                            年龄范围：
                            <Input style={{ width: '30%', textAlign: 'center', borderRadius: '4px 0px 0px 4px' }} placeholder="开始值"
                                onChange={this.commonInputChangeAge.bind(this, 'ageFrom')} value={this.state.ageFrom} />
                            <Input className="site-input-split"
                                style={{
                                    width: 40,
                                    borderLeft: 0,
                                    borderRight: 0,
                                    pointerEvents: 'none',
                                    borderRadius: 0
                                }}
                                placeholder="至"
                                disabled
                            />
                            <Input
                                className="site-input-right"
                                onChange={this.commonInputChangeAge.bind(this, 'ageTo')} value={this.state.ageTo}
                                style={{
                                    width: '30%',
                                    textAlign: 'center',
                                    borderRadius: '0px 4px 4px 0px'
                                }}
                                placeholder="结束值"
                            />
                        </Col>
                        <Col span={6} style={{ marginTop: 5 }}>
                            疾病类型： <Cascader style={{ width: '68%' }}
                                options={this.state.diseaseType}
                                onChange={this.onChangeDisease.bind(this)}
                                changeOnSelect
                            />
                        </Col>

                        <Col span={5} style={{ marginTop: 5 }}>
                            <RangeDatePicker label={'体检日期：'} format='YYYY-MM-DD' width={'77%'}
                                startDate={this.state.regDateFrom} endDate={this.state.regDateTo}
                                startChange={this.startChange.bind(this)} endChange={this.endChange.bind(this)} />
                        </Col>

                        <Col span={4} style={{ marginTop: 10 }}>
                            <span style={{ color: '#0099FF', cursor: 'pointer' }} onClick={this.loadStartDate.bind(this)}>本年度</span>
                            <span style={{ marginLeft: 5, color: '#0099FF', cursor: 'pointer' }} onClick={this.loadLastDate.bind(this)}>上一年度</span>
                        </Col>

                        <Col span={4} style={{ marginTop: 5 }}>
                            性别：<Select style={{ width: '79%' }} placeholder='请选择性别' allowClear
                                onChange={Util.handleSelectChange.bind(this, 'sexID')}>{sexOption}</Select>
                        </Col>

                        <Col span={2} style={{ marginTop: 5 }}>
                            <Button onClick={this.loadInitData} type='primary'>查询</Button>
                            <Button style={{ marginLeft: 5 }} onClick={this.handleAdvanceQuery.bind(this)} type='primary'
                            // disabled 
                            >高级查询</Button>
                        </Col>
                    </Row>
                </Card>
                <Card style={{ marginTop: 5 }}>
                    <Table columns={this.state.column} style={{ background: 'white', height: store.getState().tableHeight.y }}
                        dataSource={this.state.dataSource}
                        onRow={this.onClickRow} bordered
                        rowClassName={this.setRowClassName}
                        rowKey={(data) => {
                            return data.patID
                        }}
                        title={() => {
                            return <div style={{ textAlign: 'left' }}>
                                {/* <Button style={{ marginLeft: 5 }} disabled type='primary'>健康教育</Button> */}
                                {/* <Button style={{ marginLeft: 5 }} type='primary' disabled={Util.isEmpty(this.state.ids)}
                                    onClick={this.showSendGroupModal.bind(this)}>群发</Button> */}
                                <Button style={{ marginLeft: 5 }} type='primary' onClick={this.showImportModal.bind(this)}>导入</Button>
                                <Button style={{ marginLeft: 5 }} type='primary' onClick={this.onExportData.bind(this)}>导出</Button>
                                <Button style={{ marginLeft: 5 }} type='primary' onClick={this.handleShowInformationModal.bind(this)}>新增</Button>
                                <Button style={{ marginLeft: 5 }} type='primary' onClick={this.editInformationModal.bind(this)}
                                    disabled={Util.isEmpty(this.state.patID)}>编辑</Button>
                            </div>
                        }}
                        scroll={{ x: this.state.totalWidth, y: store.getState().tableHeight.y - 100 + 'px' }}
                        rowSelection={rowSelection}
                        onHeaderRow={column => {
                            return {
                                onDoubleClick: () => {
                                    this.columnRef.onOpenModel();
                                },
                            };
                        }}
                        pagination={false}>
                    </Table>

                    <CommonPagination size={this.state.size} current={this.state.page} total={this.state.total} search={this.state.search}
                        onShowSizeChange={this.changePageSize.bind(this)} complete={true} dataSource={this.state.dataSource}
                        loading={this.state.loading} onChange={this.onChange.bind(this)} />
                </Card>
            </div>
        </div >
    }

}

export default HealthControlPage;