Blame view

src/store/modules/dict.js 799 Bytes
1
/*
2
 * @Description:
3 4 5
 * @Autor: renchao
 * @LastEditTime: 2023-05-17 10:34:47
 */
6
import { getAllDict } from '@/api/dict'
任超 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
const state = {
  dictData: {},
  addDict: false,
}

const mutations = {
  SET_DATA: (state, data) => {
    state.addDict = true
    state.dictData = data
  },
  RESET_DICT: (state) => {
    state.addDict = false
  }
}

const actions = {
yuanbo committed
23 24 25 26
  /**
   * @description: generateDic
   * @author: renchao
   */
任超 committed
27 28 29 30 31 32 33
  generateDic ({ commit }) {
    return new Promise(async (resolve) => {
      let { result: res } = await getAllDict()
      commit('SET_DATA', res)
      resolve(true)
    })
  },
yuanbo committed
34 35 36 37
  /**
   * @description: resetdict
   * @author: renchao
   */
任超 committed
38 39 40 41 42 43 44 45 46 47 48
  resetdict ({ commit }) {
    commit('RESET_DICT')
  }
}

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