import Vue from "vue";
import Vuex from "vuex";
import { queryAllWorkType } from "@/services/workload";

Vue.use(Vuex);
const store = new Vuex.Store({
  state: {
    typeList: [],
    allType: {},
  },
  mutations: {
    setType(state, values) {
      state.typeList = values.typeList;
      state.allType = values.allType;
    },
  },
  actions: {
    getType: async function ({ commit, state }, value) {
      if (state.typeList.length > 0) return;
      commit("setType", await queryAllWorkType());
    },
  },
});
export default store;
