index.js 750 Bytes
import actions from './actions';
import mutations from './mutations';

function handleNum(n) {
  return n > 99 ? '99+' : n;
}

export default function() {
  return {
    namespaced: true,
    state: {
      fetching: false,
      yohoList: {
        notuse: [],
        use: [],
        overtime: []
      },
      num: {
        notuse: 0,
        use: 0,
        overtime: 0
      },
      ufoList: [],
      filterList: [],
      showFilter: true
    },
    actions,
    mutations,
    getters: {
      getNotUseNum(state) {
        return handleNum(state.num.notuse);
      },
      getUseNum(state) {
        return handleNum(state.num.use);
      },
      getOvertime(state) {
        return handleNum(state.num.overtime);
      }
    }
  };
}