// import {getDeptList} from "@/api/modules/dept";
// import {dictDataType} from "@/api/modules/dict";
import { dictionary, dictionaryDefine } from './dictionary-define'

const state = {
	...dictionary,
}

const getters = {
}

const mutations = {
	SET_DICT_LIST(state: any, { listName, mapName, objMapName, data }: any) {
		// const map = new Map()
		// const objMap = new Map()
		// if (data.length > 0) {
		// 	data.forEach((v: any) => {
		// 		v.selectLabel = v.dictLabel
		// 		v.selectValue = v.dictValue
		// 		map.set(v.dictValue, v.dictLabel)
		// 		objMap.set(v.dictValue, v)
		// 	})
		// }
		// state[listName] = data
		// state[mapName] = map
		// state[objMapName] = objMap
	},
}

const actions = {
	LOAD_DICT_LIST({ commit }: any, type: any) {
		// return new Promise((resolve, reject) => {
		// 	if (state[dictionaryDefine[type][0]].length === 0) {
		// 		dictDataType(type).then((res: any) => {
		// 			commit('SET_DICT_LIST', {
		// 				listName: dictionaryDefine[type][0],
		// 				mapName: dictionaryDefine[type][1],
		// 				objMapName: dictionaryDefine[type]?.[2],
		// 				data: res.data
		// 			})
		// 			resolve(res.data)
		// 		}).catch((e: any) => {
		// 			console.log('e: ', e);
		// 			reject('获取'+dictionaryDefine[type][0]+'字典错误')
		// 		})
		// 	} else {
		// 		resolve(state[dictionaryDefine[type][0]])
		// 	}
		// })
	},
}

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