// 现病史
import {SET_CURRENT,CURRENT_CONFIRM,INSERT_PROCESS,SET_CURRENT_DATA,SET_LABEL_MODULE,SETMAINCHECKBOX,
  CURRENT_RADIO,CURRENT_NUMBER,CURRENT_TEXT_LABEL,CLEAR_CURRENT_ILL,SETTEXTMODEVALUE,CURRENT_GET_BIGDATAPUSH,CURRENT_CLEAR,
  SET_CURRENT_SEARCH,SETCURRENTTEXT,CURRENT_FOCUS_INDEX,SELECT_SEARCHDATA,CLEAR_CURRENT_EDIT,CURRENTADDLABELITEM,
  SETCURRENTINPUT,DEL_CURRENT,CURRENT_TEXT_LABEL_NUMBER,REMOVE_CURR_ID,CURRENT_MUL,DEL_CURRENT_LABLE,SET_RADIO_INPUT_VALUE,CURRENT_CHRONIC,SAVE_CURR_FREE} from '../types/currentIll';
import {confirm,insertProcess,setData,setCheckBox,setRadioValue,setNumberValue,changeLabelVal,clearCurrentIll,
  setTextModeValue,setModule,bigDataSymptom,setCheckText,insertLabelData,clearCurrentEdit,addLabelItem,setInputLabel,
  backspaceText,changeNumLabelVal,removeId,multipleComfirn,delSingleLable,setRadioInputValue,fillChronicModule} from '../actions/currentIll';

const initState = {
  moduleData:[],
  data:[],
  saveText:[],
  selecteds:[],
  searchDatas:[],//搜索结果
  editClear:true,
  addModule:[],
  emptyData:[],
  symptomIds:[] //搜索去重
};
export default function(state=initState,action){    
  const res = Object.assign({},state);
  switch (action.type){
    case SET_CURRENT://需要处理截取的模板
      return setModule(state,action);
    case SET_CURRENT_DATA://设置使用的模板数据
      return setData(state,action);
    case CURRENT_CONFIRM://展开多选确定
      return confirm(state,action);
    case SET_LABEL_MODULE://设置主诉选中的标签模板
      res.mainLabelModule = action.data;
      return res;
    case INSERT_PROCESS://病程变化
      return insertProcess(state,action);
	case CLEAR_CURRENT_ILL://清除现病史数据
      return clearCurrentIll(state,action);
    case SETTEXTMODEVALUE:
      return setTextModeValue(state,action);
    case SETMAINCHECKBOX://普通多选确定
      return setCheckBox(state,action);
    case CURRENT_RADIO://单选确定
      return setRadioValue(state,action);
    case CURRENT_NUMBER://数字确定
      return setNumberValue(state,action);
    case CURRENT_TEXT_LABEL://标签双击编辑
      return changeLabelVal(state,action);
    case CURRENT_TEXT_LABEL_NUMBER://数字键盘
      return changeNumLabelVal(state,action);
    case CURRENT_GET_BIGDATAPUSH://标签双击编辑
      return bigDataSymptom(state,action);
    case SET_CURRENT_SEARCH://搜索结果
      res.searchDatas = action.data;
      res.searchStr = action.inpStr;
      return res;
    case CURRENT_CLEAR:
      res.searchDatas = [];//清空搜索结果
      return res;
    case SETCURRENTTEXT:
      return setCheckText(state,action);
    case CURRENT_FOCUS_INDEX://手动输入位置
      res.focusIndex = action.index;
      res.span = action.$span;
      return res;
    case SELECT_SEARCHDATA:
      return insertLabelData(state,action);
    case CLEAR_CURRENT_EDIT://清除数据
      return clearCurrentEdit(state,action);
    case CURRENTADDLABELITEM:
      return addLabelItem(state,action);
    case SETCURRENTINPUT:
      return setInputLabel(state,action);
    case DEL_CURRENT:
      return backspaceText(state,action);
    case REMOVE_CURR_ID:
      return removeId(state,action);
    case CURRENT_MUL://单列多选
      return multipleComfirn(state,action);
    case DEL_CURRENT_LABLE:
      return delSingleLable(state,action);
    case SET_RADIO_INPUT_VALUE:
      return setRadioInputValue(state,action);
    case CURRENT_CHRONIC:
      return fillChronicModule(state,action);
    case SAVE_CURR_FREE://自由输入
      res.saveText[0] = action.data;
      res.update = Math.random();
      return res;
    default:
      return state;
  }
}