import React from 'react';
import { connect } from 'react-redux';
import HistoryCaseContainer from '@components/HistoryCaseContainer';
import { showHistory,sortHistory,activeHistory,visibleHistory,saveHistoryId } from '@store/actions/historyTemplates'
import {keepPushData} from '@store/actions/tabTemplate';
import { dragBox } from '@utils/drag';

function mapStateToProps(state) {
    return {
        showHistoryCases:state.historyTemplates.showHistoryCases,
        activeHistory:state.historyTemplates.activeHistory,
        items:state.historyTemplates.items,
        visible:state.historyTemplates.visible,
        // preInfo: { ...state.patInfo.message, hispitalName: state.historyTemplates.HospitalInfo.name},
        preInfo: { hispitalName: state.historyTemplates.HospitalInfo.name}
    }
}


function mapDispatchToProps(dispatch) {
    return {
        showHistoryBox(){
            dragBox('hisWrapMove','closeHis','del')
            dispatch(showHistory(false))
            // 取消历史模态框后,页面设置为可滚动
            document.body.style.overflow = 'auto';
        },
        handleCaseClick(e,val){
            e.stopPropagation();
            dispatch(activeHistory(val))
        },
        handleQuoteClick(data,idx){
            // e.stopPropagation();
            dispatch(keepPushData(data,'his'))      //历史病历引用
            dispatch(activeHistory(idx))
            dispatch(visibleHistory(true))
            dispatch(saveHistoryId(data.id));
        },
        handleSortClick(){
            dispatch(sortHistory())
        }
    }
}

const HistoryCases = connect(
    mapStateToProps,
    mapDispatchToProps
)(HistoryCaseContainer);
export default HistoryCases;
