// 通用:根据字典列表和 value 获取 label 文本 export function getLabelValue( list: Array<{ label: string; value: string | number }>, value: string | number | null | undefined, ): string { if (!list || !Array.isArray(list)) return '' const item = list.find((it: any) => String(it.value) === String(value)) return item ? item.label : '' } // 通用:根据指定 key/value 字段,从列表中取 label(原 global.getLabelValueByPropes) export function getLabelValueByProps( list: any[], key: string | number | null | undefined, props: { key: string; value: string }, ): string { if (!list || !Array.isArray(list)) return '' const item = list.find((it: any) => String(it[props.key]) === String(key)) return item ? item[props.value] : '' } // 通用:根据 key 取“专业名称 || 学制年制”展示(原 global.getLabelValueByPropes2) export function getMajorLabelWithYears( list: any[], key: string | number | null | undefined, props: { key: string; value: string }, ): string { if (!list || !Array.isArray(list)) return '' const item = list.find((it: any) => String(it[props.key]) === String(key)) if (!item) return '' const majorName = item[props.value] ?? '' const years = item.xz != null ? `${item.xz} 年制` : '' return years ? `${majorName} || ${years}` : majorName }