import {GET_ALL_HIS,FILTER_ALL_HIS,CLEAR_RECORD,GET_SEARCH} from '../types/emergencyHis.js';
// import {getAllHis} from '../actions/emergencyHis.js';

const initState = {
  allHisRecord:[],
  total:null,
  params:{},
  searchData:[]
}

export default function (state=initState,action){
  let res = Object.assign({},state);
  switch(action.type){
    case GET_ALL_HIS://获取-追加
      res.allHisRecord = res.allHisRecord.concat(action.data);
      res.total = action.total;
      res.params = Object.assign(res.params,action.params);
      return res;
    case FILTER_ALL_HIS://筛选-替换
      res.allHisRecord = action.data;
      res.total = action.total;
      res.params = action.params;
      return res;
    case CLEAR_RECORD://清除
      res.allHisRecord = [];
      res.total = null;
      res.params = {};
      return res;
    case GET_SEARCH://搜素
      res.searchData = action.searchResult;
      return res;
    default:
      return res;
  }
}