role.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import axios from 'axios';
  4. import _ from 'lodash';
  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, ...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, ...data }) {
  25. const res = await this.$axios.$post(`${api.interface}/update/${id}`, data);
  26. return res;
  27. },
  28. async delete({ commit }, payload) {
  29. const res = await this.$axios.$delete(`${api.interface}/${payload}`);
  30. return res;
  31. },
  32. async roleMenu({ commit }, payload) {
  33. const res = await this.$axios.$get(`${api.interface}/menu/tree`, payload);
  34. return res;
  35. },
  36. };
  37. export default {
  38. namespaced: true,
  39. state,
  40. mutations,
  41. actions,
  42. };