Files
Academic-Affairs-System/web/src/views/CourseAdjustmentsView.vue
T

607 lines
29 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { getDisplayLocale } from '../i18n'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Check, Plus, Refresh } 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 route = useRoute()
const router = useRouter()
const isManager = computed(() =>
auth.user?.roles.some(r => ['SuperAdmin', 'AcademicAdmin', 'CollegeAdmin'].includes(r)) ?? false)
const isTeacher = computed(() => auth.user?.roles.includes('Teacher') && !isManager.value)
const adjustments = ref<any[]>([])
const pendingReviews = ref<any[]>([])
const loading = ref(false)
const reviewLoading = ref(false)
const dialog = ref(false)
const rejectDialog = ref(false)
const currentAdj = ref<any>(null)
const rejectComment = ref('')
const terms = ref<any[]>([])
const tasks = ref<any[]>([])
const sessionOptions = ref<any[]>([])
const classrooms = ref<any[]>([])
const periods = ref<any[]>([])
const sessionTask = ref<any>(null)
const sessionLoading = ref(false)
const termId = ref<string>()
const tab = ref(isManager.value ? 'reviews' : 'mine')
const minePage = ref(1)
const mineCursors = ref<string[]>([])
const nextMineCursor = ref<string>()
const mineHasMore = ref(false)
const reviewPage = ref(1)
const reviewCursors = ref<string[]>([])
const nextReviewCursor = ref<string>()
const reviewHasMore = ref(false)
const pageSize = 20
const targetAdjustmentId = computed(() => {
const value = route.query.adjustmentId
return typeof value === 'string' ? value : undefined
})
const form = reactive({
teachingTaskId: undefined as string | undefined,
sourceKey: undefined as string | undefined,
sourceScheduleEntryId: undefined as string | undefined,
sourceWeek: undefined as number | undefined,
type: 'Reschedule' as string,
reason: '',
submit: true,
targetDate: '' as string,
dayOfWeek: undefined as number | undefined,
startPeriod: undefined as number | undefined,
periodCount: 2,
classroomId: undefined as string | undefined,
substituteTeacherId: undefined as string | undefined,
cancelWeek: undefined as number | undefined,
cancelDate: '' as string,
})
const typeLabels = computed<Record<string, string>>(() => ({ Reschedule: t('adjustmentBatch.k0'), Cancel: t('adjustmentBatch.k1'), Makeup: t('adjustmentBatch.k2'), Substitute: t('adjustmentBatch.k3') }))
const statusLabels = computed<Record<string, string>>(() => ({ Draft: t('adjustmentBatch.k4'), Submitted: t('adjustmentBatch.k5'), Approved: t('adjustmentBatch.k6'), Rejected: t('adjustmentBatch.k7') }))
const statusColors: Record<string, 'info' | 'warning' | 'success' | 'danger'> = { Draft: 'info', Submitted: 'warning', Approved: 'success', Rejected: 'danger' }
const sourceRequired = computed(() => ['Reschedule', 'Cancel', 'Makeup'].includes(form.type))
const selectedSession = computed(() =>
sessionOptions.value.find(item => sessionKey(item) === form.sourceKey))
function periodOptions() {
if (periods.value.length) {
return periods.value.map(item => ({
value: item.periodNumber,
label: t('adjustmentBatch.k75', { number: item.periodNumber, name: item.name, start: item.startsAt, end: item.endsAt }),
}))
}
return Array.from({ length: 12 }, (_, i) => ({ value: i + 1, label: t('adjustmentBatch.k74', { number: i + 1 }) }))
}
function sessionKey(session: any) {
return `${session.scheduleEntryId}:${session.week}`
}
function weekdayLabel(day: number) {
return day >= 1 && day <= 7 ? t(`freeClassrooms.weekdays.${day}`) : String(day)
}
function sessionLabel(session: any) {
const end = session.startPeriod + session.periodCount - 1
const room = session.classroomName
? ` · ${session.buildingName ?? ''}${session.classroomName}`
: ` · ${t('adjustmentBatch.k20')}`
return t('adjustmentBatch.k76', { week: session.week, date: session.date, day: weekdayLabel(session.dayOfWeek), start: session.startPeriod, end, room })
}
async function load(resetPages = false) {
if (resetPages) {
minePage.value = 1
reviewPage.value = 1
mineCursors.value = []
reviewCursors.value = []
nextMineCursor.value = undefined
nextReviewCursor.value = undefined
}
loading.value = true
reviewLoading.value = isManager.value
try {
if (isTeacher.value || (!isManager.value)) {
const response = await http.get('/course-adjustments/mine', {
params: { academicTermId: termId.value, cursor: mineCursors.value.at(-1), pageSize },
})
adjustments.value = response.data.items
mineHasMore.value = response.data.hasMore
nextMineCursor.value = response.data.nextCursor
}
if (isManager.value) {
const response = await http.get('/course-adjustments/pending-reviews', {
params: {
academicTermId: targetAdjustmentId.value ? undefined : termId.value,
adjustmentId: targetAdjustmentId.value,
cursor: reviewCursors.value.at(-1),
pageSize,
},
})
pendingReviews.value = response.data.items
reviewHasMore.value = response.data.hasMore
nextReviewCursor.value = response.data.nextCursor
}
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
finally { loading.value = false; reviewLoading.value = false }
}
async function nextMinePage() {
if (!nextMineCursor.value || loading.value) return
mineCursors.value.push(nextMineCursor.value)
minePage.value++
await load()
}
async function previousMinePage() {
if (!mineCursors.value.length || loading.value) return
mineCursors.value.pop()
minePage.value--
await load()
}
async function nextReviewPage() {
if (!nextReviewCursor.value || reviewLoading.value) return
reviewCursors.value.push(nextReviewCursor.value)
reviewPage.value++
await load()
}
async function previousReviewPage() {
if (!reviewCursors.value.length || reviewLoading.value) return
reviewCursors.value.pop()
reviewPage.value--
await load()
}
function openCreate() {
Object.assign(form, {
teachingTaskId: undefined,
sourceKey: undefined,
sourceScheduleEntryId: undefined,
sourceWeek: undefined,
type: 'Reschedule',
reason: '',
submit: true,
targetDate: '',
dayOfWeek: undefined,
startPeriod: undefined,
periodCount: 2,
classroomId: undefined,
substituteTeacherId: undefined,
cancelWeek: undefined,
cancelDate: '',
})
dialog.value = true
}
async function loadSessionOptions() {
sessionOptions.value = []
classrooms.value = []
periods.value = []
sessionTask.value = null
form.sourceKey = undefined
form.sourceScheduleEntryId = undefined
form.sourceWeek = undefined
if (!form.teachingTaskId) return
sessionLoading.value = true
try {
const data = (await http.get(
`/course-adjustments/tasks/${form.teachingTaskId}/session-options`,
)).data
sessionTask.value = data.task
sessionOptions.value = data.sessions
classrooms.value = data.classrooms
periods.value = data.periods
} catch (error) {
ElMessage.error(apiErrorMessage(error))
} finally {
sessionLoading.value = false
}
}
function selectSession() {
const session = selectedSession.value
if (!session) return
form.sourceScheduleEntryId = session.scheduleEntryId
form.sourceWeek = session.week
form.periodCount = session.periodCount
form.classroomId = session.classroomId ?? undefined
}
async function submit() {
if (!form.teachingTaskId) { ElMessage.warning(t('adjustmentBatch.k8')); return }
if (sourceRequired.value && !selectedSession.value) { ElMessage.warning(t('adjustmentBatch.k9')); return }
if (selectedSession.value?.hasExistingAdjustment) { ElMessage.warning(t('adjustmentBatch.k10')); return }
if (['Reschedule', 'Makeup'].includes(form.type) && !form.targetDate) { ElMessage.warning(t('adjustmentBatch.k11')); return }
if (['Reschedule', 'Makeup'].includes(form.type) && !form.startPeriod) { ElMessage.warning(t('adjustmentBatch.k12')); return }
if (!form.reason.trim()) { ElMessage.warning(t('adjustmentBatch.k13')); return }
try {
await http.post('/course-adjustments', {
...form,
sourceKey: undefined,
dayOfWeek: form.dayOfWeek || null,
startPeriod: form.startPeriod || null,
classroomId: form.classroomId || null,
substituteTeacherId: form.substituteTeacherId || null,
cancelWeek: form.cancelWeek || null,
targetDate: form.targetDate || null,
cancelDate: form.cancelDate || null,
})
dialog.value = false
ElMessage.success(t('adjustmentBatch.k14'))
await load()
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
}
async function loadTaskOptions() {
if (!isTeacher.value && isManager.value) return
try {
tasks.value = (await http.get('/course-adjustments/task-options', {
params: { academicTermId: termId.value || undefined },
})).data
} catch (error) {
tasks.value = []
ElMessage.error(apiErrorMessage(error))
}
}
async function doSubmit(adj: any) {
try {
await http.post(`/course-adjustments/${adj.id}/submit`)
ElMessage.success(t('adjustmentBatch.k15'))
await load()
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
}
async function doApprove(adj: any) {
try {
await http.post(`/course-adjustments/${adj.id}/approve`)
ElMessage.success(t('adjustmentBatch.k6'))
await load()
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
}
function openReject(adj: any) {
currentAdj.value = adj
rejectComment.value = ''
rejectDialog.value = true
}
async function doReject() {
if (!currentAdj.value) return
try {
await http.post(`/course-adjustments/${currentAdj.value.id}/reject`, {
comment: rejectComment.value,
})
rejectDialog.value = false
ElMessage.success(t('dashboard.teacher.status.Returned'))
await load()
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
}
onMounted(async () => {
try {
const termRes = await http.get('/base-data/terms')
terms.value = termRes.data
termId.value = defaultAcademicTermId(terms.value)
await loadTaskOptions()
} catch (error) {
ElMessage.error(apiErrorMessage(error))
}
await load()
if (isManager.value && targetAdjustmentId.value) tab.value = 'reviews'
if (isTeacher.value && route.query.create === '1') {
openCreate()
await router.replace({ path: '/course-adjustments' })
}
})
watch(targetAdjustmentId, async () => {
if (isManager.value) {
tab.value = 'reviews'
reviewPage.value = 1
await load()
}
})
function changeType() {
form.targetDate = ''
form.startPeriod = undefined
form.classroomId = selectedSession.value?.classroomId ?? undefined
}
function showTarget(type: string) {
return type === 'Reschedule' || type === 'Makeup'
}
function showSub(type: string) { return type === 'Substitute' }
</script>
<template>
<div class="page-stack adj-page">
<section class="page-intro">
<div>
<span class="section-kicker">COURSE ADJUSTMENT</span>
<h2>{{ t('adjustmentBatch.k16') }}</h2>
<p>{{ t('adjustmentBatch.k17') }}</p>
</div>
<div style="display:flex;gap:8px;align-items:center">
<el-button v-if="isTeacher" type="primary" :icon="Plus" @click="openCreate">{{ t('statusChanges.submit') }}</el-button>
<el-button :icon="Refresh" @click="() => load()">{{ t('businessLabels.refresh') }}</el-button>
</div>
</section>
<section class="adj-toolbar">
<el-select v-model="termId" clearable :placeholder="t('businessLabels.allTerms')" @change="() => { load(true); loadTaskOptions() }">
<el-option v-for="t in terms" :key="t.id" :label="academicTermLabel(t)" :value="t.id" :class="academicTermOptionClass(t)" />
</el-select>
<el-segmented v-model="tab" :options="[
...(isTeacher ? [{ label: t('adjustmentBatch.k18'), value: 'mine' }] : []),
...(isManager ? [{ label: t('adjustmentBatch.k5'), value: 'reviews' }] : []),
]" />
</section>
<!-- My applications -->
<section v-if="tab === 'mine'" v-loading="loading" class="adj-list">
<article v-for="adj in adjustments" :key="adj.id" class="adj-card" :class="adj.status.toLowerCase()">
<header>
<div>
<span>{{ adj.courseCode }} · {{ adj.taskNumber }}</span>
<h3>{{ adj.courseName }}</h3>
<p>{{ adj.teacherNames.join('、') }} · {{ adj.collegeName }}</p>
</div>
<div class="adj-tags">
<el-tag :type="adj.type === 'Reschedule' ? 'primary' : adj.type === 'Cancel' ? 'danger' : adj.type === 'Makeup' ? 'success' : 'warning'" size="small">
{{ typeLabels[adj.type] }}
</el-tag>
<el-tag :type="statusColors[adj.status]" size="small">{{ statusLabels[adj.status] }}</el-tag>
</div>
</header>
<div class="adj-body">
<p v-if="adj.reason"><b>{{ t('adjustmentBatch.k26') }}</b>{{ adj.reason }}</p>
<div v-if="adj.sourceDate" class="adjustment-route">
<div><small>{{ t('adjustmentBatch.k19') }}</small><b>{{ t('adjustmentBatch.k77', { week: adj.sourceWeek, date: adj.sourceDate, start: adj.sourceStartPeriod, end: adj.sourceStartPeriod + adj.sourcePeriodCount - 1 }) }}</b><span>{{ adj.sourceClassroomName || t('adjustmentBatch.k20') }}</span></div>
<i>{{ adj.type === 'Cancel' ? '×' : '→' }}</i>
<div v-if="adj.type !== 'Cancel'"><small>{{ adj.type === 'Makeup' ? t('adjustmentBatch.k21') : t('adjustmentBatch.k22') }}</small><b>{{ t('adjustmentBatch.k78', { date: adj.targetDate, start: adj.startPeriod, end: adj.startPeriod + adj.periodCount - 1 }) }}</b><span>{{ adj.classroomName ? `${adj.buildingName} ${adj.classroomName}` : adj.sourceClassroomName || t('adjustmentBatch.k20') }}</span></div>
<div v-else><small>{{ t('adjustmentBatch.k23') }}</small><b>{{ t('adjustmentBatch.k24') }}</b><span>{{ t('adjustmentBatch.k25') }}</span></div>
</div>
<div class="adj-details">
<span v-if="!adj.sourceDate && adj.targetDate"><b>{{ t('adjustmentBatch.k27') }}</b>{{ adj.targetDate }}</span>
<span v-if="!adj.sourceDate && adj.dayOfWeek"><b>{{ t('adjustmentBatch.k28') }}</b>{{ weekdayLabel(adj.dayOfWeek) }}</span>
<span v-if="!adj.sourceDate && adj.startPeriod"><b>{{ t('adjustmentBatch.k29') }}</b>{{ t('adjustmentBatch.k79', { start: adj.startPeriod, end: adj.startPeriod + adj.periodCount - 1 }) }}</span>
<span v-if="!adj.sourceDate && adj.cancelWeek"><b>{{ t('adjustmentBatch.k30') }}</b>{{ t('adjustmentBatch.k80', { week: adj.cancelWeek }) }}</span>
<span v-if="adj.substituteTeacherName"><b>{{ t('adjustmentBatch.k31') }}</b>{{ adj.substituteTeacherName }}</span>
</div>
<el-alert v-if="adj.reviewComment" :title="t('adjustmentBatch.k33', { comment: adj.reviewComment })" type="warning" :closable="false" show-icon />
<el-button text type="primary" @click="$router.push({ path: '/approvals', query: { progressType: 'CourseAdjustment', progressId: adj.id } })">{{ t('approvalProgress.title') }}</el-button>
</div>
<footer v-if="adj.status === 'Draft'">
<el-button size="small" type="primary" @click="doSubmit(adj)">{{ t('adjustmentBatch.k34') }}</el-button>
</footer>
</article>
<el-empty v-if="!adjustments.length" :description="t('adjustmentBatch.k35')" />
<div v-if="mineCursors.length || mineHasMore" class="table-pagination cursor-pager">
<el-button :disabled="!mineCursors.length || loading" @click="previousMinePage">{{ t('businessLabels.previous') }}</el-button>
<span>{{ t('adjustmentBatch.k82', { page: minePage }) }}</span>
<el-button type="primary" :disabled="!mineHasMore || loading" @click="nextMinePage">{{ t('businessLabels.next') }}</el-button>
</div>
</section>
<!-- Pending reviews -->
<section v-if="tab === 'reviews'" v-loading="reviewLoading" class="adj-list">
<article v-for="adj in pendingReviews" :key="adj.id" class="adj-card review">
<header>
<div>
<span>{{ adj.courseCode }} · {{ adj.taskNumber }}</span>
<h3>{{ adj.courseName }}</h3>
<p>{{ adj.teacherNames.join('、') }} · {{ adj.collegeName }}</p>
</div>
<el-tag :type="adj.type === 'Reschedule' ? 'primary' : adj.type === 'Cancel' ? 'danger' : adj.type === 'Makeup' ? 'success' : 'warning'" size="small">
{{ typeLabels[adj.type] }}
</el-tag>
</header>
<div class="adj-body">
<p><b>{{ t('adjustmentBatch.k26') }}</b>{{ adj.reason }}</p>
<div v-if="adj.sourceDate" class="adjustment-route">
<div><small>{{ t('adjustmentBatch.k19') }}</small><b>{{ t('adjustmentBatch.k77', { week: adj.sourceWeek, date: adj.sourceDate, start: adj.sourceStartPeriod, end: adj.sourceStartPeriod + adj.sourcePeriodCount - 1 }) }}</b><span>{{ adj.sourceClassroomName || t('adjustmentBatch.k20') }}</span></div>
<i>{{ adj.type === 'Cancel' ? '×' : '→' }}</i>
<div v-if="adj.type !== 'Cancel'"><small>{{ adj.type === 'Makeup' ? t('adjustmentBatch.k21') : t('adjustmentBatch.k22') }}</small><b>{{ t('adjustmentBatch.k78', { date: adj.targetDate, start: adj.startPeriod, end: adj.startPeriod + adj.periodCount - 1 }) }}</b><span>{{ adj.classroomName ? `${adj.buildingName} ${adj.classroomName}` : adj.sourceClassroomName || t('adjustmentBatch.k20') }}</span></div>
<div v-else><small>{{ t('adjustmentBatch.k23') }}</small><b>{{ t('adjustmentBatch.k24') }}</b><span>{{ t('adjustmentBatch.k25') }}</span></div>
</div>
<div class="adj-details">
<span v-if="!adj.sourceDate && adj.targetDate"><b>{{ t('adjustmentBatch.k27') }}</b>{{ adj.targetDate }}</span>
<span v-if="!adj.sourceDate && adj.dayOfWeek"><b>{{ t('adjustmentBatch.k28') }}</b>{{ weekdayLabel(adj.dayOfWeek) }}</span>
<span v-if="!adj.sourceDate && adj.startPeriod"><b>{{ t('adjustmentBatch.k29') }}</b>{{ t('adjustmentBatch.k79', { start: adj.startPeriod, end: adj.startPeriod + adj.periodCount - 1 }) }}</span>
<span v-if="!adj.sourceDate && adj.cancelWeek"><b>{{ t('adjustmentBatch.k30') }}</b>{{ t('adjustmentBatch.k80', { week: adj.cancelWeek }) }}</span>
<span v-if="adj.substituteTeacherName"><b>{{ t('adjustmentBatch.k31') }}</b>{{ adj.substituteTeacherName }}</span>
</div>
<p class="adj-meta"><b>{{ t('adjustmentBatch.k32') }}</b>{{ new Date(adj.submittedAt).toLocaleString(getDisplayLocale()) }}</p>
</div>
<footer>
<el-button size="small" type="danger" plain @click="openReject(adj)">{{ t('adjustmentBatch.k37') }}</el-button>
<el-button size="small" type="success" :icon="Check" @click="doApprove(adj)">{{ t('businessLabels.approve') }}</el-button>
</footer>
</article>
<el-empty v-if="!pendingReviews.length" :description="t('adjustmentBatch.k36')" />
<div v-if="reviewCursors.length || reviewHasMore" class="table-pagination cursor-pager">
<el-button :disabled="!reviewCursors.length || reviewLoading" @click="previousReviewPage">{{ t('businessLabels.previous') }}</el-button>
<span>{{ t('adjustmentBatch.k82', { page: reviewPage }) }}</span>
<el-button type="primary" :disabled="!reviewHasMore || reviewLoading" @click="nextReviewPage">{{ t('businessLabels.next') }}</el-button>
</div>
</section>
<!-- Create dialog -->
<el-dialog v-model="dialog" :title="t('adjustmentBatch.k38')" width="760px" top="4vh" class="adjustment-dialog">
<el-form label-position="top" class="adjustment-form">
<section class="adjustment-step">
<header><b>1</b><div><h3>{{ t('adjustmentBatch.k39') }}</h3><p>{{ t('adjustmentBatch.k40') }}</p></div></header>
<el-form-item :label="t('statusChanges.type')" required>
<el-segmented v-model="form.type" :options="[
{ label: t('adjustmentBatch.k0'), value: 'Reschedule' },
{ label: t('adjustmentBatch.k1'), value: 'Cancel' },
{ label: t('adjustmentBatch.k2'), value: 'Makeup' },
{ label: t('adjustmentBatch.k3'), value: 'Substitute' },
]" @change="changeType" />
</el-form-item>
<el-alert
:title="form.type === 'Reschedule' ? t('adjustmentBatch.k41') : form.type === 'Cancel' ? t('adjustmentBatch.k42') : form.type === 'Makeup' ? t('adjustmentBatch.k43') : t('adjustmentBatch.k44')"
type="info" :closable="false"
/>
</section>
<section class="adjustment-step">
<header><b>2</b><div><h3>{{ t('adjustmentBatch.k45') }}</h3><p>{{ t('adjustmentBatch.k46') }}</p></div></header>
<el-form-item :label="t('adjustmentBatch.k47')" required>
<el-select v-model="form.teachingTaskId" filterable :placeholder="t('adjustmentBatch.k48')" @change="loadSessionOptions">
<el-option v-for="t in tasks" :key="t.id" :label="`${t.taskNumber} · ${t.courseName}`" :value="t.id" />
</el-select>
</el-form-item>
<el-form-item v-if="sourceRequired" :label="t('adjustmentBatch.k19')" required>
<el-select
v-model="form.sourceKey" filterable :loading="sessionLoading"
:placeholder="t('adjustmentBatch.k49')" @change="selectSession"
>
<el-option
v-for="session in sessionOptions" :key="sessionKey(session)"
:label="sessionLabel(session)" :value="sessionKey(session)"
:disabled="session.hasExistingAdjustment"
>
<span>{{ sessionLabel(session) }}</span>
<small v-if="session.hasExistingAdjustment" class="session-used">{{ t('adjustmentBatch.k50') }}</small>
</el-option>
</el-select>
</el-form-item>
<el-empty v-if="form.teachingTaskId && sourceRequired && !sessionLoading && !sessionOptions.length" :description="t('adjustmentBatch.k51')" :image-size="56" />
</section>
<section v-if="showTarget(form.type)" class="adjustment-step target-step">
<header><b>3</b><div><h3>{{ form.type === 'Reschedule' ? t('adjustmentBatch.k52') : t('adjustmentBatch.k53') }}</h3><p>{{ t('adjustmentBatch.k54') }}</p></div></header>
<div class="source-target-strip" v-if="selectedSession">
<div><span>{{ t('adjustmentBatch.k19') }}</span><strong>{{ sessionLabel(selectedSession) }}</strong></div>
<i>→</i>
<div><span>{{ t('adjustmentBatch.k55') }}</span><strong>{{ form.targetDate || t('adjustmentBatch.k56') }} · {{ form.startPeriod ? t('adjustmentBatch.k81', { number: form.startPeriod }) : t('adjustmentBatch.k57') }}</strong></div>
</div>
<div class="form-grid two">
<el-form-item :label="t('adjustmentBatch.k58')" required>
<el-date-picker
v-model="form.targetDate" type="date" value-format="YYYY-MM-DD"
:disabled-date="(date: Date) => sessionTask && (date < new Date(`${sessionTask.termStartDate}T00:00:00`) || date > new Date(`${sessionTask.termEndDate}T23:59:59`))"
:placeholder="t('adjustmentBatch.k59')"
/>
</el-form-item>
<el-form-item :label="t('adjustmentBatch.k60')" required>
<el-select v-model="form.startPeriod" :placeholder="t('adjustmentBatch.k61')">
<el-option v-for="o in periodOptions()" :key="o.value" :label="o.label" :value="o.value" />
</el-select>
</el-form-item>
</div>
<el-form-item :label="t('adjustmentBatch.k62')">
<el-select v-model="form.classroomId" clearable filterable :placeholder="t('adjustmentBatch.k63')">
<el-option
v-for="room in classrooms" :key="room.id"
:label="`${room.campusName} · ${room.buildingName} ${room.name} · ${t('adjustmentBatch.k83', { count: room.capacity })}`"
:value="room.id"
/>
</el-select>
</el-form-item>
</section>
<template v-if="showSub(form.type)">
<section class="adjustment-step">
<header><b>3</b><div><h3>{{ t('adjustmentBatch.k64') }}</h3><p>{{ t('adjustmentBatch.k65') }}</p></div></header>
<el-form-item :label="t('adjustmentBatch.k66')" required>
<el-select v-model="form.substituteTeacherId" filterable :placeholder="t('adjustmentBatch.k64')" />
</el-form-item>
</section>
</template>
<el-form-item :label="t('adjustmentBatch.k67')" required class="reason-field">
<el-input v-model="form.reason" type="textarea" :rows="3" maxlength="500" show-word-limit :placeholder="t('adjustmentBatch.k68')" />
</el-form-item>
<el-form-item>
<el-checkbox v-model="form.submit">{{ t('adjustmentBatch.k69') }}</el-checkbox>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialog = false">{{ t('businessLabels.cancel') }}</el-button>
<el-button type="primary" @click="submit">{{ t('statusChanges.submit') }}</el-button>
</template>
</el-dialog>
<!-- Reject dialog -->
<el-dialog v-model="rejectDialog" :title="t('adjustmentBatch.k70')" width="500px">
<el-form label-position="top">
<el-form-item :label="t('adjustmentBatch.k71')">
<el-input v-model="rejectComment" type="textarea" :rows="3" maxlength="500" show-word-limit :placeholder="t('adjustmentBatch.k72')" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="rejectDialog = false">{{ t('businessLabels.cancel') }}</el-button>
<el-button type="danger" @click="doReject">{{ t('adjustmentBatch.k73') }}</el-button>
</template>
</el-dialog>
</div>
</template>
<style scoped>
.adj-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.adj-list { display: grid; gap: 12px; }
.adj-card { background: #fff; border: 1px solid #e4e7ed; border-radius: 8px; padding: 16px 20px; }
.adj-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.adj-card header h3 { font-size: 15px; margin: 4px 0; }
.adj-card header p { font-size: 12px; color: var(--muted); margin: 0; }
.adj-card header span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.adj-tags { display: flex; gap: 6px; flex-shrink: 0; }
.adj-body { margin: 12px 0; font-size: 13px; }
.adj-details { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 12px; margin-top: 8px; }
.adj-meta { font-size: 11px; color: var(--muted); margin-top: 8px; }
.adj-card footer { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid #ebeef5; padding-top: 12px; }
.adj-card.review { border-left: 4px solid #e6a23c; }
.adj-card.draft { border-left: 4px solid #909399; }
.adj-card.submitted { border-left: 4px solid #e6a23c; }
.adj-card.approved { border-left: 4px solid #67c23a; }
.adj-card.rejected { border-left: 4px solid #f56c6c; }
.adjustment-route {
display: grid; grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
align-items: stretch; gap: 8px; margin: 12px 0; padding: 10px;
background: #f4f7f9; border: 1px solid #dfe7eb;
}
.adjustment-route > div { display: grid; gap: 4px; padding: 9px 11px; background: white; border-left: 3px solid var(--teal); }
.adjustment-route small { color: var(--muted); font-size: 10px; }
.adjustment-route b { font-size: 12px; color: var(--ink); }
.adjustment-route span { color: var(--muted); font-size: 11px; }
.adjustment-route > i { align-self: center; color: var(--indigo); font: 700 20px/1 Consolas, monospace; text-align: center; }
.adjustment-form { display: grid; gap: 14px; }
.adjustment-step { padding: 16px; border: 1px solid var(--line); background: #fbfcfd; }
.adjustment-step > header { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 14px; }
.adjustment-step > header > b {
display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 26px;
color: white; background: var(--indigo); font: 700 12px/1 Consolas, monospace;
}
.adjustment-step > header h3 { margin: 1px 0 3px; font-size: 14px; }
.adjustment-step > header p { margin: 0; color: var(--muted); font-size: 11px; }
.adjustment-step .el-form-item:last-child { margin-bottom: 0; }
.target-step { border-color: #b9d9d4; background: #f4faf8; }
.source-target-strip { display: grid; grid-template-columns: 1fr 34px 1fr; align-items: stretch; gap: 8px; margin-bottom: 14px; }
.source-target-strip > div { display: grid; gap: 5px; padding: 11px; background: white; border: 1px solid #d9e3e6; }
.source-target-strip span { color: var(--muted); font-size: 10px; }
.source-target-strip strong { font-size: 11px; line-height: 1.55; }
.source-target-strip > i { align-self: center; color: var(--teal); font: 700 20px/1 Consolas, monospace; text-align: center; }
.session-used { float: right; color: #b34e48; }
.reason-field { padding: 14px 16px 0; border-top: 1px solid var(--line); }
@media (max-width: 680px) {
.adjustment-route, .source-target-strip { grid-template-columns: 1fr; }
.adjustment-route > i, .source-target-strip > i { transform: rotate(90deg); padding: 2px; }
.adjustment-step { padding: 13px; }
}
</style>