990 lines
46 KiB
Vue
990 lines
46 KiB
Vue
<script setup lang="ts">
|
|
import { getDisplayLocale } from '../i18n'
|
|
import { useI18n } from 'vue-i18n'
|
|
const { t } = useI18n()
|
|
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
|
import { Plus, Promotion, Refresh, UserFilled, Setting, Search, MagicStick } from '@element-plus/icons-vue'
|
|
import http, { apiErrorMessage } from '../api/http'
|
|
import { useAuthStore } from '../stores/auth'
|
|
import { academicTermLabel, academicTermOptionClass, defaultAcademicTermId } from '../utils/academicTerms'
|
|
|
|
const auth = useAuthStore()
|
|
const isManager = computed(() =>
|
|
auth.user?.roles.some((r) => ['SuperAdmin', 'AcademicAdmin'].includes(r)) ?? false)
|
|
const isTeacher = computed(() => auth.user?.roles.includes('Teacher') && !isManager.value)
|
|
const plans = ref<any[]>([])
|
|
const selected = ref<any | null>(null)
|
|
const personal = ref<any[]>([])
|
|
const teachingSessions = ref<any[]>([])
|
|
const scoreDialogVisible = ref(false)
|
|
const scoreSession = ref<any | null>(null)
|
|
const scoreMap = reactive<Record<string, number | null>>({})
|
|
const scoreSaving = ref(false)
|
|
const terms = ref<any[]>([])
|
|
const tasks = ref<any[]>([])
|
|
const rooms = ref<any[]>([])
|
|
const teachers = ref<any[]>([])
|
|
const teacherOptionsLoading = ref(false)
|
|
let teacherOptionsRequestId = 0
|
|
const buildings = ref<any[]>([])
|
|
const timeSlots = ref<any[]>([])
|
|
const loading = ref(false)
|
|
const arrangeLoading = ref(false)
|
|
const arrangementJob = ref<any | null>(null)
|
|
let arrangementPollTimer: ReturnType<typeof setTimeout> | null = null
|
|
const arrangementJobRunning = computed(() =>
|
|
['Queued', 'Running'].includes(arrangementJob.value?.status))
|
|
const arrangementProgress = computed(() =>
|
|
arrangementJob.value?.status === 'Queued' ? 10
|
|
: arrangementJob.value?.status === 'Running' ? 60
|
|
: arrangementJob.value?.status === 'Succeeded' ? 100 : 0)
|
|
const planDialog = ref(false)
|
|
const sessionDialog = ref(false)
|
|
const editingSession = ref<any | null>(null)
|
|
const rosterDrawer = ref(false)
|
|
const roster = ref<any | null>(null)
|
|
const enrollmentDialog = ref(false)
|
|
const enrollmentSession = ref<any | null>(null)
|
|
const eligibleStudents = ref<any[]>([])
|
|
const eligibleLoading = ref(false)
|
|
const selectedStudentIds = ref<string[]>([])
|
|
const selectedTaskIds = ref<string[]>([])
|
|
const selectedSessionIds = ref<string[]>([])
|
|
const planForm = reactive<Record<string, any>>({})
|
|
const sessionForm = reactive<Record<string, any>>({})
|
|
const taskFilter = reactive({ keyword: '', collegeId: '', courseNature: '' })
|
|
const sessionFilter = reactive({ keyword: '', allocation: '' })
|
|
const statusLabels = computed<Record<string, string>>(() => ({
|
|
Draft: t('examsScript.k0'), Published: t('examsScript.k1'), Archived: t('examsScript.k2'),
|
|
}))
|
|
const courseNatureLabels = computed<Record<string, string>>(() => ({
|
|
GeneralRequired: t('examsScript.k3'),
|
|
GeneralElective: t('examsScript.k4'),
|
|
MajorRequired: t('examsScript.k5'),
|
|
MajorElective: t('examsScript.k6'),
|
|
Practice: t('examsScript.k7'),
|
|
}))
|
|
const taskColleges = computed(() => {
|
|
const values = new Map<string, string>()
|
|
tasks.value.forEach((task: any) => values.set(task.collegeId, task.collegeName))
|
|
return Array.from(values, ([id, name]) => ({ id, name }))
|
|
})
|
|
const filteredTasks = computed(() => {
|
|
const keyword = taskFilter.keyword.trim().toLowerCase()
|
|
const arrangedIds = new Set((selected.value?.sessions ?? [])
|
|
.filter((session: any) => session.id !== editingSession.value?.id)
|
|
.map((session: any) => session.teachingTaskId))
|
|
return tasks.value.filter((task: any) => {
|
|
if (arrangedIds.has(task.id)) return false
|
|
if (taskFilter.collegeId && task.collegeId !== taskFilter.collegeId) return false
|
|
if (taskFilter.courseNature && task.courseNature !== taskFilter.courseNature) return false
|
|
if (!keyword) return true
|
|
return [task.taskNumber, task.courseCode, task.courseName, task.name,
|
|
...(task.teacherNames ?? []), ...(task.classNames ?? [])]
|
|
.some((value: any) => String(value ?? '').toLowerCase().includes(keyword))
|
|
})
|
|
})
|
|
const filteredSessions = computed(() => {
|
|
const keyword = sessionFilter.keyword.trim().toLowerCase()
|
|
return (selected.value?.sessions ?? []).filter((session: any) => {
|
|
if (sessionFilter.allocation === 'room' && session.classroomId) return false
|
|
if (sessionFilter.allocation === 'invigilator' &&
|
|
session.invigilatorIds.length >= session.requiredInvigilatorCount) return false
|
|
if (sessionFilter.allocation === 'complete' &&
|
|
(!session.classroomId || session.invigilatorIds.length < session.requiredInvigilatorCount)) return false
|
|
if (!keyword) return true
|
|
return [session.taskNumber, session.courseCode, session.courseName, session.taskName]
|
|
.some((value: any) => String(value ?? '').toLowerCase().includes(keyword))
|
|
})
|
|
})
|
|
|
|
function timeText(startsAt: string) {
|
|
return new Date(startsAt).toLocaleTimeString(getDisplayLocale(), { hour: '2-digit', minute: '2-digit', hour12: false })
|
|
}
|
|
function dateOnlyText(value: string) {
|
|
if (!value) return ''
|
|
return new Intl.DateTimeFormat(getDisplayLocale(), { month: '2-digit', day: '2-digit', weekday: 'short' }).format(new Date(value))
|
|
}
|
|
function periodLabel(session: any) {
|
|
const end = session.startPeriod + session.periodCount - 1
|
|
const startSlot = timeSlots.value.find((s: any) => s.periodNumber === session.startPeriod)
|
|
const endSlot = timeSlots.value.find((s: any) => s.periodNumber === end)
|
|
const timeRange = startSlot && endSlot ? `${startSlot.startsAt}—${endSlot.endsAt}` : ''
|
|
return t('examsScript.periodRange', { start: session.startPeriod, end, time: timeRange ? ' · ' + timeRange : '' })
|
|
}
|
|
|
|
async function load() {
|
|
loading.value = true
|
|
try {
|
|
if (!isManager.value) {
|
|
personal.value = (await http.get('/makeup-exams/my-schedule')).data
|
|
if (isTeacher.value) {
|
|
teachingSessions.value = (await http.get('/makeup-exams/my-teaching-sessions')).data
|
|
}
|
|
return
|
|
}
|
|
plans.value = (await http.get('/makeup-exams/plans')).data
|
|
const plan = plans.value.find((x) => x.id === selected.value?.id)
|
|
?? plans.value.find((x) => x.termIsCurrent)
|
|
?? plans.value[0]
|
|
if (plan) await selectPlan(plan.id)
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
finally { loading.value = false }
|
|
}
|
|
async function selectPlan(id: string) {
|
|
stopArrangementPolling()
|
|
selected.value = (await http.get(`/makeup-exams/plans/${id}`)).data
|
|
selectedSessionIds.value = []
|
|
await Promise.all([
|
|
loadPlanResources(selected.value.academicTermId),
|
|
restoreArrangementJob(id),
|
|
])
|
|
}
|
|
async function loadPlanResources(academicTermId: string) {
|
|
const [taskRes, slotRes] = await Promise.all([
|
|
http.get('/teaching-tasks/options', {
|
|
params: { academicTermId, status: 'Published' },
|
|
}),
|
|
http.get('/makeup-exams/time-slots-for-term', { params: { academicTermId } }),
|
|
])
|
|
tasks.value = taskRes.data
|
|
timeSlots.value = slotRes.data
|
|
}
|
|
function openPlan() {
|
|
Object.assign(planForm, {
|
|
academicTermId: defaultAcademicTermId(terms.value),
|
|
name: '', notes: '',
|
|
})
|
|
planDialog.value = true
|
|
}
|
|
async function savePlan() {
|
|
try {
|
|
await http.post('/makeup-exams/plans', planForm)
|
|
planDialog.value = false
|
|
await load()
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
function openSession(existing?: any) {
|
|
editingSession.value = existing ?? null
|
|
selectedTaskIds.value = existing ? [existing.teachingTaskId] : []
|
|
Object.assign(taskFilter, { keyword: '', collegeId: '', courseNature: '' })
|
|
const firstSlot = timeSlots.value[0]
|
|
Object.assign(sessionForm, {
|
|
teachingTaskId: existing?.teachingTaskId ?? undefined,
|
|
classroomId: existing?.classroomId ?? undefined,
|
|
examDate: existing?.examDate ?? '',
|
|
startPeriod: existing?.startPeriod ?? (firstSlot?.periodNumber ?? 1),
|
|
periodCount: existing?.periodCount ?? 2,
|
|
requiredBuildingId: existing?.requiredBuildingId ?? undefined,
|
|
requiredBuildingIds: parseBuildingIds(existing?.requiredBuildingIds),
|
|
requiredInvigilatorCount: existing?.requiredInvigilatorCount ?? 2,
|
|
invigilatorIds: existing?.invigilatorIds ?? [],
|
|
notes: existing?.notes ?? '',
|
|
})
|
|
if (existing?.invigilatorIds?.length) {
|
|
const selected = existing.invigilatorIds.map((id: string, index: number) => ({
|
|
id, teacherNumber: '', name: existing.invigilatorNames?.[index] ?? t('examsScript.k11'),
|
|
}))
|
|
teachers.value = [...selected, ...teachers.value.filter((item: any) => !existing.invigilatorIds.includes(item.id))]
|
|
}
|
|
sessionDialog.value = true
|
|
}
|
|
|
|
async function searchTeacherOptions(keyword = '') {
|
|
const requestId = ++teacherOptionsRequestId
|
|
teacherOptionsLoading.value = true
|
|
try {
|
|
const { data } = await http.get('/personnel/teachers', { params: {
|
|
page: 1, pageSize: 50, teacherStatus: 'Active', keyword: keyword.trim() || undefined,
|
|
} })
|
|
if (requestId !== teacherOptionsRequestId) return
|
|
const selectedIds = new Set(sessionForm.invigilatorIds ?? [])
|
|
const selected = teachers.value.filter((item: any) => selectedIds.has(item.id))
|
|
teachers.value = [...selected, ...data.items.filter((item: any) => !selectedIds.has(item.id))]
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
finally { if (requestId === teacherOptionsRequestId) teacherOptionsLoading.value = false }
|
|
}
|
|
function teacherOptionLabel(teacher: any) {
|
|
return teacher.teacherNumber ? `${teacher.teacherNumber} · ${teacher.name}` : teacher.name
|
|
}
|
|
async function saveSession() {
|
|
try {
|
|
const payload = { ...sessionForm }
|
|
if (editingSession.value) {
|
|
await http.put(`/makeup-exams/plans/${selected.value.id}/sessions/${editingSession.value.id}`, payload)
|
|
} else {
|
|
if (selectedTaskIds.value.length === 0) {
|
|
ElMessage.warning(t('examsScript.k12'))
|
|
return
|
|
}
|
|
const res = await http.post(`/makeup-exams/plans/${selected.value.id}/sessions/batch`, {
|
|
teachingTaskIds: selectedTaskIds.value,
|
|
examDate: payload.examDate,
|
|
startPeriod: payload.startPeriod,
|
|
periodCount: payload.periodCount,
|
|
requiredBuildingId: payload.requiredBuildingId,
|
|
requiredBuildingIds: payload.requiredBuildingIds,
|
|
requiredInvigilatorCount: payload.requiredInvigilatorCount,
|
|
notes: payload.notes,
|
|
})
|
|
ElMessage.success(t('examsScript.createdMakeups', { count: res.data.createdCount }))
|
|
}
|
|
sessionDialog.value = false
|
|
editingSession.value = null
|
|
await selectPlan(selected.value.id)
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
async function removeSession(row: any) {
|
|
try {
|
|
await ElMessageBox.confirm(t('examsScript.removeMakeup', { name: row.courseName }), t('examsScript.k38'), { type: 'warning' })
|
|
await http.delete(`/makeup-exams/plans/${selected.value.id}/sessions/${row.id}`)
|
|
await selectPlan(selected.value.id)
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
function selectFilteredTasks() {
|
|
selectedTaskIds.value = Array.from(new Set([
|
|
...selectedTaskIds.value,
|
|
...filteredTasks.value.map((task: any) => task.id),
|
|
])).slice(0, 100)
|
|
}
|
|
function clearFilteredTasks() {
|
|
const visibleIds = new Set(filteredTasks.value.map((task: any) => task.id))
|
|
selectedTaskIds.value = selectedTaskIds.value.filter(id => !visibleIds.has(id))
|
|
}
|
|
function toggleTaskSelection(id: string, checked: boolean) {
|
|
if (checked && selectedTaskIds.value.length >= 100) {
|
|
ElMessage.warning(t('examsScript.k17'))
|
|
return
|
|
}
|
|
selectedTaskIds.value = checked
|
|
? Array.from(new Set([...selectedTaskIds.value, id]))
|
|
: selectedTaskIds.value.filter(value => value !== id)
|
|
}
|
|
function selectFilteredSessions() {
|
|
selectedSessionIds.value = filteredSessions.value.map((session: any) => session.id)
|
|
}
|
|
function clearSessionSelection() {
|
|
selectedSessionIds.value = []
|
|
}
|
|
function toggleSessionSelection(id: string, checked: boolean) {
|
|
selectedSessionIds.value = checked
|
|
? Array.from(new Set([...selectedSessionIds.value, id]))
|
|
: selectedSessionIds.value.filter(value => value !== id)
|
|
}
|
|
async function autoArrange(mode: 'rooms' | 'invigilators' | 'all') {
|
|
try {
|
|
const target = selectedSessionIds.value.length
|
|
? t('examsScript.selected', { count: selectedSessionIds.value.length })
|
|
: t('examsScript.k19')
|
|
const action = mode === 'rooms' ? t('examsScript.k20')
|
|
: mode === 'invigilators' ? t('examsScript.k21') : t('examsScript.k22')
|
|
await ElMessageBox.confirm(
|
|
t('examsScript.assignMakeup', { target, action }),
|
|
t('examsScript.assignTitle', { action }), { type: 'info', confirmButtonText: t('examsScript.k25') })
|
|
arrangeLoading.value = true
|
|
const res = await http.post(`/makeup-exams/plans/${selected.value.id}/auto-arrange`, {
|
|
sessionIds: selectedSessionIds.value,
|
|
assignClassrooms: mode !== 'invigilators',
|
|
assignInvigilators: mode !== 'rooms',
|
|
})
|
|
arrangementJob.value = {
|
|
id: res.data.jobId,
|
|
planId: selected.value.id,
|
|
status: res.data.status,
|
|
currentStep: t('examsScript.k26'),
|
|
}
|
|
ElMessage.success(res.data.message)
|
|
scheduleArrangementPoll(true)
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
} finally { arrangeLoading.value = false }
|
|
}
|
|
async function restoreArrangementJob(planId: string) {
|
|
try {
|
|
const res = await http.get(
|
|
`/makeup-exams/plans/${planId}/arrangement-job`,
|
|
)
|
|
if (res.status === 204 || !res.data ||
|
|
!['Queued', 'Running'].includes(res.data.status)) {
|
|
arrangementJob.value = null
|
|
return
|
|
}
|
|
arrangementJob.value = res.data
|
|
scheduleArrangementPoll(false)
|
|
} catch {
|
|
arrangementJob.value = null
|
|
}
|
|
}
|
|
function scheduleArrangementPoll(notifyTerminal: boolean) {
|
|
stopArrangementPolling()
|
|
arrangementPollTimer = setTimeout(
|
|
() => pollArrangementJob(notifyTerminal),
|
|
1500,
|
|
)
|
|
}
|
|
async function pollArrangementJob(notifyTerminal: boolean) {
|
|
if (!arrangementJob.value?.id) return
|
|
const jobId = arrangementJob.value.id
|
|
const planId = selected.value?.id
|
|
try {
|
|
const { data: job } = await http.get(
|
|
`/makeup-exams/arrangement-jobs/${jobId}`,
|
|
)
|
|
if (selected.value?.id !== planId ||
|
|
arrangementJob.value?.id !== jobId) return
|
|
arrangementJob.value = job
|
|
if (['Queued', 'Running'].includes(job.status)) {
|
|
scheduleArrangementPoll(notifyTerminal)
|
|
return
|
|
}
|
|
stopArrangementPolling()
|
|
if (job.status === 'Succeeded') {
|
|
const planId = selected.value?.id
|
|
if (planId) await selectPlan(planId)
|
|
if (notifyTerminal) ElMessage.success(job.resultMessage || t('examsScript.k39'))
|
|
} else if (notifyTerminal) {
|
|
ElMessage.error(job.errorMessage || t('examsScript.k40'))
|
|
}
|
|
} catch {
|
|
if (selected.value?.id === planId &&
|
|
arrangementJob.value?.id === jobId) {
|
|
scheduleArrangementPoll(notifyTerminal)
|
|
}
|
|
}
|
|
}
|
|
function stopArrangementPolling() {
|
|
if (arrangementPollTimer) {
|
|
clearTimeout(arrangementPollTimer)
|
|
arrangementPollTimer = null
|
|
}
|
|
}
|
|
async function publishPlan() {
|
|
try {
|
|
await ElMessageBox.confirm(t('examsScript.k29'), t('examsScript.k41'), {
|
|
type: 'warning', confirmButtonText: t('examsScript.k31'),
|
|
})
|
|
await http.post(`/makeup-exams/plans/${selected.value.id}/publish`)
|
|
await load()
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
async function showRoster(row: any) {
|
|
try {
|
|
roster.value = (await http.get(`/makeup-exams/sessions/${row.id}/roster`)).data
|
|
rosterDrawer.value = true
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
function periodOptions() {
|
|
const max = timeSlots.value.length > 0 ? timeSlots.value[timeSlots.value.length - 1].periodNumber : 12
|
|
return Array.from({ length: max }, (_, i) => ({ value: i + 1, label: t('examsScript.period', { number: i + 1 }) }))
|
|
}
|
|
function periodCountOptions() {
|
|
return [1, 2, 3, 4].map(n => ({ value: n, label: t('examsScript.subperiod', { number: n }) }))
|
|
}
|
|
function classroomLabel(room: any) {
|
|
return t('examsScript.room', { name: room.name, capacity: room.capacity, building: room.buildingName })
|
|
}
|
|
function filteredRooms() {
|
|
if (!sessionForm.requiredBuildingIds || sessionForm.requiredBuildingIds.length === 0) return rooms.value
|
|
return rooms.value.filter((r: any) => sessionForm.requiredBuildingIds.includes(r.buildingId))
|
|
}
|
|
function parseBuildingIds(raw: string | undefined | null): string[] {
|
|
if (!raw) return []
|
|
try { return JSON.parse(raw) } catch { return [] }
|
|
}
|
|
|
|
function openEnrollment(session: any) {
|
|
enrollmentSession.value = session
|
|
eligibleStudents.value = []
|
|
selectedStudentIds.value = []
|
|
enrollmentDialog.value = true
|
|
}
|
|
async function loadEligibleStudents() {
|
|
if (!enrollmentSession.value) return
|
|
eligibleLoading.value = true
|
|
try {
|
|
eligibleStudents.value = (await http.get('/makeup-exams/eligible-students', {
|
|
params: { teachingTaskId: enrollmentSession.value.teachingTaskId },
|
|
})).data
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
finally { eligibleLoading.value = false }
|
|
}
|
|
function onEnrollmentSelection(rows: any[]) {
|
|
selectedStudentIds.value = rows.map((r: any) => r.studentId)
|
|
}
|
|
async function enrollSelectedStudents() {
|
|
if (!enrollmentSession.value || selectedStudentIds.value.length === 0) return
|
|
try {
|
|
await http.post(`/makeup-exams/sessions/${enrollmentSession.value.id}/enroll`, {
|
|
studentIds: selectedStudentIds.value,
|
|
})
|
|
ElMessage.success(t('examsScript.enrolled', { count: selectedStudentIds.value.length }))
|
|
enrollmentDialog.value = false
|
|
await selectPlan(selected.value.id)
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
async function archivePlan() {
|
|
try {
|
|
await ElMessageBox.confirm(t('examsScript.k42'), t('examsScript.k43'), {
|
|
type: 'info', confirmButtonText: t('examsScript.k44'),
|
|
})
|
|
await http.post(`/makeup-exams/plans/${selected.value.id}/archive`)
|
|
await load()
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
// ── Score entry (teacher) ──
|
|
function openScoreDialog(session: any) {
|
|
scoreSession.value = session
|
|
Object.keys(scoreMap).forEach(k => delete scoreMap[k])
|
|
if (session.enrollments) {
|
|
for (const e of session.enrollments) {
|
|
scoreMap[e.studentId] = e.makeupScore ?? null
|
|
}
|
|
}
|
|
scoreDialogVisible.value = true
|
|
}
|
|
function onScoreInput(studentId: string, val: any) {
|
|
scoreMap[studentId] = val ?? null
|
|
}
|
|
async function submitScores() {
|
|
if (!scoreSession.value) return
|
|
const entries = Object.entries(scoreMap)
|
|
.filter(([, v]) => v !== null && v !== undefined)
|
|
.map(([studentId, score]) => ({ studentId, score: Number(score) }))
|
|
if (entries.length === 0) { ElMessage.warning(t('examsScript.k45')); return }
|
|
scoreSaving.value = true
|
|
try {
|
|
await http.put(`/makeup-exams/sessions/${scoreSession.value.id}/scores`, entries)
|
|
ElMessage.success(t('examsScript.saved', { count: entries.length }))
|
|
scoreDialogVisible.value = false
|
|
await load()
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
finally { scoreSaving.value = false }
|
|
}
|
|
|
|
// ── Auto-create job ──
|
|
const autoJobId = ref<string | null>(null)
|
|
const autoJobStatus = ref<string | null>(null)
|
|
const autoJobProgress = ref(0)
|
|
const autoJobMessage = ref('')
|
|
let pollTimer: ReturnType<typeof setInterval> | null = null
|
|
|
|
async function startAutoCreate() {
|
|
try {
|
|
await ElMessageBox.confirm(
|
|
t('examsScript.k46'),
|
|
t('examsScript.k47'), { type: 'info', confirmButtonText: t('examsScript.k48') })
|
|
const res = await http.post(`/makeup-exams/plans/${selected.value.id}/auto-create`)
|
|
autoJobId.value = res.data.jobId
|
|
autoJobStatus.value = 'Queued'
|
|
autoJobProgress.value = 0
|
|
autoJobMessage.value = t('examsScript.k49')
|
|
startPolling()
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
function startPolling() {
|
|
if (pollTimer) clearInterval(pollTimer)
|
|
pollTimer = setInterval(pollAutoJob, 1500)
|
|
}
|
|
|
|
async function pollAutoJob() {
|
|
if (!autoJobId.value) return
|
|
try {
|
|
const res = await http.get(`/makeup-exams/auto-jobs/${autoJobId.value}`)
|
|
const job = res.data
|
|
autoJobStatus.value = job.status
|
|
if (job.totalCourses > 0) {
|
|
autoJobProgress.value = Math.round((job.processedCourses / job.totalCourses) * 100)
|
|
}
|
|
autoJobMessage.value = job.status === 'Succeeded'
|
|
? t('examsScript.autoSuccess', { sessions: job.createdSessions, students: job.enrolledStudents })
|
|
: job.status === 'Failed'
|
|
? t('examsScript.autoFailed', { error: job.errorMessage || t('examsScript.k50') })
|
|
: t('examsScript.autoProgress', { processed: job.processedCourses, total: job.totalCourses })
|
|
if (job.status === 'Succeeded' || job.status === 'Failed') {
|
|
stopPolling()
|
|
if (job.status === 'Succeeded') {
|
|
ElMessage.success(autoJobMessage.value)
|
|
await selectPlan(selected.value.id)
|
|
} else {
|
|
ElMessage.error(autoJobMessage.value)
|
|
}
|
|
}
|
|
} catch (_) { stopPolling() }
|
|
}
|
|
|
|
function stopPolling() {
|
|
if (pollTimer) { clearInterval(pollTimer); pollTimer = null }
|
|
}
|
|
|
|
onMounted(async () => {
|
|
try {
|
|
if (isManager.value) {
|
|
const [termRes, roomRes, teacherRes, buildingRes] = await Promise.all([
|
|
http.get('/base-data/terms'),
|
|
http.get('/base-data/classrooms'),
|
|
http.get('/personnel/teachers', { params: { page: 1, pageSize: 50, teacherStatus: 'Active' } }),
|
|
http.get('/base-data/buildings'),
|
|
])
|
|
terms.value = termRes.data
|
|
rooms.value = roomRes.data
|
|
teachers.value = teacherRes.data.items
|
|
buildings.value = buildingRes.data
|
|
}
|
|
await load()
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
})
|
|
onBeforeUnmount(() => {
|
|
stopPolling()
|
|
stopArrangementPolling()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="page-stack exam-page">
|
|
<section class="page-intro">
|
|
<div>
|
|
<span class="section-kicker">MAKE-UP EXAMINATION</span>
|
|
<h2>{{ isManager ? t('examsTemplate.k31') : isTeacher ? t('examsTemplate.k32') : t('examsTemplate.k33') }}</h2>
|
|
<p>{{ isManager ? t('examsTemplate.k34') : t('examsTemplate.k35') }}</p>
|
|
</div>
|
|
<el-button v-if="isManager" type="primary" :icon="Plus" @click="openPlan">{{ t('examsTemplate.k48') }}</el-button>
|
|
<el-button v-else :icon="Refresh" @click="load">{{ t('workflowBatch.k6') }}</el-button>
|
|
</section>
|
|
|
|
<template v-if="isManager">
|
|
<section class="exam-plan-strip">
|
|
<button v-for="plan in plans" :key="plan.id" :class="{ active: selected?.id === plan.id, 'historical-record': !plan.termIsCurrent && !plan.termIsArchived, 'archived-record': plan.termIsArchived }" @click="selectPlan(plan.id)">
|
|
<span>{{ plan.termName }}</span><b>{{ plan.name }}</b>
|
|
<small>{{ t('examsTemplate.k59', { count: plan.sessionCount }) }}</small><i>{{ statusLabels[plan.status] }}</i>
|
|
</button>
|
|
</section>
|
|
<section v-if="selected" class="exam-board" v-loading="loading">
|
|
<header>
|
|
<div>
|
|
<span>MAKE-UP EXAM TIMELINE</span>
|
|
<h3>{{ selected.name }}</h3>
|
|
<p>{{ t('examsTemplate.k61', { term: selected.termName, count: selected.sessions.length }) }}</p>
|
|
</div>
|
|
<div class="exam-actions">
|
|
<el-button v-if="selected.status === 'Draft'" :icon="MagicStick" type="success" :disabled="arrangementJobRunning" @click="startAutoCreate">{{ t('examsTemplate.k37') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" @click="autoArrange('rooms')" :loading="arrangeLoading" :disabled="arrangementJobRunning || ['Queued', 'Running'].includes(autoJobStatus ?? '')">{{ t('workflowBatch.k13') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" @click="autoArrange('invigilators')" :loading="arrangeLoading" :disabled="arrangementJobRunning || ['Queued', 'Running'].includes(autoJobStatus ?? '')">{{ t('workflowBatch.k10') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" :icon="Setting" @click="autoArrange('all')" :loading="arrangeLoading" :disabled="arrangementJobRunning || ['Queued', 'Running'].includes(autoJobStatus ?? '')">{{ t('workflowBatch.k12') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" :icon="Plus" :disabled="arrangementJobRunning" @click="openSession()">{{ t('workflowBatch.k4') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" type="primary" :icon="Promotion" :disabled="arrangementJobRunning" @click="publishPlan">{{ t('workflowBatch.k7') }}</el-button>
|
|
<el-button v-if="selected.status === 'Published'" type="info" @click="archivePlan">{{ t('archive.archive') }}</el-button>
|
|
</div>
|
|
</header>
|
|
<el-alert
|
|
v-if="arrangementJob"
|
|
:title="arrangementJob.status === 'Failed' ? t('examsTemplate.k7') : arrangementJob.status === 'Succeeded' ? t('examsTemplate.k8') : t('examsTemplate.k38')"
|
|
:type="arrangementJob.status === 'Failed' ? 'error' : arrangementJob.status === 'Succeeded' ? 'success' : 'info'"
|
|
:closable="false"
|
|
show-icon
|
|
style="margin-bottom: 16px"
|
|
>
|
|
<template #default>
|
|
<p>{{ arrangementJob.errorMessage || arrangementJob.resultMessage || arrangementJob.currentStep || t('examsTemplate.k10') }}</p>
|
|
<el-progress
|
|
v-if="arrangementJobRunning"
|
|
:percentage="arrangementProgress"
|
|
:show-text="false"
|
|
:stroke-width="6"
|
|
:indeterminate="arrangementJob.status === 'Running'"
|
|
/>
|
|
</template>
|
|
</el-alert>
|
|
<div v-if="autoJobId && autoJobStatus !== 'Succeeded' && autoJobStatus !== 'Failed'" style="margin-bottom: 16px">
|
|
<el-alert :title="autoJobMessage" type="info" :closable="false">
|
|
<template #default>
|
|
<el-progress :percentage="autoJobProgress" :stroke-width="8" />
|
|
</template>
|
|
</el-alert>
|
|
</div>
|
|
<div class="exam-filter-bar">
|
|
<el-input v-model="sessionFilter.keyword" clearable :placeholder="t('batchBusiness.k30')" />
|
|
<el-select v-model="sessionFilter.allocation" clearable :placeholder="t('batchBusiness.k36')">
|
|
<el-option :label="t('batchBusiness.k23')" value="room" />
|
|
<el-option :label="t('batchBusiness.k27')" value="invigilator" />
|
|
<el-option :label="t('batchBusiness.k37')" value="complete" />
|
|
</el-select>
|
|
<span>{{ t('examsTemplate.k71', { shown: filteredSessions.length, total: selected.sessions.length }) }}</span>
|
|
<template v-if="selected.status === 'Draft'">
|
|
<el-button link type="primary" @click="selectFilteredSessions">{{ t('workflowBatch.k22') }}</el-button>
|
|
<el-button link @click="clearSessionSelection">{{ t('workflowBatch.k9') }}</el-button>
|
|
<el-tag v-if="selectedSessionIds.length" type="info">{{ t('examsTemplate.k64', { count: selectedSessionIds.length }) }}</el-tag>
|
|
</template>
|
|
</div>
|
|
<div class="exam-timeline">
|
|
<article v-for="session in filteredSessions" :key="session.id" :class="{ unassigned: !session.classroomId }">
|
|
<time>
|
|
<el-checkbox
|
|
v-if="selected.status === 'Draft'"
|
|
:model-value="selectedSessionIds.includes(session.id)"
|
|
@change="toggleSessionSelection(session.id, Boolean($event))"
|
|
>{{ t('batchBusiness.k33') }}</el-checkbox>
|
|
<b>{{ dateOnlyText(session.examDate) }}</b>
|
|
<span>{{ periodLabel(session) }}</span>
|
|
</time>
|
|
<div>
|
|
<span>{{ session.courseCode }} · {{ session.taskNumber }}</span>
|
|
<h4>{{ session.courseName }}</h4>
|
|
<p>
|
|
<template v-if="session.classroomId">{{ session.buildingName }} · {{ session.classroomName }} · {{ t('examsTemplate.k66', { capacity: session.classroomCapacity }) }}</template>
|
|
<template v-else><el-tag size="small" type="warning">{{ t('batchBusiness.k23') }}</el-tag></template>
|
|
· {{ session.enrolledCount ?? session.studentCount ?? 0 }} {{ t('graduationAudits.people') }}
|
|
<template v-if="session.requiredBuildingName">{{ t('examsTemplate.k67', { building: session.requiredBuildingName }) }}</template>
|
|
<template v-if="session.requiredInvigilatorCount > 1">{{ t('examsTemplate.k68', { count: session.requiredInvigilatorCount }) }}</template>
|
|
</p>
|
|
</div>
|
|
<div class="exam-staff">
|
|
<span>{{ t('workflowBatch.k11') }}</span>
|
|
<b>{{ session.invigilatorNames.length ? session.invigilatorNames.join(t('academicPlanning.separator')) : t('examsTemplate.k17') }}</b>
|
|
<small>{{ timeText(session.startsAt) }}—{{ timeText(session.endsAt) }}</small>
|
|
</div>
|
|
<div class="exam-row-actions">
|
|
<el-button link type="primary" @click="showRoster(session)">{{ t('batchBusiness.k35') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" link type="success" @click="openEnrollment(session)">{{ t('examsTemplate.k39') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" link type="primary" @click="openSession(session)">{{ t('businessLabels.edit') }}</el-button>
|
|
<el-button v-if="selected.status === 'Draft'" link type="danger" @click="removeSession(session)">{{ t('businessLabels.remove') }}</el-button>
|
|
</div>
|
|
</article>
|
|
<el-empty v-if="!selected.sessions.length" :description="t('examsTemplate.k40')" />
|
|
<el-empty v-else-if="!filteredSessions.length" :description="t('examsTemplate.k41')" />
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<!-- Teacher: teaching sessions for score entry -->
|
|
<section v-if="isTeacher && teachingSessions.length" class="exam-board" v-loading="loading" style="margin-top: 0">
|
|
<header>
|
|
<div>
|
|
<span>MAKE-UP EXAM GRADING</span>
|
|
<h3>{{ t('examsTemplate.k42') }}</h3>
|
|
<p>{{ t('examsTemplate.k43') }}</p>
|
|
</div>
|
|
</header>
|
|
<div class="exam-timeline">
|
|
<article v-for="session in teachingSessions" :key="session.id">
|
|
<time>
|
|
<b>{{ dateOnlyText(session.examDate) }}</b>
|
|
<span>{{ periodLabel(session) }}</span>
|
|
</time>
|
|
<div>
|
|
<span>{{ session.courseCode }} · {{ session.taskNumber }}</span>
|
|
<h4>{{ session.courseName }}</h4>
|
|
<p>
|
|
{{ session.buildingName ? `${session.buildingName} · ${session.classroomName}` : t('dashboard.student.examRoomPending') }}
|
|
{{ t('examsTemplate.k72', { count: session.enrolledCount, graded: session.gradedCount }) }}
|
|
</p>
|
|
</div>
|
|
<div class="exam-row-actions">
|
|
<el-button type="warning" @click="openScoreDialog(session)">{{ t('examsTemplate.k44') }}</el-button>
|
|
</div>
|
|
</article>
|
|
</div>
|
|
</section>
|
|
|
|
<section v-else-if="!isTeacher" class="exam-ticket-grid" v-loading="loading">
|
|
<article v-for="item in personal" :key="item.id">
|
|
<div class="exam-ticket-date">
|
|
<b>{{ dateOnlyText(item.examDate) }}</b>
|
|
<span>{{ timeText(item.startsAt) }}—{{ timeText(item.endsAt) }}</span>
|
|
</div>
|
|
<div>
|
|
<span>{{ item.courseCode }} · {{ item.taskNumber }}</span>
|
|
<h3>{{ item.courseName }}</h3>
|
|
<p>{{ item.buildingName ? `${item.buildingName} · ${item.classroomName}` : t('dashboard.student.examRoomPending') }}</p>
|
|
<el-tag v-if="item.seatNumber" size="small" type="success">{{ t('batchBusiness.k28') }} {{ item.seatNumber }}</el-tag>
|
|
<p v-if="item.reason" style="margin-top: 4px">
|
|
<span>{{ t('examsTemplate.k73', { reason: item.reason === 1 ? t('statisticsStatuses.fail') : item.reason === 2 ? t('dashboard.student.examStatus.Absent') : t('examsTemplate.k45') }) }}</span>
|
|
<span v-if="item.makeupScore != null">{{ t('examsTemplate.k74') }}<b>{{ item.makeupScore }}</b></span>
|
|
</p>
|
|
</div>
|
|
<footer>
|
|
<el-icon><UserFilled /></el-icon>
|
|
{{ t('examsTemplate.k70', { names: item.invigilatorNames?.join(t('academicPlanning.separator')) || t('examsTemplate.k20') }) }}
|
|
</footer>
|
|
</article>
|
|
<el-empty v-if="!personal.length" :description="t('examsTemplate.k46')" />
|
|
</section>
|
|
|
|
<!-- Teacher invigilation schedule -->
|
|
<section v-if="isTeacher && personal.length" class="exam-ticket-grid" v-loading="loading" style="margin-top: 0">
|
|
<h3 style="margin-bottom: 16px; font-size: 16px; color: #666">{{ t('examsTemplate.k47') }}</h3>
|
|
<article v-for="item in personal" :key="'inv-' + item.id">
|
|
<div class="exam-ticket-date">
|
|
<b>{{ dateOnlyText(item.examDate) }}</b>
|
|
<span>{{ timeText(item.startsAt) }}—{{ timeText(item.endsAt) }}</span>
|
|
</div>
|
|
<div>
|
|
<span>{{ item.courseCode }} · {{ item.taskNumber }}</span>
|
|
<h3>{{ item.courseName }}</h3>
|
|
<p>{{ item.buildingName ? `${item.buildingName} · ${item.classroomName}` : t('dashboard.student.examRoomPending') }}</p>
|
|
</div>
|
|
<footer>
|
|
<el-icon><UserFilled /></el-icon>
|
|
{{ t('examsTemplate.k69', { count: item.enrolledCount ?? item.studentCount ?? 0 }) }}
|
|
</footer>
|
|
</article>
|
|
</section>
|
|
|
|
<!-- Plan Dialog -->
|
|
<el-dialog v-model="planDialog" :title="t('examsTemplate.k48')" width="600px">
|
|
<el-form label-position="top">
|
|
<el-form-item :label="t('businessLabels.term')">
|
|
<el-select v-model="planForm.academicTermId">
|
|
<el-option v-for="x in terms" :key="x.id" :label="academicTermLabel(x)" :value="x.id" :class="academicTermOptionClass(x)" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k4')"><el-input v-model="planForm.name" maxlength="120" /></el-form-item>
|
|
<el-form-item :label="t('businessLabels.description')"><el-input v-model="planForm.notes" type="textarea" maxlength="500" /></el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button @click="planDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
|
<el-button type="primary" @click="savePlan">{{ t('workflowBatch.k0') }}</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- Session Dialog -->
|
|
<el-dialog v-model="sessionDialog" :title="editingSession ? t('examsTemplate.k49') : t('examsTemplate.k50')" width="960px" top="3vh">
|
|
<el-form label-position="top">
|
|
<el-form-item v-if="editingSession" :label="t('batchBusiness.k3')">
|
|
<el-select v-model="sessionForm.teachingTaskId" filterable :placeholder="t('batchBusiness.k32')">
|
|
<el-option v-for="x in tasks" :key="x.id" :label="`${x.taskNumber} · ${x.courseName}`" :value="x.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<template v-else>
|
|
<div class="task-filter-grid">
|
|
<el-input v-model="taskFilter.keyword" clearable :placeholder="t('batchBusiness.k31')" />
|
|
<el-select v-model="taskFilter.collegeId" clearable :placeholder="t('batchBusiness.k1')">
|
|
<el-option v-for="x in taskColleges" :key="x.id" :label="x.name" :value="x.id" />
|
|
</el-select>
|
|
<el-select v-model="taskFilter.courseNature" clearable :placeholder="t('courses.allNatures')">
|
|
<el-option v-for="(label, value) in courseNatureLabels" :key="value" :label="label" :value="value" />
|
|
</el-select>
|
|
</div>
|
|
<div class="task-selection-actions">
|
|
<span>{{ t('examsTemplate.k75', { available: filteredTasks.length, selected: selectedTaskIds.length }) }}</span>
|
|
<el-button link type="primary" @click="selectFilteredTasks">{{ t('workflowBatch.k8') }}</el-button>
|
|
<el-button link @click="clearFilteredTasks">{{ t('workflowBatch.k5') }}</el-button>
|
|
</div>
|
|
<el-table :data="filteredTasks" height="260" size="small">
|
|
<el-table-column :label="t('batchBusiness.k33')" width="64">
|
|
<template #default="scope">
|
|
<el-checkbox
|
|
:model-value="selectedTaskIds.includes(scope.row.id)"
|
|
@click.stop
|
|
@update:model-value="toggleTaskSelection(scope.row.id, Boolean($event))"
|
|
/>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="taskNumber" :label="t('batchBusiness.k26')" width="130" />
|
|
<el-table-column prop="courseName" :label="t('businessLabels.course')" min-width="150" />
|
|
<el-table-column prop="collegeName" :label="t('batchBusiness.k34')" min-width="130" />
|
|
<el-table-column :label="t('batchBusiness.k2')" min-width="120">
|
|
<template #default="scope">{{ scope.row.teacherNames?.join(t('academicPlanning.separator')) || t('examsTemplate.k20') }}</template>
|
|
</el-table-column>
|
|
<el-table-column :label="t('businessLabels.administrativeClass')" min-width="150">
|
|
<template #default="scope">{{ scope.row.classNames?.join(t('academicPlanning.separator')) || '-' }}</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</template>
|
|
<div class="form-grid">
|
|
<el-form-item :label="t('businessLabels.examDate')">
|
|
<el-date-picker v-model="sessionForm.examDate" type="date" value-format="YYYY-MM-DD" :placeholder="t('batchBusiness.k5')" />
|
|
</el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k6')">
|
|
<el-select v-model="sessionForm.startPeriod">
|
|
<el-option v-for="opt in periodOptions()" :key="opt.value" :label="opt.label" :value="opt.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k29')">
|
|
<el-select v-model="sessionForm.periodCount">
|
|
<el-option v-for="opt in periodCountOptions()" :key="opt.value" :label="opt.label" :value="opt.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</div>
|
|
<div class="form-grid">
|
|
<el-form-item :label="t('batchBusiness.k21')">
|
|
<el-select v-model="sessionForm.requiredBuildingIds" multiple clearable :placeholder="t('batchBusiness.k19')">
|
|
<el-option v-for="x in buildings" :key="x.id" :label="x.name" :value="x.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k24')">
|
|
<el-input-number v-model="sessionForm.requiredInvigilatorCount" :min="1" :max="10" />
|
|
</el-form-item>
|
|
</div>
|
|
<el-form-item v-if="editingSession" :label="t('batchBusiness.k22')">
|
|
<el-select v-model="sessionForm.classroomId" clearable filterable :placeholder="t('batchBusiness.k25')">
|
|
<el-option v-for="x in filteredRooms()" :key="x.id" :label="classroomLabel(x)" :value="x.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item v-if="editingSession" :label="t('batchBusiness.k18')">
|
|
<el-select v-model="sessionForm.invigilatorIds" multiple filterable remote clearable :remote-method="searchTeacherOptions" :loading="teacherOptionsLoading" :placeholder="t('batchBusiness.k20')">
|
|
<el-option v-for="x in teachers" :key="x.id" :label="teacherOptionLabel(x)" :value="x.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item :label="t('businessLabels.notes')">
|
|
<el-input v-model="sessionForm.notes" maxlength="500" :placeholder="t('businessLabels.optional')" />
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button @click="sessionDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
|
<el-button type="primary" @click="saveSession">
|
|
{{ editingSession ? t('businessLabels.saveChanges') : t('examsTemplate.k76', { count: selectedTaskIds.length }) }}
|
|
</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- Roster Drawer -->
|
|
<el-drawer v-model="rosterDrawer" :title="t('batchBusiness.k35')" size="600px">
|
|
<el-table v-if="roster" :data="roster.students">
|
|
<el-table-column prop="seatNumber" :label="t('batchBusiness.k28')" width="80" />
|
|
<el-table-column prop="studentNumber" :label="t('businessLabels.studentNumber')" width="120" />
|
|
<el-table-column prop="name" :label="t('businessLabels.name')" width="80" />
|
|
<el-table-column prop="className" :label="t('businessLabels.administrativeClass')" width="130" />
|
|
<el-table-column :label="t('examsTemplate.k51')" width="90">
|
|
<template #default="scope">
|
|
<span>{{ scope.row.reason === 1 ? t('statisticsStatuses.fail') : scope.row.reason === 2 ? t('dashboard.student.examStatus.Absent') : scope.row.reason === 3 ? t('examsTemplate.k45') : '-' }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column :label="t('businessLabels.score')" width="70">
|
|
<template #default="scope">
|
|
{{ scope.row.makeupScore ?? '-' }}
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-drawer>
|
|
|
|
<!-- Enrollment Dialog -->
|
|
<el-dialog v-model="enrollmentDialog" :title="t('examsTemplate.k52')" width="700px">
|
|
<div v-if="enrollmentSession">
|
|
<p><b>{{ enrollmentSession.courseName }}</b> · {{ dateOnlyText(enrollmentSession.examDate) }} {{ periodLabel(enrollmentSession) }}</p>
|
|
<p style="margin-bottom: 12px">{{ t('examsTemplate.k77', { count: enrollmentSession.enrolledCount ?? enrollmentSession.studentCount }) }}</p>
|
|
<el-button type="primary" :icon="Search" @click="loadEligibleStudents" :loading="eligibleLoading" style="margin-bottom: 12px">{{ t('examsTemplate.k53') }}</el-button>
|
|
<el-table v-if="eligibleStudents.length" :data="eligibleStudents" @selection-change="onEnrollmentSelection" ref="enrollmentTable">
|
|
<el-table-column type="selection" width="40" />
|
|
<el-table-column prop="studentNumber" :label="t('businessLabels.studentNumber')" width="120" />
|
|
<el-table-column prop="name" :label="t('businessLabels.name')" width="80" />
|
|
<el-table-column prop="className" :label="t('businessLabels.administrativeClass')" width="140" />
|
|
<el-table-column :label="t('examsTemplate.k51')" width="100">
|
|
<template #default="scope">
|
|
<span>{{ scope.row.reason === 1 ? t('statisticsStatuses.fail') : scope.row.reason === 2 ? t('dashboard.student.examStatus.Absent') : t('examsTemplate.k45') }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column :label="t('businessLabels.details')" min-width="120">
|
|
<template #default="scope">
|
|
<span v-if="scope.row.reason === 1 && scope.row.totalScore != null">{{ t('examsTemplate.k78', { score: scope.row.totalScore }) }}</span>
|
|
<span v-else-if="scope.row.reason === 3">{{ t('examsTemplate.k54') }}</span>
|
|
<span v-else>{{ t('studentCurriculum.examStatuses.Absent') }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<el-empty v-else-if="!eligibleLoading" :description="t('examsTemplate.k55')" />
|
|
</div>
|
|
<template #footer>
|
|
<el-button @click="enrollmentDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
|
<el-button type="primary" @click="enrollSelectedStudents" :disabled="!selectedStudentIds.length">{{ t('examsTemplate.k79', { count: selectedStudentIds.length }) }}</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- Score Dialog (teacher) -->
|
|
<el-dialog v-model="scoreDialogVisible" :title="t('examsTemplate.k56')" width="680px">
|
|
<template v-if="scoreSession">
|
|
<p style="margin-bottom: 12px"><b>{{ scoreSession.courseName }}</b> · {{ dateOnlyText(scoreSession.examDate) }} · {{ t('examsTemplate.k69', { count: scoreSession.enrolledCount }) }}</p>
|
|
<el-alert type="warning" :title="t('examsTemplate.k57')" :closable="false" style="margin-bottom: 12px" />
|
|
<el-table :data="scoreSession.enrollments" size="small">
|
|
<el-table-column prop="studentNumber" :label="t('businessLabels.studentNumber')" width="120" />
|
|
<el-table-column prop="name" :label="t('businessLabels.name')" width="80" />
|
|
<el-table-column :label="t('examsTemplate.k51')" width="90">
|
|
<template #default="scope">
|
|
<span>{{ scope.row.reason === 1 ? t('statisticsStatuses.fail') : scope.row.reason === 2 ? t('dashboard.student.examStatus.Absent') : t('examsTemplate.k45') }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column :label="t('examsTemplate.k58')" width="150">
|
|
<template #default="scope">
|
|
<el-input-number :model-value="scoreMap[scope.row.studentId]" @update:model-value="onScoreInput(scope.row.studentId, $event)" :min="0" :max="100" :precision="1" size="small" controls-position="right" placeholder="0-100" />
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</template>
|
|
<template #footer>
|
|
<el-button @click="scoreDialogVisible = false">{{ t('businessLabels.cancel') }}</el-button>
|
|
<el-button type="primary" @click="submitScores" :loading="scoreSaving">{{ t('workflowBatch.k21') }}</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.exam-actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
justify-content: flex-end;
|
|
}
|
|
.exam-filter-bar,
|
|
.task-filter-grid,
|
|
.task-selection-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
.exam-filter-bar {
|
|
margin-bottom: 16px;
|
|
flex-wrap: wrap;
|
|
}
|
|
.exam-filter-bar .el-input {
|
|
width: min(320px, 100%);
|
|
}
|
|
.exam-filter-bar .el-select {
|
|
width: 180px;
|
|
}
|
|
.task-filter-grid {
|
|
display: grid;
|
|
grid-template-columns: minmax(240px, 1.5fr) minmax(160px, 1fr) minmax(160px, 1fr);
|
|
margin-bottom: 10px;
|
|
}
|
|
.task-selection-actions {
|
|
justify-content: flex-end;
|
|
margin-bottom: 8px;
|
|
}
|
|
.task-selection-actions span {
|
|
margin-right: auto;
|
|
}
|
|
.exam-timeline article.unassigned {
|
|
border-left-color: #e6a23c;
|
|
}
|
|
.enrollment-header {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
.enrollment-header p {
|
|
margin: 0;
|
|
}
|
|
@media (max-width: 720px) {
|
|
.exam-actions {
|
|
justify-content: flex-start;
|
|
}
|
|
.task-filter-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
.task-selection-actions {
|
|
align-items: flex-start;
|
|
flex-direction: column;
|
|
}
|
|
}
|
|
</style>
|