// state里面存放的是变量，如果你要注册全局变量，写这里
const state = {
  elTableDataMap: new Map(), // 存储map数据对象
  elFormDataMap: new Map()// 存储map数据对象
}
// mutations => 修改store中的变量的方法，如果你要改变变量的值，就写这里  commit('SET_ROLES', roles)
const mutations = {
  ELTABLEDATAMAP_ADD: (state, value) => { // 添加数据到Map对象
    state.elTableDataMap.set(value.key, value.value)
  },
  ELFORMDATAMAP_ADD: (state, value) => { // 添加数据到Map对象
    state.elFormDataMap.set(value.key, value.value)
  },
  ELTABLEDATAMAP_UPDATA: (state, key, value) => { // 更新数据到Map对象
    state.elTableDataMap.set(key, value)
  },
  ELFORMDATAMAP_UPDATA: (state, key, value) => { // 更新数据到Map对象
    state.elFormDataMap.set(key, value)
  },
  ELFORMDATAMAP_CLEAR: (state) => {
    state.elFormDataMap = new Map()
  },
  ELTABLEDATAMAP_CLEAR: (state) => {
    state.elTableDataMap = new Map()
  },
  ELTABLEDATAMAP_RESTART: (state, map) => {
    state.elTableDataMap = map
  },
  ELFORMDATAMAP_RESTART: (state, map) => {
    state.elFormDataMap = map
  }
}
// getters相当于是state的计算属性，如果你需要将变量的值进行计算，然后输出，写这里
// const getters = {
//   getElTableDataMapByKey(state, key) {
//     return state.elTableDataMap.has(key)
//   },
//   clearElTableDataMap(state) {
//     mutations.ELTABLEDATAMAP_CLEAR(state)
//   },
// }
// actions提交的是mutations，相当于就是改变变量的方法的重写，但是，actions是可以进行异步操作的 store.dispatch('elTable/elTableDataMapRestart',{map:new Map()})
const actions = {
  elTableDataMapAdd({ commit }, value) {
    commit('ELTABLEDATAMAP_ADD', value)
  },
  elFormDataMapAdd({ commit }, value) {
    commit('ELFORMDATAMAP_ADD', value)
  },
  elTableDataMapRestart({ commit, state }, map) {
    commit('ELTABLEDATAMAP_RESTART', state, map)
  },
  elFormDataMapRestart({ commit, state }, map) {
    commit('ELFORMDATAMAP_RESTART', state, map)
  },
  elTableDataMapClear({ commit, state }) {
    commit('ELTABLEDATAMAP_CLEAR', state)
  },
  elFormDataMapClear({ commit, state }) {
    commit('ELFORMDATAMAP_CLEAR', state)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
  // getters
}
