import React from 'react';
import {
    connect
} from 'react-redux';
import AssistCheck from '@components/AssistCheck';
import { assistLable,delAssistLabel,changeAssistVal,changeDate,allCheckImports,selectOneChecks,showInIcsss } from '@store/actions/assistCheck';
import { getSearchList,getInstroduce ,getImportLists,getSonDetailList} from '@store/async-actions/assistCheck';
import {ISREAD} from '@store/types/homePage.js';
import {billing, getConceptDetail} from '@store/async-actions/pushMessage';
import { getCalendarDate} from '@utils/tools';

function mapStateToProps(state) {//console.log(state)
    return {
        list:state.assistCheck.list,
        assistLabel:state.assistCheck.assistLabel,
        isRead:state.homePage.isRead,
        winWidth:state.homePage.windowWidth,
        assistList:state.homePage.assistList,
        assistVal:state.assistCheck.assistVal,
        windowHeight:state.homePage.windowHeight,
        hospitalMsg: state.homePage.sysConfig || {},

        message: state.patInfo.message,
        hospitalPac: state.assistCheck.hospitalPac,
        hospitalSonInspect: state.assistCheck.hospitalPacObj,
        checkedList: state.assistCheck.checkedList,
        selectGroupList: state.assistCheck.selectGroupList,
        allCheck: state.assistCheck.allCheck,
        msgObj: state.assistCheck.msgObj,
        checkedListImport: state.assistCheck.checkedListImport,
        typeConfig: state.typeConfig
    }
}

function mapDispatchToProps(dispatch, store) {
    return {
        showInIcss(){
          dispatch(showInIcsss())
        },
        selectOneCheck(name,checkItem,item){
          dispatch(selectOneChecks(name,checkItem,item))
        },
        allCheckImport() {
          dispatch(allCheckImports())
        },
        handleSearchs(data) {
          dispatch(getImportLists(data))
        },
        handleGetSonList(name,time) {
          dispatch(getSonDetailList(name,time))
        },

        getInfomation(item){
            dispatch(getConceptDetail(item))
        },
        handleChangeValue(val) {
            dispatch(getSearchList(val))
        },
        handleSign(id,idx,type){
            dispatch(assistLable(id,idx,type))
        },
        handleDelAssist(idx,name,type){
            dispatch(delAssistLabel(idx,name,type))
            dispatch({
              type:ISREAD
            })
        },
        handleChangeAssistValue(val,idx){
            dispatch(changeAssistVal(val,idx))
        },
        handleChangeDate(info,idx){
            let date = getCalendarDate(info);
            dispatch(changeDate(date,idx))
        },
        //右侧推送
        fetchPushInfos(){
          //调右侧推送
          dispatch(billing());
        }
    }
}

const AssistCheckAction = connect(mapStateToProps, mapDispatchToProps)(AssistCheck);

export default AssistCheckAction;