const dictData = {} const emptyDict = [] function normalizeOptions(options) { if (!Array.isArray(options)) { return emptyDict } return options.map((option) => { const label = option.label || option.name || option.value const value = option.value || label return { ...option, label, name: option.name || label, value } }) } export default { getDictDataByType(type) { return normalizeOptions(dictData[type]) }, getDictLabel(type, value) { if (value === undefined || value === null || value === "") { return "-" } const matched = normalizeOptions(dictData[type]).find((option) => String(option.value) === String(value)) return matched ? matched.label : value } }