import React from 'react';
import { connect } from 'react-redux';
import DiagnosticList from '@components/DiagnosticList';
import { ADD_DIAGNOSTIC,  DEL_DIAGNOSTIC, UP_DIAGNOSTIC, DOWN_DIAGNOSTIC, GET_DIAGNOSTIC_STR, GET_IS_FIRST, HIDE_REFER_RECORD, SHOW_HISTORY_CASE,HIDE_HISTORY_CASE } from '@store/types/diagnosticList'; 
import { getTreatResult } from '@store/async-actions/treat';
import { SHOW_TREAT } from '../store/types/treat';
import {billing, getTips} from '../store/async-actions/pushMessage';
import {keepPushData} from '@store/actions/tabTemplate';
import { showHistory,sortHistory,activeHistory,visibleHistory } from '@store/actions/historyTemplates'




function mapStateToProps(state) {
    return {
        list: state.diagnosticList.diagnosticList,
        treatment: state.treat.show,
        isFirst: state.diagnosticList.isFirst,
        diagnosticStr: state.diagnosticList.diagnosticStr,
        showReferRecord: state.diagnosticList.showReferRecord,
        showHistoryCase: state.diagnosticList.showHistoryCase,
        items:state.historyTemplates.items,
    }
}

function mapDispatchToProps(dispatch) {
    return {
        delDiagnostic: (item) => {
            dispatch({
                type: DEL_DIAGNOSTIC,
                item: item
            });
            dispatch({
                type: GET_DIAGNOSTIC_STR
            });
        },
        upDiagnostic: (index, id) => {
            dispatch({
                type: UP_DIAGNOSTIC,
                index: index
            });
            dispatch({
                type: GET_DIAGNOSTIC_STR
            });
        },
        downDiagnostic: (index, id) => {
            dispatch({
                type: DOWN_DIAGNOSTIC,
                index: index
            });
            dispatch({
                type: GET_DIAGNOSTIC_STR
            });
        },
        getSearchResult:() => {
            dispatch(getSearchResult)
        },
        showTreat: () => {
            dispatch({
                type: SHOW_TREAT,
            })
        },
        getTreatResult: (item) => {
            dispatch(getTreatResult(item))
        },
        getTips: (diagItem) => {
            dispatch(getTips(diagItem))
        },
        getBilling: () => {
            dispatch(billing())
        },
        hideReferRecord: ()=>{
            dispatch({
                type: HIDE_REFER_RECORD
            })
        },
        showHistoryCaseModal: ()=> {
            dispatch({
                type: SHOW_HISTORY_CASE
            })
        },
        hideHistoryCaseModal: ()=> {
            dispatch({
                type: HIDE_HISTORY_CASE
            })
        },
        handleQuoteClick(data){
            
            dispatch(keepPushData(data,'his'))      //历史病历引用
            // dispatch(activeHistory(idx))
            dispatch(visibleHistory(true))
           
        },
        
    }
}

const diagnosticListContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(DiagnosticList)

export default diagnosticListContainer;

