index.js 540 B

123456789101112131415161718192021222324
  1. import Vue from "vue";
  2. import Vuex from "vuex";
  3. import { queryAllWorkType } from "@/services/workload";
  4. Vue.use(Vuex);
  5. const store = new Vuex.Store({
  6. state: {
  7. typeList: [],
  8. allType: {},
  9. },
  10. mutations: {
  11. setType(state, values) {
  12. state.typeList = values.typeList;
  13. state.allType = values.allType;
  14. },
  15. },
  16. actions: {
  17. getType: async function ({ commit, state }, value) {
  18. if (state.typeList.length > 0) return;
  19. commit("setType", await queryAllWorkType());
  20. },
  21. },
  22. });
  23. export default store;