menus.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. const _ = require('lodash');
  4. Vue.use(Vuex);
  5. const api = {
  6. url: `/point/${process.env.VUE_APP_BRANCH_ROUTER}/v1/api/menus`,
  7. };
  8. const state = () => ({});
  9. const mutations = {};
  10. const actions = {
  11. async query({ commit }, { skip = 0, limit, ...info } = {}) {
  12. const res = await this.$axios.$get(`${api.url}`, {
  13. skip,
  14. limit,
  15. ...info,
  16. });
  17. return res;
  18. },
  19. async create({ commit }, payload) {
  20. const res = await this.$axios.$post(`${api.url}`, payload);
  21. return res;
  22. },
  23. async fetch({ commit }, payload) {
  24. const res = await this.$axios.$get(`${api.url}/${payload}`);
  25. return res;
  26. },
  27. async update({ commit }, payload) {
  28. const id = _.get(payload, `id`, _.get(payload, `_id`));
  29. const res = await this.$axios.$post(`${api.url}/${id}`, payload);
  30. return res;
  31. },
  32. async delete({ commit }, payload) {
  33. const res = await this.$axios.$delete(`${api.url}/${payload}`);
  34. return res;
  35. },
  36. async userMenu({ commit }, payload) {
  37. const res = await this.$axios.$post(`${api.url}/getUserMenu`);
  38. return res;
  39. },
  40. };
  41. export default {
  42. namespaced: true,
  43. state,
  44. mutations,
  45. actions,
  46. };