/**
 * vuex getter
 */
import dictEnum from '@/enum/dict';
export default {
  user: (state) => state.user,
  theme: (state) => state.theme,
  dict: (state) => state.dict,
  // 根据字典enumName  和 dictCode 获取字典项
  getDict: (state) => (enumName, dictCode) =>
    (state.dict[dictEnum[enumName]] || []).find(
      (item) => item.dictCode === dictCode
    ) || {},
  // 根据字典enumName  和 dictCode 获取字典 值（名称
  getDictValue: (state) => (enumName, dictCode) => {
    const obj = (state.dict[dictEnum[enumName]] || []).find((item) => {
      return item.dictCode === dictCode;
    });

    return obj && obj.dictValue;
  }
};
