import React from 'react';
import {
  connect
} from 'react-redux';
import newAdvice from '@components/NewAdvice';
import {
  getSearchList,
  getSublableList,
} from '@store/async-actions/newAdvice';
import {
  setLabel,
  fillActived,
  fillActiveDetail,
  checkValueIsChange,
  delExcelLis,
  clearLabel,
  delPartItem,
  setContext,
  setTipAdviceNew,
  searchTypeNew,
  resetLabel,
  delOnePic,
  checkOffOn,
  selectJiType,
  handleSelectShow,
  handleSuiFang,
} from '@store/actions/newAdvice';
import {
  billing,
  embedPush,
  getConceptDetail,
  getMRAnalyse
} from '@store/async-actions/pushMessage';
import {HIDEDROP} from '@types/homePage';

function mapStateToProps(state) {//console.log(state)
  return {
    list: state.newAdvice.list,
    labelList: state.newAdvice.labelList,
    fillActive: state.newAdvice.fillActive,
    shType: state.newAdvice.shType,
    activeIdx: state.newAdvice.activeIdx,
    getExcelDataList: state.newAdvice.getExcelDataList,
    labelListActive: state.newAdvice.labelListActive,
    inspectList: state.homePage.inspectList,
    windowHeight: state.homePage.windowHeight,
    windowWidth: state.homePage.windowWidth,
    inspectVal: state.newAdvice.inspectVal,
    message: state.patInfo.message,
    labelListBig: state.newAdvice.labelListBig,
    labelListSmall: state.newAdvice.labelListSmall,
    labelListBlood: state.newAdvice.labelListBlood,
    hospitalMsg: state.homePage.sysConfig || {},
    typeConfig: state.typeConfig,
    staticData:state.homePage.staticData['9'],
    hosId:state.homePage.curHos.hosId
  }
}

function mapDispatchToProps(dispatch) {
  return {
    handleSuiFang(item,idx){
      dispatch(handleSuiFang(item,idx))
    },
    handleSelectShow(idx,sign){
      dispatch(handleSelectShow(idx,sign))
    },
    selectJiType(part,idx){
      dispatch(selectJiType(part,idx))
    },
    checkOnOff(item,idx){
      dispatch(checkOffOn(item,idx))
    },
    detailClick(val){
      dispatch(searchTypeNew(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,sign,tip) {
      dispatch(setTipAdviceNew(item,value,sign,tip))
    },
    //右侧推送
    fetchPushInfos(obj) {
      obj.action = 'doc_advice'
      //调右侧推送
      dispatch(embedPush(obj));
    },
    hideAllDrop(){
      dispatch({
        type:HIDEDROP
      });
    },
  }
}

const NewInspectAction = connect(mapStateToProps, mapDispatchToProps)(newAdvice);

export default NewInspectAction;