import React from 'react';
import {connect} from 'react-redux';
import PushItems from '../components/PushItems'
import {CHANGE_ASSAY, CHANGE_CHECK, ADD_BILLING, SHOW_TIPS_DETAILS, HIDE_TIPS_DETAILS,SHOW_TABLE_LIST,SET_PUSH_EMERGENCY_IDX} from '@store/types/pushMessage';
import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR } from '@store/types/diagnosticList';
import {billing, getAllConceptDetail} from '../store/async-actions/pushMessage';
import { isAddMainSuit } from '@store/async-actions/diagnosticList';
import { HIDEDROP } from '@store/types/homePage.js';
import { getConceptDetail } from '@store/async-actions/pushMessage';

function mapStateToProps(state) {//console.log(state)
  const {pushMessage,diagnosticList,inspect} = state;
    return {
        pushMessage: pushMessage,
        tipsDiscalimer:  state.copyRight.disContent,
        chronicMagItem: diagnosticList.chronicMagItem,
        clickDiag: diagnosticList.clickDiag,
        tableList: pushMessage.tableList,
        showList: pushMessage.showList,
        chronicPushItems: pushMessage.chronicPushItems,
        setPushEmergencyIdx: state.pushMessage.setPushEmergencyIdx || '',
        sysConfig:state.homePage.sysConfig,
        windowHeight:state.homePage.windowHeight,
        EMRScrollCont:inspect.context.scrollArea,             //滚动条对象
    }
}

function mapDispatchToProps(dispatch) {
    return {
        hideAllDrop(){
            dispatch({
              type:HIDEDROP
            });
        },
        changeAssay: (item) => {
            dispatch({type: CHANGE_ASSAY, item})
        },
        changeCheck: (item) => {
            dispatch({type: CHANGE_CHECK, item})
        },
        addDiagnostic: (item) => {
            dispatch({
                type: ADD_DIAGNOSTIC,
                item: item
            });
            dispatch({
                type: GET_DIAGNOSTIC_STR
            });
            dispatch(isAddMainSuit())
            dispatch(billing());
        },
        billing: (checkedAssay, checkedCheck) => {
            // dispatch(billing)
            dispatch({
                type: ADD_BILLING, //添加开单项
                assay: checkedAssay,
                check: checkedCheck,
            })
        },
        getInfomation(item){
            dispatch(getConceptDetail(item))
        },
        getTipsDetails: (item) => {
            dispatch(getAllConceptDetail(item))
        },
        showTipsDetailsModal: () => {
            dispatch({
                type: SHOW_TIPS_DETAILS
            })
        },
        hideTipsDetailsModal: () => {
            dispatch({
                type: HIDE_TIPS_DETAILS
            })
        },
        setDataIdx:(idx)=>{
            dispatch({
                type: SET_PUSH_EMERGENCY_IDX,
                idx:idx
            })
        }
    }
}

const PushItemsComtainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(PushItems);

export default PushItemsComtainer;