classes.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. Vue.use(Vuex);
  5. const api = {
  6. interface: `/api/train/class`,
  7. divide: `/api/train/class/divide`,
  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. //分班
  33. async divide({ commit }, payload) {
  34. const res = await this.$axios.$post(`${api.divide}`, payload);
  35. return res;
  36. },
  37. };
  38. export default {
  39. namespaced: true,
  40. state,
  41. mutations,
  42. actions,
  43. };