import React from 'react';
import {connect} from 'react-redux';
import {SETRADIO,CLEARSELECTED,CONFIRMSELECTED,SETOTHERINPUT} from '@types/otherHistory';
import {SETMAININPUT} from '@types/mainSuit';
import {SETCURRENTINPUT} from '@types/currentIll';
import {SETCHECKINPUT} from "@types/checkBody";
import InlineTag from "../common/components/InlineTag";
import {getLabelIndex} from "@common/js/func";
import {CLICKCOUNT} from '@types/homePage.js';

function mapStateToProps(state){
  return {}
}

const tagInpActions = {
  1:SETMAININPUT,
  2:SETCURRENTINPUT,
  3:SETOTHERINPUT,
  4:SETCHECKINPUT
};

function mapDispatchToProps(dispatch,store){
  return {
    handleInput(params) {
      const type = params.ikey.substr(0,1);    //当前所在的项目
      const {ikey,text,prefix,suffix} = params;
      const i = getLabelIndex(ikey);
      const inner = params.ikey.substr(params.ikey.length-1);
      dispatch({
        type:tagInpActions[+type],
        i,
        text,
        prefix,
        suffix,
        subIndex:inner
      })
    },
    handledbClick(obj){
      dispatch({
        type:CLICKCOUNT,
        data:obj,
        clickType:'双击',
        num:1
      });
    }
  }
}

const InlineTagCont = connect(mapStateToProps,mapDispatchToProps)(InlineTag);

export default InlineTagCont;
