export default function createEnum(dictList) {
  const valueToItemMap = {};
  const nameToItemMap = {};
  dictList.forEach((dictItem) => {
    nameToItemMap[dictItem["name"]] = dictItem;
    valueToDescMap[dictItem["value"]] = dictItem;
  });

  return {
    ...nameToValueMap,
    options: dictList,
    getValueByName(enumName) {
      return nameToItemMap[enumName].value;
    },
    getLabelByValue(value) {
      return valueToItemMap[value].label || '';
    },
    getLabelByName(name) {
      return nameToItemMap[name].label
    },
    getTagByValue(value) {
      return valueToItemMap[name].tag || ''
    }
  };
}
// 角色状态
export const RULE_STATUS = createEnum([
  {
    value: 0,
    label: "启用",
    name: "enabled",
  },
  {
    value: 1,
    label: "停用",
    name: "disabled",
  },
]);

// 账号状态
export const ACCOUNT_STATUS = createEnum([
  {
    value: 0,
    label: "启用",
    name: "enabled",
  },
  {
    value: 1,
    label: "停用",
    name: "disabled",
  },
]);

// 院区状态
export const WARD_STATUS = createEnum([
  {
    value: 0,
    label: "启用",
    name: "enabled",
  },
  {
    value: 1,
    label: "停用",
    name: "disabled",
  },
])
// 是否为本院区
export const IS_MY_HOSPITAL = createEnum([
  {
    value: 1,
    label: "是",
    name: "is"
  },
  {
    value: 0,
    label: "否",
    name: "no"
  }
])
