You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
676 B

  1. import RoleService from '@/services/role.service'
  2. export const state = () => ({
  3. items: [],
  4. loading: false
  5. })
  6. export const getters = {
  7. roles(state) {
  8. return state.items
  9. }
  10. }
  11. export const mutations = {
  12. setRoleList(state, payload) {
  13. state.items = payload
  14. },
  15. setLoading(state, payload) {
  16. state.loading = payload
  17. }
  18. }
  19. export const actions = {
  20. getRoleList({ commit }) {
  21. commit('setLoading', true)
  22. return RoleService.getRoleList()
  23. .then((response) => {
  24. commit('setRoleList', response.data)
  25. })
  26. .catch((error) => {
  27. alert(error)
  28. })
  29. .finally(() => {
  30. commit('setLoading', false)
  31. })
  32. }
  33. }