import { listAll } from '@/api/system/dict/type.js'

const dict = {
  state: {
    data: {}
  },

  mutations: {
    SET_DICT: (state, data) => {
      state.data = data
    }
  },

  actions: {
    // 加载字典数据
    GetDicts({ commit }) {
      return new Promise((resolve, reject) => {
        listAll().then(res => {
          commit('SET_DICT', res.data)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default dict
