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

1321 lines
38 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.reschedule"),
Cancel: t("adjustmentBatch.cancelClass"),
Makeup: t("adjustmentBatch.makeupClass"),
Substitute: t("adjustmentBatch.substituteTeacher"),
}));
const statusLabels = computed<Record<string, string>>(() => ({
Draft: t("adjustmentBatch.draft"),
Submitted: t("adjustmentBatch.pendingReview"),
Approved: t("adjustmentBatch.approved"),
Rejected: t("adjustmentBatch.returned"),
}));
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.periodNumberNameStartEnd", {
number: item.periodNumber,
name: item.name,
start: item.startsAt,
end: item.endsAt,
}),
}));
}
return Array.from({ length: 12 }, (_, i) => ({
value: i + 1,
label: t("adjustmentBatch.periodNumber", { 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.noFixedClassroom")}`;
return t("adjustmentBatch.weekWeekDateDayPeriodsStartEndRoom", {
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.selectATeachingClass"));
return;
}
if (sourceRequired.value && !selectedSession.value) {
ElMessage.warning(t("adjustmentBatch.selectTheOriginalClassSession"));
return;
}
if (selectedSession.value?.hasExistingAdjustment) {
ElMessage.warning(
t(
"adjustmentBatch.thisSessionAlreadyHasAnAdjustmentSelectAnotherSession",
),
);
return;
}
if (["Reschedule", "Makeup"].includes(form.type) && !form.targetDate) {
ElMessage.warning(t("adjustmentBatch.selectATargetDate"));
return;
}
if (["Reschedule", "Makeup"].includes(form.type) && !form.startPeriod) {
ElMessage.warning(t("adjustmentBatch.selectATargetPeriod"));
return;
}
if (!form.reason.trim()) {
ElMessage.warning(t("adjustmentBatch.enterAReasonForTheRequest"));
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.requestSubmitted"));
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.submittedForReview"));
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.approved"));
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.classAdjustments") }}</h2>
<p>
{{
t(
"adjustmentBatch.teachersRequestReschedulingCancellationMakeupClassesOrSubstitutionChangesTakeEffectAfterCollegeReviewAndRelevantPeopleAreNotified",
)
}}
</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.myRequests'), value: 'mine' }]
: []),
...(isManager
? [{ label: t('adjustmentBatch.pendingReview'), 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.reason") }}</b
>{{ adj.reason }}
</p>
<div v-if="adj.sourceDate" class="adjustment-route">
<div>
<small>{{ t("adjustmentBatch.originalSession") }}</small
><b>{{
t("adjustmentBatch.weekWeekDatePeriodsStartEnd", {
week: adj.sourceWeek,
date: adj.sourceDate,
start: adj.sourceStartPeriod,
end: adj.sourceStartPeriod + adj.sourcePeriodCount - 1,
})
}}</b
><span>{{
adj.sourceClassroomName || t("adjustmentBatch.noFixedClassroom")
}}</span>
</div>
<i>{{ adj.type === "Cancel" ? "×" : "→" }}</i>
<div v-if="adj.type !== 'Cancel'">
<small>{{
adj.type === "Makeup"
? t("adjustmentBatch.addMakeupClass")
: t("adjustmentBatch.moveTo")
}}</small
><b>{{
t("adjustmentBatch.datePeriodsStartEnd", {
date: adj.targetDate,
start: adj.startPeriod,
end: adj.startPeriod + adj.periodCount - 1,
})
}}</b
><span>{{
adj.classroomName
? `${adj.buildingName} ${adj.classroomName}`
: adj.sourceClassroomName ||
t("adjustmentBatch.noFixedClassroom")
}}</span>
</div>
<div v-else>
<small>{{ t("adjustmentBatch.result") }}</small
><b>{{ t("adjustmentBatch.cancelThisSessionOnly") }}</b
><span>{{ t("adjustmentBatch.otherWeeksRemainUnchanged") }}</span>
</div>
</div>
<div class="adj-details">
<span v-if="!adj.sourceDate && adj.targetDate"
><b>{{ t("adjustmentBatch.date") }}</b
>{{ adj.targetDate }}</span
>
<span v-if="!adj.sourceDate && adj.dayOfWeek"
><b>{{ t("adjustmentBatch.day") }}</b
>{{ weekdayLabel(adj.dayOfWeek) }}</span
>
<span v-if="!adj.sourceDate && adj.startPeriod"
><b>{{ t("adjustmentBatch.periods") }}</b
>{{
t("adjustmentBatch.periodsStartEnd", {
start: adj.startPeriod,
end: adj.startPeriod + adj.periodCount - 1,
})
}}</span
>
<span v-if="!adj.sourceDate && adj.cancelWeek"
><b>{{ t("adjustmentBatch.cancelledWeek") }}</b
>{{
t("adjustmentBatch.weekWeek", { week: adj.cancelWeek })
}}</span
>
<span v-if="adj.substituteTeacherName"
><b>{{ t("adjustmentBatch.substituteTeacher2") }}</b
>{{ adj.substituteTeacherName }}</span
>
</div>
<el-alert
v-if="adj.reviewComment"
:title="
t('adjustmentBatch.reviewCommentComment', {
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.submitForReview")
}}</el-button>
</footer>
</article>
<el-empty
v-if="!adjustments.length"
:description="t('adjustmentBatch.noClassAdjustmentRequests')"
/>
<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.batchPage", { 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.reason") }}</b
>{{ adj.reason }}
</p>
<div v-if="adj.sourceDate" class="adjustment-route">
<div>
<small>{{ t("adjustmentBatch.originalSession") }}</small
><b>{{
t("adjustmentBatch.weekWeekDatePeriodsStartEnd", {
week: adj.sourceWeek,
date: adj.sourceDate,
start: adj.sourceStartPeriod,
end: adj.sourceStartPeriod + adj.sourcePeriodCount - 1,
})
}}</b
><span>{{
adj.sourceClassroomName || t("adjustmentBatch.noFixedClassroom")
}}</span>
</div>
<i>{{ adj.type === "Cancel" ? "×" : "→" }}</i>
<div v-if="adj.type !== 'Cancel'">
<small>{{
adj.type === "Makeup"
? t("adjustmentBatch.addMakeupClass")
: t("adjustmentBatch.moveTo")
}}</small
><b>{{
t("adjustmentBatch.datePeriodsStartEnd", {
date: adj.targetDate,
start: adj.startPeriod,
end: adj.startPeriod + adj.periodCount - 1,
})
}}</b
><span>{{
adj.classroomName
? `${adj.buildingName} ${adj.classroomName}`
: adj.sourceClassroomName ||
t("adjustmentBatch.noFixedClassroom")
}}</span>
</div>
<div v-else>
<small>{{ t("adjustmentBatch.result") }}</small
><b>{{ t("adjustmentBatch.cancelThisSessionOnly") }}</b
><span>{{ t("adjustmentBatch.otherWeeksRemainUnchanged") }}</span>
</div>
</div>
<div class="adj-details">
<span v-if="!adj.sourceDate && adj.targetDate"
><b>{{ t("adjustmentBatch.date") }}</b
>{{ adj.targetDate }}</span
>
<span v-if="!adj.sourceDate && adj.dayOfWeek"
><b>{{ t("adjustmentBatch.day") }}</b
>{{ weekdayLabel(adj.dayOfWeek) }}</span
>
<span v-if="!adj.sourceDate && adj.startPeriod"
><b>{{ t("adjustmentBatch.periods") }}</b
>{{
t("adjustmentBatch.periodsStartEnd", {
start: adj.startPeriod,
end: adj.startPeriod + adj.periodCount - 1,
})
}}</span
>
<span v-if="!adj.sourceDate && adj.cancelWeek"
><b>{{ t("adjustmentBatch.cancelledWeek") }}</b
>{{
t("adjustmentBatch.weekWeek", { week: adj.cancelWeek })
}}</span
>
<span v-if="adj.substituteTeacherName"
><b>{{ t("adjustmentBatch.substituteTeacher2") }}</b
>{{ adj.substituteTeacherName }}</span
>
</div>
<p class="adj-meta">
<b>{{ t("adjustmentBatch.submitted") }}</b
>{{ new Date(adj.submittedAt).toLocaleString(getDisplayLocale()) }}
</p>
</div>
<footer>
<el-button
size="small"
type="danger"
plain
@click="openReject(adj)"
>{{ t("adjustmentBatch.return") }}</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.noRequestsAwaitingReview')"
/>
<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.batchPage", { 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.requestASingleClassAdjustment')"
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.selectAdjustmentType") }}</h3>
<p>
{{
t("adjustmentBatch.eachRequestAppliesToOneSpecificSession")
}}
</p>
</div>
</header>
<el-form-item :label="t('statusChanges.type')" required>
<el-segmented
v-model="form.type"
:options="[
{ label: t('adjustmentBatch.reschedule'), value: 'Reschedule' },
{ label: t('adjustmentBatch.cancelClass'), value: 'Cancel' },
{ label: t('adjustmentBatch.makeupClass'), value: 'Makeup' },
{
label: t('adjustmentBatch.substituteTeacher'),
value: 'Substitute',
},
]"
@change="changeType"
/>
</el-form-item>
<el-alert
:title="
form.type === 'Reschedule'
? t(
'adjustmentBatch.moveTheOriginalSessionToADifferentDateAndPeriodTheOriginalTimeIsFreed',
)
: form.type === 'Cancel'
? t(
'adjustmentBatch.cancelOnlyTheSelectedSessionOtherWeeksAreUnaffected',
)
: form.type === 'Makeup'
? t(
'adjustmentBatch.keepTheOriginalSessionAndAddAMakeupClass',
)
: t(
'adjustmentBatch.addASubstituteTeacherToTheTeachingClass',
)
"
type="info"
:closable="false"
/>
</section>
<section class="adjustment-step">
<header>
<b>2</b>
<div>
<h3>{{ t("adjustmentBatch.selectTheOriginalSession") }}</h3>
<p>
{{
t(
"adjustmentBatch.chooseFromThePublishedTimetableInsteadOfEnteringTheWeekAndDayManually",
)
}}
</p>
</div>
</header>
<el-form-item :label="t('adjustmentBatch.teachingClass')" required>
<el-select
v-model="form.teachingTaskId"
filterable
:placeholder="t('adjustmentBatch.selectATeachingClassYouTeach')"
@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.originalSession')"
required
>
<el-select
v-model="form.sourceKey"
filterable
:loading="sessionLoading"
:placeholder="t('adjustmentBatch.selectAWeekDayAndPeriod')"
@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.requestExists") }}</small
>
</el-option>
</el-select>
</el-form-item>
<el-empty
v-if="
form.teachingTaskId &&
sourceRequired &&
!sessionLoading &&
!sessionOptions.length
"
:description="
t(
'adjustmentBatch.noPublishedSessionsAreAvailableForThisTeachingClass',
)
"
: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.scheduleTheRescheduledSession")
: t("adjustmentBatch.scheduleTheMakeupSession")
}}
</h3>
<p>
{{
t(
"adjustmentBatch.theOriginalDurationIsRetainedTeacherClassAndClassroomConflictsAreCheckedDuringReview",
)
}}
</p>
</div>
</header>
<div class="source-target-strip" v-if="selectedSession">
<div>
<span>{{ t("adjustmentBatch.originalSession") }}</span
><strong>{{ sessionLabel(selectedSession) }}</strong>
</div>
<i>→</i>
<div>
<span>{{ t("adjustmentBatch.targetSession") }}</span
><strong
>{{ form.targetDate || t("adjustmentBatch.selectADate") }} ·
{{
form.startPeriod
? t("adjustmentBatch.fromPeriodNumber", {
number: form.startPeriod,
})
: t("adjustmentBatch.selectAPeriod")
}}</strong
>
</div>
</div>
<div class="form-grid two">
<el-form-item :label="t('adjustmentBatch.targetDate')" 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.selectADateWithinThisTerm')"
/>
</el-form-item>
<el-form-item
:label="t('adjustmentBatch.targetStartingPeriod')"
required
>
<el-select
v-model="form.startPeriod"
:placeholder="t('adjustmentBatch.selectAPeriod2')"
>
<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.targetClassroom')">
<el-select
v-model="form.classroomId"
clearable
filterable
:placeholder="
t('adjustmentBatch.leaveBlankToUseTheOriginalClassroom')
"
>
<el-option
v-for="room in classrooms"
:key="room.id"
:label="`${room.campusName} · ${room.buildingName} ${room.name} · ${t('adjustmentBatch.countPeople', { 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.selectASubstituteTeacher") }}</h3>
<p>
{{ t("adjustmentBatch.theSubstituteMustBeAnActiveTeacher") }}
</p>
</div>
</header>
<el-form-item
:label="t('adjustmentBatch.substituteTeacher3')"
required
>
<el-select
v-model="form.substituteTeacherId"
filterable
:placeholder="t('adjustmentBatch.selectASubstituteTeacher')"
/>
</el-form-item>
</section>
</template>
<el-form-item
:label="t('adjustmentBatch.reasonForRequest')"
required
class="reason-field"
>
<el-input
v-model="form.reason"
type="textarea"
:rows="3"
maxlength="500"
show-word-limit
:placeholder="t('adjustmentBatch.explainTheReasonForTheAdjustment')"
/>
</el-form-item>
<el-form-item>
<el-checkbox v-model="form.submit">{{
t("adjustmentBatch.sendForReviewImmediately")
}}</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.returnRequest')"
width="500px"
>
<el-form label-position="top">
<el-form-item :label="t('adjustmentBatch.returnComment')">
<el-input
v-model="rejectComment"
type="textarea"
:rows="3"
maxlength="500"
show-word-limit
:placeholder="
t('adjustmentBatch.explainWhyThisRequestIsBeingReturned')
"
/>
</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.confirmReturn")
}}</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: var(--surface);
border: 1px solid var(--line);
border-radius: var(--radius-card);
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: var(--surface-muted);
}
.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>