fix:优化token过期逻辑、考勤管理调整
parent
de90d5284a
commit
fb6a791e64
@ -1,6 +1,6 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/** 分页查询考勤任务 */
|
||||
export const getTaskPage = (params) => {
|
||||
return request.get('/attendance/task/page', { params })
|
||||
/** 分页查询考勤记录 */
|
||||
export const getRecordPage = (params) => {
|
||||
return request.get('/attendance/record/page', { params })
|
||||
}
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
import { ref } from 'vue'
|
||||
import { getCourseList, getTeacherList, getClassList, getRoomsList } from '@/api/info'
|
||||
|
||||
const courseMap = ref({})
|
||||
const teacherMap = ref({})
|
||||
const classMap = ref({})
|
||||
const roomMap = ref({})
|
||||
let loadPromise = null
|
||||
|
||||
const loadNameMaps = () => {
|
||||
if (!loadPromise) {
|
||||
loadPromise = Promise.all([
|
||||
getCourseList(),
|
||||
getTeacherList(),
|
||||
getClassList(),
|
||||
getRoomsList()
|
||||
]).then(([courseRes, teacherRes, classRes, roomRes]) => {
|
||||
const toMap = (list, nameKey = 'name') => {
|
||||
const map = {}
|
||||
;(list || []).forEach((item) => { map[item.id] = item[nameKey] })
|
||||
return map
|
||||
}
|
||||
courseMap.value = toMap(courseRes.data, 'courseName')
|
||||
teacherMap.value = toMap(teacherRes.data, 'name')
|
||||
classMap.value = toMap(classRes.data, 'className')
|
||||
roomMap.value = toMap(roomRes.data, 'roomName')
|
||||
}).catch((e) => {
|
||||
// 加载失败保留空映射,重置 promise 以便下次可重试
|
||||
console.error('[useNameMaps] 加载名称映射失败:', e)
|
||||
loadPromise = null
|
||||
})
|
||||
}
|
||||
return loadPromise
|
||||
}
|
||||
|
||||
/** 根据 ID 获取名称,兜底返回 ID 本身 */
|
||||
const courseName = (id) => courseMap.value[id] ?? id ?? ''
|
||||
const teacherName = (id) => teacherMap.value[id] ?? id ?? ''
|
||||
const className = (id) => classMap.value[id] ?? id ?? ''
|
||||
const roomName = (id) => roomMap.value[id] ?? id ?? ''
|
||||
|
||||
export function useNameMaps() {
|
||||
return { loadNameMaps, courseName, teacherName, className, roomName }
|
||||
}
|
||||
Loading…
Reference in New Issue