feat: localize classroom reservation workflows
This commit is contained in:
1 parent
77fd2a1ac3
commit
eb40272594
4 files changed
+79
-77
No files matched your search
@@ -150,16 +150,16 @@ const availablePeriodCounts = computed(() => {
|
||||
return counts
|
||||
})
|
||||
|
||||
const statusMeta: Record<Reservation['status'], { label: string; type: 'warning' | 'success' | 'danger' | 'info' }> = {
|
||||
Submitted: { label: '待学院审核', type: 'warning' },
|
||||
Approved: { label: '已批准', type: 'success' },
|
||||
Rejected: { label: '已驳回', type: 'danger' },
|
||||
Cancelled: { label: '已取消', type: 'info' },
|
||||
}
|
||||
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[status as Reservation['status']]
|
||||
?? { label: '未知状态', type: 'info' as const }
|
||||
return statusMeta.value[status as Reservation['status']]
|
||||
?? { label: t('classroomReservation.unknown'), type: 'info' as const }
|
||||
}
|
||||
|
||||
function todayText() {
|
||||
@@ -242,7 +242,7 @@ function isDateDisabled(value: Date) {
|
||||
|
||||
async function queryAvailability() {
|
||||
if (!form.academicTermId || !form.reservationDate) {
|
||||
ElMessage.warning('请先选择学期和预约日期。')
|
||||
ElMessage.warning(t('classroomReservation.selectTermDate'))
|
||||
return
|
||||
}
|
||||
availabilityLoading.value = true
|
||||
@@ -264,7 +264,7 @@ async function queryAvailability() {
|
||||
form.classroomId = ''
|
||||
}
|
||||
if (availableRooms.value.length === 0) {
|
||||
ElMessage.warning('当前条件下没有可预约教室,请调整日期、节次或人数。')
|
||||
ElMessage.warning(t('classroomReservation.noRooms'))
|
||||
}
|
||||
} catch (error) {
|
||||
availabilityChecked.value = false
|
||||
@@ -276,15 +276,15 @@ async function queryAvailability() {
|
||||
|
||||
async function submitReservation() {
|
||||
if (!applicant.value) {
|
||||
ElMessage.error(applicantProblem.value || '当前账号没有可用的学院归属。')
|
||||
ElMessage.error(applicantProblem.value || t('classroomReservation.noCollege'))
|
||||
return
|
||||
}
|
||||
if (!availabilityChecked.value || !form.classroomId) {
|
||||
ElMessage.warning('请先查询可用教室并选择教室。')
|
||||
ElMessage.warning(t('classroomReservation.selectRoom'))
|
||||
return
|
||||
}
|
||||
if (!form.purpose.trim() || !form.contactPhone.trim()) {
|
||||
ElMessage.warning('请填写借用用途和联系电话。')
|
||||
ElMessage.warning(t('classroomReservation.requiredFields'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
@@ -300,7 +300,7 @@ async function submitReservation() {
|
||||
contactPhone: form.contactPhone.trim(),
|
||||
notes: form.notes.trim() || null,
|
||||
})
|
||||
ElMessage.success('申请已提交,将由您所在学院审核。')
|
||||
ElMessage.success(t('classroomReservation.submittedMessage'))
|
||||
form.purpose = ''
|
||||
form.notes = ''
|
||||
invalidateAvailability()
|
||||
@@ -358,13 +358,13 @@ async function cancelReservation(item: Reservation | Record<string, any>) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
item.status === 'Approved'
|
||||
? '该预约已经批准,取消后教室将立即释放。确认取消吗?'
|
||||
: '确认撤回这条待审核申请吗?',
|
||||
'取消教室预约',
|
||||
{ type: 'warning', confirmButtonText: '确认取消', cancelButtonText: '暂不取消' },
|
||||
? 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('预约已取消。')
|
||||
ElMessage.success(t('classroomReservation.cancelledMessage'))
|
||||
await loadMine()
|
||||
} catch (error) {
|
||||
if (error === 'cancel' || error === 'close') return
|
||||
@@ -375,12 +375,12 @@ async function cancelReservation(item: Reservation | Record<string, any>) {
|
||||
async function approveReservation(item: Reservation | Record<string, any>) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认批准 ${item.applicantName} 对 ${item.buildingName} ${item.classroomName} 的借用申请吗?系统会再次检查占用冲突。`,
|
||||
'批准教室借用',
|
||||
{ type: 'success', confirmButtonText: '批准', cancelButtonText: '返回' },
|
||||
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('申请已批准。')
|
||||
ElMessage.success(t('classroomReservation.approvedMessage'))
|
||||
await loadReview()
|
||||
} catch (error) {
|
||||
if (error === 'cancel' || error === 'close') return
|
||||
@@ -391,14 +391,14 @@ async function approveReservation(item: Reservation | Record<string, any>) {
|
||||
async function rejectReservation(item: Reservation | Record<string, any>) {
|
||||
try {
|
||||
const result = await ElMessageBox.prompt(
|
||||
'请填写驳回原因,申请人将在消息中心收到该意见。',
|
||||
'驳回教室借用',
|
||||
t('classroomReservation.rejectPrompt'),
|
||||
t('classroomReservation.rejectTitle'),
|
||||
{
|
||||
inputType: 'textarea',
|
||||
inputPlaceholder: '请输入具体原因',
|
||||
inputValidator: (value) => value.trim().length > 0 || '驳回原因不能为空',
|
||||
confirmButtonText: '确认驳回',
|
||||
cancelButtonText: '返回',
|
||||
inputPlaceholder: t('classroomReservation.reasonPlaceholder'),
|
||||
inputValidator: (value) => value.trim().length > 0 || t('classroomReservation.reasonRequired'),
|
||||
confirmButtonText: t('classroomReservation.confirmReject'),
|
||||
cancelButtonText: t('classroomReservation.back'),
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
@@ -416,12 +416,12 @@ async function rejectReservation(item: Reservation | Record<string, any>) {
|
||||
function periodText(item: Reservation | Record<string, any>) {
|
||||
const end = item.startPeriod + item.periodCount - 1
|
||||
return item.periodCount === 1
|
||||
? `第 ${item.startPeriod} 节`
|
||||
: `第 ${item.startPeriod}—${end} 节`
|
||||
? t('classroomReservation.singlePeriod', { start: item.startPeriod })
|
||||
: t('classroomReservation.periodRange', { start: item.startPeriod, end })
|
||||
}
|
||||
|
||||
function roomLabel(room: AvailableClassroom) {
|
||||
return `${room.campusName} · ${room.buildingName} · ${room.name}(${room.capacity} 人)`
|
||||
return t('classroomReservation.roomLabel', { campus: room.campusName, building: room.buildingName, room: room.name, capacity: room.capacity })
|
||||
}
|
||||
|
||||
function formatDateTime(value?: string) {
|
||||
@@ -441,12 +441,12 @@ onMounted(async () => {
|
||||
<section class="reservation-page">
|
||||
<header class="page-heading">
|
||||
<div>
|
||||
<p class="eyebrow">教学场地</p>
|
||||
<h2>教室借用与预约</h2>
|
||||
<p>选择正式课表之外的空闲时段提交申请,由申请人所在学院审核。</p>
|
||||
<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">
|
||||
审核学院:{{ applicant.collegeName }}
|
||||
{{ t('classroomReservation.reviewCollege', { college: applicant.collegeName }) }}
|
||||
</el-tag>
|
||||
</header>
|
||||
|
||||
@@ -463,8 +463,8 @@ onMounted(async () => {
|
||||
<template #header>
|
||||
<div class="card-title">
|
||||
<div>
|
||||
<h3>提交借用申请</h3>
|
||||
<p>系统会避让正式课程、已发布考试及已批准的教室预约。</p>
|
||||
<h3>{{ t('classroomReservation.applyTitle') }}</h3>
|
||||
<p>{{ t('classroomReservation.conflictHint') }}</p>
|
||||
</div>
|
||||
<span v-if="applicant">{{ applicant.displayName }} · {{ applicant.collegeName }}</span>
|
||||
</div>
|
||||
@@ -475,25 +475,25 @@ onMounted(async () => {
|
||||
<el-form-item :label="t('businessLabels.term')" required>
|
||||
<el-select
|
||||
v-model="form.academicTermId"
|
||||
placeholder="选择学期"
|
||||
:placeholder="t('classroomReservation.selectTerm')"
|
||||
@change="changeTerm"
|
||||
>
|
||||
<el-option
|
||||
v-for="term in terms"
|
||||
:key="term.id"
|
||||
:value="term.id"
|
||||
:label="`${term.name}${term.hasPublishedTimetable ? '' : '(课表未发布)'}`"
|
||||
:label="term.hasPublishedTimetable ? term.name : t('classroomReservation.unpublishedTerm', { term: term.name })"
|
||||
:disabled="!term.hasPublishedTimetable"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="预约日期" required>
|
||||
<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="选择日期"
|
||||
:placeholder="t('classroomReservation.selectDate')"
|
||||
:disabled-date="isDateDisabled"
|
||||
@change="invalidateAvailability"
|
||||
/>
|
||||
@@ -514,11 +514,11 @@ onMounted(async () => {
|
||||
v-for="count in availablePeriodCounts"
|
||||
:key="count"
|
||||
:value="count"
|
||||
:label="`${count} 节`"
|
||||
:label="t('classroomReservation.periodCount', { count })"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="预计人数" required>
|
||||
<el-form-item :label="t('classroomReservation.attendees')" required>
|
||||
<el-input-number
|
||||
v-model="form.attendeeCount"
|
||||
:min="1"
|
||||
@@ -546,7 +546,7 @@ onMounted(async () => {
|
||||
<el-select
|
||||
v-model="form.buildingId"
|
||||
clearable
|
||||
placeholder="全部教学楼"
|
||||
:placeholder="t('classroomReservation.allBuildings')"
|
||||
@change="invalidateAvailability"
|
||||
>
|
||||
<el-option
|
||||
@@ -557,13 +557,13 @@ onMounted(async () => {
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="可用教室" required>
|
||||
<el-form-item :label="t('classroomReservation.availableRooms')" required>
|
||||
<div class="room-picker">
|
||||
<el-select
|
||||
v-model="form.classroomId"
|
||||
filterable
|
||||
:disabled="!availabilityChecked"
|
||||
:placeholder="availabilityChecked ? '选择可用教室' : '请先查询可用教室'"
|
||||
:placeholder="availabilityChecked ? t('classroomReservation.chooseRoom') : t('classroomReservation.searchFirst')"
|
||||
>
|
||||
<el-option
|
||||
v-for="room in availableRooms"
|
||||
@@ -578,48 +578,48 @@ onMounted(async () => {
|
||||
plain
|
||||
@click="queryAvailability"
|
||||
>
|
||||
查询可用教室
|
||||
{{ t('classroomReservation.searchRooms') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="借用用途" required class="span-2">
|
||||
<el-form-item :label="t('classroomReservation.purpose')" required class="span-2">
|
||||
<el-input
|
||||
v-model="form.purpose"
|
||||
maxlength="200"
|
||||
show-word-limit
|
||||
placeholder="例如:学院学术讲座、班级主题活动"
|
||||
:placeholder="t('classroomReservation.purposePlaceholder')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('businessLabels.phone')" required>
|
||||
<el-input
|
||||
v-model="form.contactPhone"
|
||||
maxlength="30"
|
||||
placeholder="便于审核人联系"
|
||||
:placeholder="t('classroomReservation.contactHint')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="补充说明" class="span-2">
|
||||
<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="可填写设备、布置或其他需求"
|
||||
:placeholder="t('classroomReservation.notesPlaceholder')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="submit-row">
|
||||
<p v-if="availabilityChecked">
|
||||
已找到 <b>{{ availableRooms.length }}</b> 间符合条件的空闲教室
|
||||
{{ t('classroomReservation.roomsFound', { count: availableRooms.length }) }}
|
||||
</p>
|
||||
<span v-else>日期、节次、人数变化后需重新查询可用教室。</span>
|
||||
<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>
|
||||
@@ -627,10 +627,10 @@ onMounted(async () => {
|
||||
|
||||
<el-card class="records-card" shadow="never">
|
||||
<el-tabs v-model="activeTab" @tab-change="changeTab">
|
||||
<el-tab-pane label="我的申请" name="mine">
|
||||
<el-tab-pane :label="t('classroomReservation.mine')" name="mine">
|
||||
<div v-loading="loading">
|
||||
<el-table :data="mine" class="desktop-table">
|
||||
<el-table-column label="日期与节次" min-width="150">
|
||||
<el-table-column :label="t('classroomReservation.datePeriods')" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<b>{{ row.reservationDate }}</b>
|
||||
<small>{{ periodText(row) }}</small>
|
||||
@@ -639,10 +639,10 @@ onMounted(async () => {
|
||||
<el-table-column :label="t('businessLabels.classroom')" min-width="190">
|
||||
<template #default="{ row }">
|
||||
<b>{{ row.buildingName }} · {{ row.classroomName }}</b>
|
||||
<small>{{ row.campusName }} · {{ row.attendeeCount }} 人</small>
|
||||
<small>{{ t('classroomReservation.campusAttendees', { campus: row.campusName, count: row.attendeeCount }) }}</small>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="purpose" label="用途" min-width="180" show-overflow-tooltip />
|
||||
<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">
|
||||
@@ -661,7 +661,7 @@ onMounted(async () => {
|
||||
type="danger"
|
||||
@click="cancelReservation(row)"
|
||||
>
|
||||
取消
|
||||
{{ t('classroomReservation.cancel') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -678,7 +678,7 @@ onMounted(async () => {
|
||||
</el-tag>
|
||||
</header>
|
||||
<p>{{ item.purpose }}</p>
|
||||
<small>{{ item.attendeeCount }} 人 · {{ item.contactPhone }}</small>
|
||||
<small>{{ t('classroomReservation.attendeesPhone', { count: item.attendeeCount, phone: item.contactPhone }) }}</small>
|
||||
<blockquote v-if="item.reviewComment">{{ item.reviewComment }}</blockquote>
|
||||
<el-button
|
||||
v-if="['Submitted', 'Approved'].includes(item.status)"
|
||||
@@ -686,11 +686,11 @@ onMounted(async () => {
|
||||
plain
|
||||
@click="cancelReservation(item)"
|
||||
>
|
||||
取消预约
|
||||
{{ t('classroomReservation.cancelReservation') }}
|
||||
</el-button>
|
||||
</article>
|
||||
</div>
|
||||
<el-empty v-if="mine.length === 0" description="还没有教室借用申请" />
|
||||
<el-empty v-if="mine.length === 0" :description="t('classroomReservation.emptyMine')" />
|
||||
<el-pagination
|
||||
v-if="mineTotal > pageSize"
|
||||
v-model:current-page="minePage"
|
||||
@@ -702,11 +702,11 @@ onMounted(async () => {
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane v-if="isCollegeAdmin" label="本院审核" name="review">
|
||||
<el-tab-pane v-if="isCollegeAdmin" :label="t('classroomReservation.collegeReview')" name="review">
|
||||
<div class="review-toolbar">
|
||||
<div>
|
||||
<h3>{{ applicant?.collegeName || auth.user?.displayName }}审核队列</h3>
|
||||
<p>这里只显示申请人归属本学院的教室借用申请。</p>
|
||||
<h3>{{ t('classroomReservation.reviewQueue', { college: applicant?.collegeName || auth.user?.displayName }) }}</h3>
|
||||
<p>{{ t('classroomReservation.reviewHint') }}</p>
|
||||
</div>
|
||||
<el-select
|
||||
v-model="reviewStatus"
|
||||
@@ -722,25 +722,25 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div v-loading="loading">
|
||||
<el-table :data="reviewItems" class="desktop-table">
|
||||
<el-table-column label="申请人" min-width="140">
|
||||
<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="日期与教室" min-width="220">
|
||||
<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="用途与人数" min-width="220">
|
||||
<el-table-column :label="t('classroomReservation.purposeAttendees')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.purpose }}</span>
|
||||
<small>{{ row.attendeeCount }} 人 · {{ row.contactPhone }}</small>
|
||||
<small>{{ t('classroomReservation.attendeesPhone', { count: row.attendeeCount, phone: row.contactPhone }) }}</small>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提交时间" width="170">
|
||||
<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">
|
||||
@@ -753,7 +753,7 @@ onMounted(async () => {
|
||||
<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)">批准</el-button>
|
||||
<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>
|
||||
@@ -772,15 +772,15 @@ onMounted(async () => {
|
||||
</el-tag>
|
||||
</header>
|
||||
<p>{{ item.purpose }}</p>
|
||||
<small>{{ item.attendeeCount }} 人 · {{ item.contactPhone }}</small>
|
||||
<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)">批准</el-button>
|
||||
<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="当前筛选下没有申请" />
|
||||
<el-empty v-if="reviewItems.length === 0" :description="t('classroomReservation.emptyReview')" />
|
||||
<el-pagination
|
||||
v-if="reviewTotal > pageSize"
|
||||
v-model:current-page="reviewPage"
|
||||
|
||||
Reference in new issue
Block a user