role.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. //用户的菜单选项增删改查
  5. Vue.use(Vuex);
  6. const api = {
  7. interface: `/api/auth/role`,
  8. };
  9. const state = () => ({});
  10. const mutations = {};
  11. const actions = {
  12. async query({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
  13. const res = await this.$axios.$get(api.interface, { skip, limit, ...info });
  14. return res;
  15. },
  16. async create({ commit }, payload) {
  17. const res = await this.$axios.$post(`${api.interface}`, payload);
  18. return res;
  19. },
  20. async fetch({ commit }, payload) {
  21. const res = await this.$axios.$get(`${api.interface}/${payload}`);
  22. return res;
  23. },
  24. async update({ commit }, { id, ...info } = {}) {
  25. const res = await this.$axios.$post(`${api.interface}/update/${id}`, { ...info });
  26. return res;
  27. },
  28. async delete({ commit }, payload) {
  29. const res = await this.$axios.$delete(`${api.interface}/${payload}`);
  30. return res;
  31. },
  32. };
  33. export default {
  34. namespaced: true,
  35. state,
  36. mutations,
  37. actions,
  38. };