个人资料和岗位列表联调,简历优化部分页面
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import store from '@/stores/index'
|
||||
import type { IndustryItem } from '@/api/common'
|
||||
|
||||
/**
|
||||
* 根据行业 ID 从 store 行业树中查找对应的行业名称
|
||||
* 遍历一级→二级,匹配到即返回名称,未匹配返回 ID 本身
|
||||
* @param id 行业 ID(如 12)
|
||||
* @returns 匹配到的行业名称,未匹配则返回 ID 字符串
|
||||
*/
|
||||
export function resolveIndustryName(id: number): string {
|
||||
if (!id && id !== 0) return ''
|
||||
const industries: IndustryItem[] = store.state.industries
|
||||
for (const parent of industries) {
|
||||
if (String(parent.id) === String(id)) return parent.name
|
||||
for (const child of parent.children) {
|
||||
if (String(child.id) === String(id)) return child.name
|
||||
}
|
||||
}
|
||||
return String(id)
|
||||
}
|
||||
Reference in New Issue
Block a user