58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
/**
|
|
* 求职意向名称解析工具
|
|
* 从 store 中的分类树数据里,根据意向 ID/Code 查找对应名称
|
|
*/
|
|
import store from '@/stores'
|
|
|
|
/**
|
|
* 获取意向岗位类型名称列表
|
|
* 根据 jobIntention.categoryIds 在 jobCategories 树中查找名称
|
|
*/
|
|
export function getIntentionCategoryNames(): string[] {
|
|
const ids = store.state.jobIntention.categoryIds || []
|
|
if (ids.length === 0) return []
|
|
const names: string[] = []
|
|
for (const group of store.state.jobCategories) {
|
|
for (const child of group.children || []) {
|
|
for (const leaf of child.children || []) {
|
|
if (ids.includes(Number(leaf.id))) names.push(leaf.name)
|
|
}
|
|
}
|
|
}
|
|
return names
|
|
}
|
|
|
|
/**
|
|
* 获取意向城市名称列表
|
|
* 根据 jobIntention.regionCodes 在 regions 树中查找名称
|
|
*/
|
|
export function getIntentionRegionNames(): string[] {
|
|
const codes = store.state.jobIntention.regionCodes || []
|
|
if (codes.length === 0) return []
|
|
const names: string[] = []
|
|
for (const province of store.state.regions) {
|
|
if (codes.includes(province.code)) { names.push(province.name); continue }
|
|
for (const city of province.children || []) {
|
|
if (codes.includes(city.code)) names.push(city.name)
|
|
}
|
|
}
|
|
return names
|
|
}
|
|
|
|
/**
|
|
* 获取意向行业名称列表
|
|
* 根据 jobIntention.industryIds 在 industries 树中查找名称
|
|
*/
|
|
export function getIntentionIndustryNames(): string[] {
|
|
const ids = store.state.jobIntention.industryIds || []
|
|
if (ids.length === 0) return []
|
|
const names: string[] = []
|
|
for (const group of store.state.industries) {
|
|
if (ids.includes(Number(group.id))) { names.push(group.name); continue }
|
|
for (const child of group.children || []) {
|
|
if (ids.includes(Number(child.id))) names.push(child.name)
|
|
}
|
|
}
|
|
return names
|
|
}
|