1010 lines
32 KiB
Vue
1010 lines
32 KiB
Vue
<script setup lang="ts">
|
||
import { getDisplayLocale } from '../i18n'
|
||
import { useI18n } from 'vue-i18n'
|
||
const { t } = useI18n()
|
||
import { computed, onMounted, reactive, ref } from 'vue'
|
||
import { useRoute } from 'vue-router'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import http, { apiErrorMessage } from '../api/http'
|
||
import { useAuthStore } from '../stores/auth'
|
||
|
||
interface TermOption {
|
||
id: string
|
||
name: string
|
||
startDate: string
|
||
endDate: string
|
||
isCurrent: boolean
|
||
hasPublishedTimetable: boolean
|
||
}
|
||
|
||
interface CampusOption {
|
||
id: string
|
||
code: string
|
||
name: string
|
||
}
|
||
|
||
interface BuildingOption {
|
||
id: string
|
||
code: string
|
||
name: string
|
||
campusId: string
|
||
}
|
||
|
||
interface ClassroomOption {
|
||
id: string
|
||
code: string
|
||
name: string
|
||
buildingId: string
|
||
capacity: number
|
||
roomType: string
|
||
}
|
||
|
||
interface AvailableClassroom extends ClassroomOption {
|
||
buildingName: string
|
||
campusId: string
|
||
campusName: string
|
||
}
|
||
|
||
interface TimeSlot {
|
||
periodNumber: number
|
||
name: string
|
||
startTime: string
|
||
endTime: string
|
||
}
|
||
|
||
interface Applicant {
|
||
id: string
|
||
displayName: string
|
||
collegeId: string
|
||
collegeName: string
|
||
}
|
||
|
||
interface Reservation {
|
||
id: string
|
||
applicantUserId: string
|
||
applicantName: string
|
||
applicantCollegeId: string
|
||
applicantCollegeName: string
|
||
academicTermId: string
|
||
academicTermName: string
|
||
classroomId: string
|
||
classroomCode: string
|
||
classroomName: string
|
||
buildingName: string
|
||
campusName: string
|
||
reservationDate: string
|
||
startPeriod: number
|
||
periodCount: number
|
||
attendeeCount: number
|
||
purpose: string
|
||
contactPhone: string
|
||
notes?: string
|
||
status: 'Submitted' | 'Approved' | 'Rejected' | 'Cancelled'
|
||
reviewComment?: string
|
||
reviewedAt?: string
|
||
cancelledAt?: string
|
||
createdAt: string
|
||
}
|
||
|
||
interface PagedResponse {
|
||
items: Reservation[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
}
|
||
|
||
const auth = useAuthStore()
|
||
const isCollegeAdmin = computed(() =>
|
||
auth.user?.roles.includes('CollegeAdmin') ?? false,
|
||
)
|
||
const route = useRoute()
|
||
const activeTab = ref<'mine' | 'review'>(route.query.tab === 'review' && isCollegeAdmin.value ? 'review' : 'mine')
|
||
const loading = ref(false)
|
||
const submitting = ref(false)
|
||
const availabilityLoading = ref(false)
|
||
const applicant = ref<Applicant | null>(null)
|
||
const applicantProblem = ref('')
|
||
const terms = ref<TermOption[]>([])
|
||
const campuses = ref<CampusOption[]>([])
|
||
const buildings = ref<BuildingOption[]>([])
|
||
const classrooms = ref<ClassroomOption[]>([])
|
||
const timeSlots = ref<TimeSlot[]>([])
|
||
const availableRooms = ref<AvailableClassroom[]>([])
|
||
const availabilityChecked = ref(false)
|
||
const mine = ref<Reservation[]>([])
|
||
const mineTotal = ref(0)
|
||
const minePage = ref(1)
|
||
const reviewItems = ref<Reservation[]>([])
|
||
const reviewTotal = ref(0)
|
||
const reviewPage = ref(1)
|
||
const pageSize = 12
|
||
const reviewStatus = ref<Reservation['status'] | ''>('Submitted')
|
||
|
||
const form = reactive({
|
||
academicTermId: '',
|
||
reservationDate: '',
|
||
campusId: '',
|
||
buildingId: '',
|
||
classroomId: '',
|
||
startPeriod: 1,
|
||
periodCount: 2,
|
||
attendeeCount: 1,
|
||
purpose: '',
|
||
contactPhone: '',
|
||
notes: '',
|
||
})
|
||
|
||
const selectedTerm = computed(() =>
|
||
terms.value.find((term) => term.id === form.academicTermId),
|
||
)
|
||
const filteredBuildings = computed(() =>
|
||
buildings.value.filter((building) =>
|
||
!form.campusId || building.campusId === form.campusId,
|
||
),
|
||
)
|
||
const availablePeriodCounts = computed(() => {
|
||
const enabled = new Set(timeSlots.value.map((slot) => slot.periodNumber))
|
||
const counts: number[] = []
|
||
for (let count = 1; count <= 6; count += 1) {
|
||
if (!enabled.has(form.startPeriod + count - 1)) break
|
||
counts.push(count)
|
||
}
|
||
return counts
|
||
})
|
||
|
||
const statusMeta = computed<Record<Reservation['status'], { label: string; type: 'warning' | 'success' | 'danger' | 'info' }>>(() => ({
|
||
Submitted: { label: t('classroomReservation.submitted'), type: 'warning' },
|
||
Approved: { label: t('classroomReservation.approved'), type: 'success' },
|
||
Rejected: { label: t('classroomReservation.rejected'), type: 'danger' },
|
||
Cancelled: { label: t('classroomReservation.cancelled'), type: 'info' },
|
||
}))
|
||
|
||
function statusInfo(status: unknown) {
|
||
return statusMeta.value[status as Reservation['status']]
|
||
?? { label: t('classroomReservation.unknown'), type: 'info' as const }
|
||
}
|
||
|
||
function todayText() {
|
||
const formatter = new Intl.DateTimeFormat('en-CA', {
|
||
timeZone: 'Asia/Shanghai',
|
||
year: 'numeric',
|
||
month: '2-digit',
|
||
day: '2-digit',
|
||
})
|
||
return formatter.format(new Date())
|
||
}
|
||
|
||
function initialReservationDate(term?: TermOption) {
|
||
const today = todayText()
|
||
if (!term) return today
|
||
if (today < term.startDate) return term.startDate
|
||
if (today > term.endDate) return ''
|
||
return today
|
||
}
|
||
|
||
function invalidateAvailability() {
|
||
availabilityChecked.value = false
|
||
availableRooms.value = []
|
||
form.classroomId = ''
|
||
}
|
||
|
||
async function loadOptions(termId?: string) {
|
||
const { data } = await http.get('/classroom-reservations/options', {
|
||
params: termId ? { academicTermId: termId } : {},
|
||
})
|
||
applicant.value = data.applicant
|
||
applicantProblem.value = data.applicantProblem ?? ''
|
||
terms.value = data.terms
|
||
campuses.value = data.campuses
|
||
buildings.value = data.buildings
|
||
classrooms.value = data.classrooms
|
||
timeSlots.value = data.timeSlots
|
||
const nextTermId = termId || data.selectedTermId || ''
|
||
form.academicTermId = nextTermId
|
||
if (!timeSlots.value.some((slot) => slot.periodNumber === form.startPeriod)) {
|
||
form.startPeriod = timeSlots.value[0]?.periodNumber ?? 1
|
||
}
|
||
if (!availablePeriodCounts.value.includes(form.periodCount)) {
|
||
form.periodCount = availablePeriodCounts.value[0] ?? 1
|
||
}
|
||
if (!form.reservationDate ||
|
||
form.reservationDate < (selectedTerm.value?.startDate ?? '') ||
|
||
form.reservationDate > (selectedTerm.value?.endDate ?? '9999-12-31')) {
|
||
form.reservationDate = initialReservationDate(selectedTerm.value)
|
||
}
|
||
invalidateAvailability()
|
||
}
|
||
|
||
async function changeTerm(termId: string) {
|
||
try {
|
||
await loadOptions(termId)
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
function changeCampus() {
|
||
if (form.buildingId &&
|
||
!filteredBuildings.value.some((building) => building.id === form.buildingId)) {
|
||
form.buildingId = ''
|
||
}
|
||
invalidateAvailability()
|
||
}
|
||
|
||
function isDateDisabled(value: Date) {
|
||
const term = selectedTerm.value
|
||
if (!term) return true
|
||
const date = [
|
||
value.getFullYear(),
|
||
String(value.getMonth() + 1).padStart(2, '0'),
|
||
String(value.getDate()).padStart(2, '0'),
|
||
].join('-')
|
||
return date < todayText() || date < term.startDate || date > term.endDate
|
||
}
|
||
|
||
async function queryAvailability() {
|
||
if (!form.academicTermId || !form.reservationDate) {
|
||
ElMessage.warning(t('classroomReservation.selectTermDate'))
|
||
return
|
||
}
|
||
availabilityLoading.value = true
|
||
try {
|
||
const { data } = await http.get('/classroom-reservations/availability', {
|
||
params: {
|
||
academicTermId: form.academicTermId,
|
||
reservationDate: form.reservationDate,
|
||
startPeriod: form.startPeriod,
|
||
periodCount: form.periodCount,
|
||
campusId: form.campusId || undefined,
|
||
buildingId: form.buildingId || undefined,
|
||
attendeeCount: form.attendeeCount,
|
||
},
|
||
})
|
||
availableRooms.value = data.items
|
||
availabilityChecked.value = true
|
||
if (!availableRooms.value.some((room) => room.id === form.classroomId)) {
|
||
form.classroomId = ''
|
||
}
|
||
if (availableRooms.value.length === 0) {
|
||
ElMessage.warning(t('classroomReservation.noRooms'))
|
||
}
|
||
} catch (error) {
|
||
availabilityChecked.value = false
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
availabilityLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function submitReservation() {
|
||
if (!applicant.value) {
|
||
ElMessage.error(applicantProblem.value || t('classroomReservation.noCollege'))
|
||
return
|
||
}
|
||
if (!availabilityChecked.value || !form.classroomId) {
|
||
ElMessage.warning(t('classroomReservation.selectRoom'))
|
||
return
|
||
}
|
||
if (!form.purpose.trim() || !form.contactPhone.trim()) {
|
||
ElMessage.warning(t('classroomReservation.requiredFields'))
|
||
return
|
||
}
|
||
submitting.value = true
|
||
try {
|
||
await http.post('/classroom-reservations', {
|
||
academicTermId: form.academicTermId,
|
||
classroomId: form.classroomId,
|
||
reservationDate: form.reservationDate,
|
||
startPeriod: form.startPeriod,
|
||
periodCount: form.periodCount,
|
||
attendeeCount: form.attendeeCount,
|
||
purpose: form.purpose.trim(),
|
||
contactPhone: form.contactPhone.trim(),
|
||
notes: form.notes.trim() || null,
|
||
})
|
||
ElMessage.success(t('classroomReservation.submittedMessage'))
|
||
form.purpose = ''
|
||
form.notes = ''
|
||
invalidateAvailability()
|
||
activeTab.value = 'mine'
|
||
minePage.value = 1
|
||
await loadMine()
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
submitting.value = false
|
||
}
|
||
}
|
||
|
||
async function loadMine() {
|
||
loading.value = true
|
||
try {
|
||
const { data } = await http.get<PagedResponse>('/classroom-reservations/mine', {
|
||
params: { page: minePage.value, pageSize },
|
||
})
|
||
mine.value = data.items
|
||
mineTotal.value = data.total
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
async function loadReview() {
|
||
if (!isCollegeAdmin.value) return
|
||
loading.value = true
|
||
try {
|
||
const { data } = await http.get<PagedResponse>('/classroom-reservations/review', {
|
||
params: {
|
||
status: reviewStatus.value || undefined,
|
||
page: reviewPage.value,
|
||
pageSize,
|
||
},
|
||
})
|
||
reviewItems.value = data.items
|
||
reviewTotal.value = data.total
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
async function changeTab(name: string | number) {
|
||
activeTab.value = name as 'mine' | 'review'
|
||
if (activeTab.value === 'review') await loadReview()
|
||
}
|
||
|
||
async function cancelReservation(item: Reservation | Record<string, any>) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
item.status === 'Approved'
|
||
? t('classroomReservation.cancelApproved')
|
||
: t('classroomReservation.cancelPending'),
|
||
t('classroomReservation.cancelTitle'),
|
||
{ type: 'warning', confirmButtonText: t('classroomReservation.confirmCancel'), cancelButtonText: t('classroomReservation.keep') },
|
||
)
|
||
await http.post(`/classroom-reservations/${item.id}/cancel`)
|
||
ElMessage.success(t('classroomReservation.cancelledMessage'))
|
||
await loadMine()
|
||
} catch (error) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function approveReservation(item: Reservation | Record<string, any>) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
t('classroomReservation.approveConfirm', { name: item.applicantName, building: item.buildingName, room: item.classroomName }),
|
||
t('classroomReservation.approveTitle'),
|
||
{ type: 'success', confirmButtonText: t('classroomReservation.approve'), cancelButtonText: t('classroomReservation.back') },
|
||
)
|
||
await http.post(`/classroom-reservations/${item.id}/approve`, { comment: null })
|
||
ElMessage.success(t('classroomReservation.approvedMessage'))
|
||
await loadReview()
|
||
} catch (error) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function rejectReservation(item: Reservation | Record<string, any>) {
|
||
try {
|
||
const result = await ElMessageBox.prompt(
|
||
t('classroomReservation.rejectPrompt'),
|
||
t('classroomReservation.rejectTitle'),
|
||
{
|
||
inputType: 'textarea',
|
||
inputPlaceholder: t('classroomReservation.reasonPlaceholder'),
|
||
inputValidator: (value) => value.trim().length > 0 || t('classroomReservation.reasonRequired'),
|
||
confirmButtonText: t('classroomReservation.confirmReject'),
|
||
cancelButtonText: t('classroomReservation.back'),
|
||
type: 'warning',
|
||
},
|
||
)
|
||
await http.post(`/classroom-reservations/${item.id}/reject`, {
|
||
comment: result.value.trim(),
|
||
})
|
||
ElMessage.success(t('statusChanges.messages.rejected'))
|
||
await loadReview()
|
||
} catch (error) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
function periodText(item: Reservation | Record<string, any>) {
|
||
const end = item.startPeriod + item.periodCount - 1
|
||
return item.periodCount === 1
|
||
? t('classroomReservation.singlePeriod', { start: item.startPeriod })
|
||
: t('classroomReservation.periodRange', { start: item.startPeriod, end })
|
||
}
|
||
|
||
function roomLabel(room: AvailableClassroom) {
|
||
return t('classroomReservation.roomLabel', { campus: room.campusName, building: room.buildingName, room: room.name, capacity: room.capacity })
|
||
}
|
||
|
||
function formatDateTime(value?: string) {
|
||
return value ? new Date(value).toLocaleString(getDisplayLocale(), { hour12: false }) : '—'
|
||
}
|
||
|
||
onMounted(async () => {
|
||
try {
|
||
await Promise.all([loadOptions(), loadMine(), ...(activeTab.value === 'review' ? [loadReview()] : [])])
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<section class="reservation-page">
|
||
<header class="page-heading">
|
||
<div>
|
||
<p class="eyebrow">{{ t('classroomReservation.kicker') }}</p>
|
||
<h2>{{ t('classroomReservation.title') }}</h2>
|
||
<p>{{ t('classroomReservation.description') }}</p>
|
||
</div>
|
||
<el-tag v-if="applicant" type="success" effect="plain" size="large">
|
||
{{ t('classroomReservation.reviewCollege', { college: applicant.collegeName }) }}
|
||
</el-tag>
|
||
</header>
|
||
|
||
<el-alert
|
||
v-if="applicantProblem"
|
||
:title="applicantProblem"
|
||
type="warning"
|
||
show-icon
|
||
:closable="false"
|
||
class="scope-alert"
|
||
/>
|
||
|
||
<el-card class="application-card" shadow="never">
|
||
<template #header>
|
||
<div class="card-title">
|
||
<div>
|
||
<h3>{{ t('classroomReservation.applyTitle') }}</h3>
|
||
<p>{{ t('classroomReservation.conflictHint') }}</p>
|
||
</div>
|
||
<span v-if="applicant">{{ applicant.displayName }} · {{ applicant.collegeName }}</span>
|
||
</div>
|
||
</template>
|
||
|
||
<el-form label-position="top" :disabled="!applicant">
|
||
<div class="form-grid">
|
||
<el-form-item :label="t('businessLabels.term')" required>
|
||
<el-select
|
||
v-model="form.academicTermId"
|
||
:placeholder="t('classroomReservation.selectTerm')"
|
||
@change="changeTerm"
|
||
>
|
||
<el-option
|
||
v-for="term in terms"
|
||
:key="term.id"
|
||
:value="term.id"
|
||
:label="term.hasPublishedTimetable ? term.name : t('classroomReservation.unpublishedTerm', { term: term.name })"
|
||
:disabled="!term.hasPublishedTimetable"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('classroomReservation.date')" required>
|
||
<el-date-picker
|
||
v-model="form.reservationDate"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
format="YYYY-MM-DD"
|
||
:placeholder="t('classroomReservation.selectDate')"
|
||
:disabled-date="isDateDisabled"
|
||
@change="invalidateAvailability"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item :label="t('freeClassrooms.startPeriod')" required>
|
||
<el-select v-model="form.startPeriod" @change="invalidateAvailability">
|
||
<el-option
|
||
v-for="slot in timeSlots"
|
||
:key="slot.periodNumber"
|
||
:value="slot.periodNumber"
|
||
:label="`${slot.name}${slot.startTime ? `(${slot.startTime}—${slot.endTime})` : ''}`"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('freeClassrooms.periodCount')" required>
|
||
<el-select v-model="form.periodCount" @change="invalidateAvailability">
|
||
<el-option
|
||
v-for="count in availablePeriodCounts"
|
||
:key="count"
|
||
:value="count"
|
||
:label="t('classroomReservation.periodCount', { count })"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('classroomReservation.attendees')" required>
|
||
<el-input-number
|
||
v-model="form.attendeeCount"
|
||
:min="1"
|
||
:max="10000"
|
||
controls-position="right"
|
||
@change="invalidateAvailability"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item :label="t('freeClassrooms.campus')">
|
||
<el-select
|
||
v-model="form.campusId"
|
||
clearable
|
||
:placeholder="t('freeClassrooms.allCampuses')"
|
||
@change="changeCampus"
|
||
>
|
||
<el-option
|
||
v-for="campus in campuses"
|
||
:key="campus.id"
|
||
:value="campus.id"
|
||
:label="campus.name"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('businessLabels.building')">
|
||
<el-select
|
||
v-model="form.buildingId"
|
||
clearable
|
||
:placeholder="t('classroomReservation.allBuildings')"
|
||
@change="invalidateAvailability"
|
||
>
|
||
<el-option
|
||
v-for="building in filteredBuildings"
|
||
:key="building.id"
|
||
:value="building.id"
|
||
:label="building.name"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('classroomReservation.availableRooms')" required>
|
||
<div class="room-picker">
|
||
<el-select
|
||
v-model="form.classroomId"
|
||
filterable
|
||
:disabled="!availabilityChecked"
|
||
:placeholder="availabilityChecked ? t('classroomReservation.chooseRoom') : t('classroomReservation.searchFirst')"
|
||
>
|
||
<el-option
|
||
v-for="room in availableRooms"
|
||
:key="room.id"
|
||
:value="room.id"
|
||
:label="roomLabel(room)"
|
||
/>
|
||
</el-select>
|
||
<el-button
|
||
:loading="availabilityLoading"
|
||
type="primary"
|
||
plain
|
||
@click="queryAvailability"
|
||
>
|
||
{{ t('classroomReservation.searchRooms') }}
|
||
</el-button>
|
||
</div>
|
||
</el-form-item>
|
||
<el-form-item :label="t('classroomReservation.purpose')" required class="span-2">
|
||
<el-input
|
||
v-model="form.purpose"
|
||
maxlength="200"
|
||
show-word-limit
|
||
:placeholder="t('classroomReservation.purposePlaceholder')"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item :label="t('businessLabels.phone')" required>
|
||
<el-input
|
||
v-model="form.contactPhone"
|
||
maxlength="30"
|
||
:placeholder="t('classroomReservation.contactHint')"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item :label="t('classroomReservation.notes')" class="span-2">
|
||
<el-input
|
||
v-model="form.notes"
|
||
type="textarea"
|
||
:rows="3"
|
||
maxlength="500"
|
||
show-word-limit
|
||
:placeholder="t('classroomReservation.notesPlaceholder')"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="submit-row">
|
||
<p v-if="availabilityChecked">
|
||
{{ t('classroomReservation.roomsFound', { count: availableRooms.length }) }}
|
||
</p>
|
||
<span v-else>{{ t('classroomReservation.searchAgain') }}</span>
|
||
<el-button
|
||
type="primary"
|
||
size="large"
|
||
:loading="submitting"
|
||
@click="submitReservation"
|
||
>
|
||
{{ t('classroomReservation.submit') }}
|
||
</el-button>
|
||
</div>
|
||
</el-form>
|
||
</el-card>
|
||
|
||
<el-card class="records-card" shadow="never">
|
||
<el-tabs v-model="activeTab" @tab-change="changeTab">
|
||
<el-tab-pane :label="t('classroomReservation.mine')" name="mine">
|
||
<div v-loading="loading">
|
||
<el-table :data="mine" class="desktop-table">
|
||
<el-table-column :label="t('classroomReservation.datePeriods')" min-width="150">
|
||
<template #default="{ row }">
|
||
<b>{{ row.reservationDate }}</b>
|
||
<small>{{ periodText(row) }}</small>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.classroom')" min-width="190">
|
||
<template #default="{ row }">
|
||
<b>{{ row.buildingName }} · {{ row.classroomName }}</b>
|
||
<small>{{ t('classroomReservation.campusAttendees', { campus: row.campusName, count: row.attendeeCount }) }}</small>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="purpose" :label="t('classroomReservation.purposeShort')" min-width="180" show-overflow-tooltip />
|
||
<el-table-column :label="t('businessLabels.status')" width="120">
|
||
<template #default="{ row }">
|
||
<el-tag :type="statusInfo(row.status).type">
|
||
{{ statusInfo(row.status).label }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.reviewComment')" min-width="170">
|
||
<template #default="{ row }">{{ row.reviewComment || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.actions')" width="160" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button link type="primary" @click="$router.push({ path: '/approvals', query: { progressType: 'ClassroomReservation', progressId: row.id } })">{{ t('approvalProgress.title') }}</el-button>
|
||
<el-button
|
||
v-if="['Submitted', 'Approved'].includes(row.status)"
|
||
link
|
||
type="danger"
|
||
@click="cancelReservation(row)"
|
||
>
|
||
{{ t('classroomReservation.cancel') }}
|
||
</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div class="mobile-records">
|
||
<article v-for="item in mine" :key="item.id" class="record-item">
|
||
<header>
|
||
<div>
|
||
<b>{{ item.reservationDate }} · {{ periodText(item) }}</b>
|
||
<span>{{ item.buildingName }} {{ item.classroomName }}</span>
|
||
</div>
|
||
<el-tag :type="statusInfo(item.status).type">
|
||
{{ statusInfo(item.status).label }}
|
||
</el-tag>
|
||
</header>
|
||
<p>{{ item.purpose }}</p>
|
||
<small>{{ t('classroomReservation.attendeesPhone', { count: item.attendeeCount, phone: item.contactPhone }) }}</small>
|
||
<blockquote v-if="item.reviewComment">{{ item.reviewComment }}</blockquote>
|
||
<el-button text type="primary" @click="$router.push({ path: '/approvals', query: { progressType: 'ClassroomReservation', progressId: item.id } })">{{ t('approvalProgress.title') }}</el-button>
|
||
<el-button
|
||
v-if="['Submitted', 'Approved'].includes(item.status)"
|
||
type="danger"
|
||
plain
|
||
@click="cancelReservation(item)"
|
||
>
|
||
{{ t('classroomReservation.cancelReservation') }}
|
||
</el-button>
|
||
</article>
|
||
</div>
|
||
<el-empty v-if="mine.length === 0" :description="t('classroomReservation.emptyMine')" />
|
||
<el-pagination
|
||
v-if="mineTotal > pageSize"
|
||
v-model:current-page="minePage"
|
||
:page-size="pageSize"
|
||
:total="mineTotal"
|
||
layout="prev, pager, next"
|
||
@current-change="loadMine"
|
||
/>
|
||
</div>
|
||
</el-tab-pane>
|
||
|
||
<el-tab-pane v-if="isCollegeAdmin" :label="t('classroomReservation.collegeReview')" name="review">
|
||
<div class="review-toolbar">
|
||
<div>
|
||
<h3>{{ t('classroomReservation.reviewQueue', { college: applicant?.collegeName || auth.user?.displayName }) }}</h3>
|
||
<p>{{ t('classroomReservation.reviewHint') }}</p>
|
||
</div>
|
||
<el-select
|
||
v-model="reviewStatus"
|
||
style="width: 150px"
|
||
@change="reviewPage = 1; loadReview()"
|
||
>
|
||
<el-option :label="t('businessLabels.pending')" value="Submitted" />
|
||
<el-option :label="t('statusChanges.states.Approved')" value="Approved" />
|
||
<el-option :label="t('businessLabels.rejected')" value="Rejected" />
|
||
<el-option :label="t('enrollmentManagement.statuses.Cancelled')" value="Cancelled" />
|
||
<el-option :label="t('businessLabels.allStatus')" value="" />
|
||
</el-select>
|
||
</div>
|
||
<div v-loading="loading">
|
||
<el-table :data="reviewItems" class="desktop-table">
|
||
<el-table-column :label="t('classroomReservation.applicant')" min-width="140">
|
||
<template #default="{ row }">
|
||
<b>{{ row.applicantName }}</b>
|
||
<small>{{ row.applicantCollegeName }}</small>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('classroomReservation.dateRoom')" min-width="220">
|
||
<template #default="{ row }">
|
||
<b>{{ row.reservationDate }} · {{ periodText(row) }}</b>
|
||
<small>{{ row.campusName }} · {{ row.buildingName }} {{ row.classroomName }}</small>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('classroomReservation.purposeAttendees')" min-width="220">
|
||
<template #default="{ row }">
|
||
<span>{{ row.purpose }}</span>
|
||
<small>{{ t('classroomReservation.attendeesPhone', { count: row.attendeeCount, phone: row.contactPhone }) }}</small>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('classroomReservation.submittedAt')" width="170">
|
||
<template #default="{ row }">{{ formatDateTime(row.createdAt) }}</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.status')" width="120">
|
||
<template #default="{ row }">
|
||
<el-tag :type="statusInfo(row.status).type">
|
||
{{ statusInfo(row.status).label }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.actions')" width="150" fixed="right">
|
||
<template #default="{ row }">
|
||
<template v-if="row.status === 'Submitted'">
|
||
<el-button link type="success" @click="approveReservation(row)">{{ t('classroomReservation.approve') }}</el-button>
|
||
<el-button link type="danger" @click="rejectReservation(row)">{{ t('businessLabels.reject') }}</el-button>
|
||
</template>
|
||
<span v-else>{{ row.reviewComment || '—' }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div class="mobile-records">
|
||
<article v-for="item in reviewItems" :key="item.id" class="record-item">
|
||
<header>
|
||
<div>
|
||
<b>{{ item.applicantName }} · {{ item.reservationDate }}</b>
|
||
<span>{{ periodText(item) }} · {{ item.buildingName }} {{ item.classroomName }}</span>
|
||
</div>
|
||
<el-tag :type="statusInfo(item.status).type">
|
||
{{ statusInfo(item.status).label }}
|
||
</el-tag>
|
||
</header>
|
||
<p>{{ item.purpose }}</p>
|
||
<small>{{ t('classroomReservation.attendeesPhone', { count: item.attendeeCount, phone: item.contactPhone }) }}</small>
|
||
<div v-if="item.status === 'Submitted'" class="review-actions">
|
||
<el-button type="success" @click="approveReservation(item)">{{ t('classroomReservation.approve') }}</el-button>
|
||
<el-button type="danger" plain @click="rejectReservation(item)">{{ t('businessLabels.reject') }}</el-button>
|
||
</div>
|
||
<blockquote v-else-if="item.reviewComment">{{ item.reviewComment }}</blockquote>
|
||
</article>
|
||
</div>
|
||
<el-empty v-if="reviewItems.length === 0" :description="t('classroomReservation.emptyReview')" />
|
||
<el-pagination
|
||
v-if="reviewTotal > pageSize"
|
||
v-model:current-page="reviewPage"
|
||
:page-size="pageSize"
|
||
:total="reviewTotal"
|
||
layout="prev, pager, next"
|
||
@current-change="loadReview"
|
||
/>
|
||
</div>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
</el-card>
|
||
</section>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.reservation-page {
|
||
display: grid;
|
||
gap: 20px;
|
||
}
|
||
|
||
.page-heading,
|
||
.card-title,
|
||
.submit-row,
|
||
.review-toolbar,
|
||
.record-item header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
}
|
||
|
||
.page-heading h2,
|
||
.card-title h3,
|
||
.review-toolbar h3 {
|
||
margin: 0;
|
||
color: #183b56;
|
||
}
|
||
|
||
.page-heading p,
|
||
.card-title p,
|
||
.review-toolbar p {
|
||
margin: 5px 0 0;
|
||
color: #6c7f90;
|
||
}
|
||
|
||
.eyebrow {
|
||
color: #17867c !important;
|
||
font-size: 12px;
|
||
font-weight: 800;
|
||
letter-spacing: .16em;
|
||
}
|
||
|
||
.scope-alert {
|
||
border: 1px solid #f3d7a5;
|
||
}
|
||
|
||
.application-card,
|
||
.records-card {
|
||
border: 1px solid #dfe9ec;
|
||
border-radius: 12px;
|
||
}
|
||
|
||
.card-title > span {
|
||
color: #17867c;
|
||
font-weight: 700;
|
||
}
|
||
|
||
.form-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||
gap: 0 16px;
|
||
}
|
||
|
||
.span-2 {
|
||
grid-column: span 2;
|
||
}
|
||
|
||
.room-picker {
|
||
display: flex;
|
||
width: 100%;
|
||
gap: 8px;
|
||
}
|
||
|
||
.room-picker .el-select {
|
||
flex: 1;
|
||
}
|
||
|
||
.submit-row {
|
||
padding-top: 10px;
|
||
border-top: 1px dashed #dfe9ec;
|
||
}
|
||
|
||
.submit-row p,
|
||
.submit-row span {
|
||
margin: 0;
|
||
color: #6c7f90;
|
||
font-size: 13px;
|
||
}
|
||
|
||
.submit-row b {
|
||
color: #17867c;
|
||
}
|
||
|
||
.desktop-table b,
|
||
.desktop-table span,
|
||
.desktop-table small {
|
||
display: block;
|
||
}
|
||
|
||
.desktop-table small {
|
||
margin-top: 4px;
|
||
color: #7a8a99;
|
||
}
|
||
|
||
.review-toolbar {
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.mobile-records {
|
||
display: none;
|
||
}
|
||
|
||
.record-item {
|
||
align-items: stretch;
|
||
flex-direction: column;
|
||
padding: 15px;
|
||
border: 1px solid #dfe9ec;
|
||
border-radius: 10px;
|
||
background: #fff;
|
||
}
|
||
|
||
.record-item + .record-item {
|
||
margin-top: 10px;
|
||
}
|
||
|
||
.record-item header {
|
||
align-items: flex-start;
|
||
}
|
||
|
||
.record-item header b,
|
||
.record-item header span,
|
||
.record-item small {
|
||
display: block;
|
||
}
|
||
|
||
.record-item header span,
|
||
.record-item small {
|
||
margin-top: 4px;
|
||
color: #738596;
|
||
}
|
||
|
||
.record-item p {
|
||
margin: 12px 0 2px;
|
||
color: #29495f;
|
||
}
|
||
|
||
.record-item blockquote {
|
||
margin: 10px 0 0;
|
||
padding: 9px 12px;
|
||
border-left: 3px solid #e4a74e;
|
||
background: #fff9ef;
|
||
color: #805d2c;
|
||
}
|
||
|
||
.review-actions {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 8px;
|
||
margin-top: 12px;
|
||
}
|
||
|
||
.el-pagination {
|
||
justify-content: flex-end;
|
||
margin-top: 16px;
|
||
}
|
||
|
||
@media (max-width: 1100px) {
|
||
.form-grid {
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
}
|
||
}
|
||
|
||
@media (max-width: 720px) {
|
||
.page-heading,
|
||
.card-title,
|
||
.submit-row,
|
||
.review-toolbar {
|
||
align-items: flex-start;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.form-grid {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
|
||
.span-2 {
|
||
grid-column: span 1;
|
||
}
|
||
|
||
.room-picker {
|
||
flex-direction: column;
|
||
}
|
||
|
||
.submit-row .el-button,
|
||
.review-toolbar .el-select {
|
||
width: 100% !important;
|
||
}
|
||
|
||
.desktop-table {
|
||
display: none;
|
||
}
|
||
|
||
.mobile-records {
|
||
display: block;
|
||
}
|
||
|
||
.el-pagination {
|
||
justify-content: center;
|
||
}
|
||
}
|
||
</style>
|