dict.js 799 Bytes
/*
 * @Description:
 * @Autor: renchao
 * @LastEditTime: 2023-05-17 10:34:47
 */
import { getAllDict } from '@/api/dict'
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 = {
  /**
   * @description: generateDic
   * @author: renchao
   */
  generateDic ({ commit }) {
    return new Promise(async (resolve) => {
      let { result: res } = await getAllDict()
      commit('SET_DATA', res)
      resolve(true)
    })
  },
  /**
   * @description: resetdict
   * @author: renchao
   */
  resetdict ({ commit }) {
    commit('RESET_DICT')
  }
}

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