import {SET,SETNUMBER4,SETSELECTED4,SETCHECKBOX,ADDLABELITEM,SETCHECKTEXT,SETSEARCHDATA,
  SELECTSEARCHDATA,CHANGECHECKTEXTLABEL,CLEARCHECKBODY,CHECK_FOCUS_INDEX,CHECKBODY_CLEAR,SETCHECKINPUT} from '../types/checkBody.js';
import {set,setNumberValue,setRadioValue,setCheckBoxValue,addLabelItem,setCheckText,setSearchData,insertLabelData,changeLabelVal,clearCheckBody,setInputLabel} from '../actions/checkBody.js';
import config from '@config/index.js';

const block = Object.assign(JSON.parse(config.textLabel),{full:true});
const initState = {
                data:[],
                saveText:[],    //saveText为生成的纯文本
                searchData:[],
                selecteds:[],
                focusIndex:''};
export default function(state=initState,action){
  let res = Object.assign({},state);
  switch(action.type){
    case SET:
      return set(state,action);
    case SETNUMBER4:
      return setNumberValue(state,action);
    case SETSELECTED4:
      return setRadioValue(state,action);
    case ADDLABELITEM:
      return addLabelItem(state,action);
    case SETCHECKTEXT:
      return setCheckText(state,action);
    case SETSEARCHDATA:
      return setSearchData(state,action);
    case SETCHECKBOX:
      return setCheckBoxValue(state,action);
    case SELECTSEARCHDATA:
      return insertLabelData(state,action);
    case CLEARCHECKBODY:
      return clearCheckBody(state,action);
    case CHANGECHECKTEXTLABEL://改变标签值
      return changeLabelVal(state,action);
    case CHECK_FOCUS_INDEX:
      res.focusIndex = action.index;
      res.span = action.$span;
	case CHECKBODY_CLEAR://失焦清空搜索值
      res.searchData = [];
      return res;
  case SETCHECKINPUT:
      return setInputLabel(state,action);
    default:
      return res;
  }
}