import Vue from 'vue'
import Vuex from 'vuex'
import { getAffairType } from '@/api/index'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    affairTypes: [] // 事务类型列表
  },
  mutations: {
    updateAffairTypes(state, types) {
      state.affairTypes = types
    }
  },
  actions: {
    async getAffairTypes({ commit }) {
      const affairTypes = await getAffairType()
      commit('updateAffairTypes', affairTypes)
    }
  }
})
