import React from 'react';
import {
  connect
} from 'react-redux';
import Inspect from '@components/Inspect';
import {
  getSearchList,
  getSublableList,
} from '@store/async-actions/inspect';
import {
  setLabel,
  fillActived,
  fillActiveDetail,
  checkValueIsChange,
  delExcelLis,
  clearLabel,
  delPartItem,
  setContext,
  setTips,
  searchType,
  resetLabel,
  delOnePic,
  checkOffOn,
} from '@store/actions/inspect';
import {
  billing,
  embedPush,
  getConceptDetail,
  getMRAnalyse
} from '@store/async-actions/pushMessage';
import {HIDEDROP} from '@types/homePage';

function mapStateToProps(state) {//console.log(state)
  return {
    list: state.inspect.list,
    labelList: state.inspect.labelList,
    fillActive: state.inspect.fillActive,
    shType: state.inspect.shType,
    getExcelDataList: state.inspect.getExcelDataList,
    labelListActive: state.inspect.labelListActive,
    inspectList: state.homePage.inspectList,
    windowHeight: state.homePage.windowHeight,
    windowWidth: state.homePage.windowWidth,
    inspectVal: state.inspect.inspectVal,
    message: state.patInfo.message,
    labelListBig: state.inspect.labelListBig,
    labelListSmall: state.inspect.labelListSmall,
    hospitalMsg: state.homePage.sysConfig || {},
    typeConfig: state.typeConfig
  }
}

function mapDispatchToProps(dispatch) {
  return {
    checkOnOff(item,idx){
      dispatch(checkOffOn(item,idx))
    },
    detailClick(val){
      dispatch(searchType(val))
    },
    setContext(obj){
      dispatch(setContext(obj))
    },
    handleDelConfirm(obj,idx){
      dispatch(delOnePic(obj,idx))
    },
    handleChangeValue(val) {
      dispatch(getSearchList(val))
    },
    getInfomation(item) {
      dispatch(getConceptDetail(item))
    },
    handleSign(arr,id, idx, type) {
      dispatch(resetLabel(arr))
      // dispatch(setLabel(idx, type))
      // dispatch(getSublableList(id))
      // dispatch(getMRAnalyse())
    },
    handleLabelSub(e, id, idx) {
      dispatch(fillActived(id, idx))
      // e.stopPropagation()
    },
    handleClear(e, idx) {
      e.stopPropagation();
      dispatch(clearLabel(idx))
    },
    handleConfirm(e, idx, time, arr) {
      e.stopPropagation();
      dispatch(checkValueIsChange(idx, time, arr))
    },
    changeActivePart(idx, value) {
      dispatch(fillActiveDetail(idx, value))
    },
    handleCloseExcel(idx) {
      dispatch(delExcelLis(idx));
      dispatch(getMRAnalyse())
    },
    delPartItem(idx) {
      dispatch(delPartItem(idx))
      dispatch(getMRAnalyse())
    },
    setTipValue(item,value,type,tip) {
      dispatch(setTips(item,value,type,tip))
    },
    //右侧推送
    fetchPushInfos(obj) {
      obj.action = 'lis'
      //调右侧推送
      dispatch(embedPush(obj));
    },
    hideAllDrop(){
      dispatch({
        type:HIDEDROP
      });
    },
  }
}

const InspectAction = connect(mapStateToProps, mapDispatchToProps)(Inspect);

export default InspectAction;