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

function mapStateToProps(state) {//console.log(state.typeConfig)
    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 {
        setTipValue(item,val,idx){
          dispatch(setTipVal(item,val,idx))
        },
        checkOnOff(item,idx){
          dispatch(checkOffOn(item,idx))
        },
        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(item,type){
            dispatch(assistLable(item,type))
            dispatch(getMRAnalyse())
        },
        handleDelAssist(idx,name,type){
            dispatch(delAssistLabel(idx,name,type))
            dispatch(getMRAnalyse())
            dispatch({
              type:ISREAD
            })
        },
        handleChangeAssistValue(val,idx){
            dispatch(changeAssistVal(val,idx))
        },
        handleChangeDate(info,idx){
            let date = getCalendarDate(info);
            dispatch(changeDate(date,idx))
        },
        //右侧推送
        fetchPushInfos(obj){
          obj.action = 'pacs'
          //调右侧推送
          dispatch(embedPush(obj));
        },
        hideAllDrop(){
          dispatch({
            type:HIDEDROP
          });
        },
    }
}

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

export default AssistCheckAction;