index.js 649 B

12345678910111213141516171819202122232425262728
  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. currentProject: {},
  10. },
  11. mutations: {
  12. setType(state, values) {
  13. state.typeList = values.typeList;
  14. state.allType = values.allType;
  15. },
  16. setCurrentProject(state, project) {
  17. state.currentProject = project;
  18. },
  19. },
  20. actions: {
  21. getType: async function ({ commit, state }, value) {
  22. if (state.typeList.length > 0) return;
  23. commit("setType", await queryAllWorkType());
  24. },
  25. },
  26. });
  27. export default store;