个人资料和岗位列表联调,简历优化部分页面
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)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import store from '@/stores/index'
|
||||
import type { JobCategoryItem } from '@/api/common'
|
||||
|
||||
/**
|
||||
* 根据岗位分类 ID 从 store 岗位树中查找对应的岗位名称
|
||||
* 遍历一级→二级→三级,匹配到即返回名称,未匹配返回 ID 本身
|
||||
* @param id 岗位分类 ID(如 305)
|
||||
* @returns 匹配到的岗位名称,未匹配则返回 ID 字符串
|
||||
*/
|
||||
export function resolveJobCategoryName(id: number): string {
|
||||
if (!id && id !== 0) return ''
|
||||
const categories: JobCategoryItem[] = store.state.jobCategories
|
||||
for (const lv1 of categories) {
|
||||
if (String(lv1.id) === String(id)) return lv1.name
|
||||
for (const lv2 of lv1.children) {
|
||||
if (String(lv2.id) === String(id)) return lv2.name
|
||||
if (lv2.children) {
|
||||
for (const lv3 of lv2.children) {
|
||||
if (String(lv3.id) === String(id)) return lv3.name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return String(id)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import store from '@/stores'
|
||||
|
||||
/**
|
||||
* 创建 axios 实例
|
||||
@@ -21,6 +22,9 @@ service.interceptors.response.use(
|
||||
(error) => {
|
||||
const status = error.response?.status
|
||||
if (status === 401) {
|
||||
// 同步重置前端登录状态,弹出登录框
|
||||
store.commit('SET_AUTHENTICATED', false)
|
||||
store.dispatch('openLogin', window.location.pathname)
|
||||
ElMessage.error('登录已过期,请重新登录')
|
||||
} else {
|
||||
ElMessage.error(error.response?.data?.msg || '请求失败')
|
||||
|
||||
Reference in New Issue
Block a user