Require approval for student profile changes
This commit is contained in:
1 parent
a0d56561c5
commit
6c2cefd348
15 files changed
+13599
-25
No files matched your search
Vendored
+1
@@ -84,6 +84,7 @@ declare module 'vue' {
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
SiteFooter: typeof import('./components/SiteFooter.vue')['default']
|
||||
SmartLaunchScreen: typeof import('./components/SmartLaunchScreen.vue')['default']
|
||||
StudentIdentityChangePanel: typeof import('./components/StudentIdentityChangePanel.vue')['default']
|
||||
StudentLeavePanel: typeof import('./components/StudentLeavePanel.vue')['default']
|
||||
VacantBedPicker: typeof import('./components/VacantBedPicker.vue')['default']
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
|
||||
const props = defineProps<{ reviewer?: boolean }>()
|
||||
const { locale } = useI18n()
|
||||
const rows = ref<any[]>([])
|
||||
const busy = ref(false)
|
||||
const text = (zh: string, en: string) => locale.value.startsWith('zh') ? zh : en
|
||||
const labels: Record<string, [string, string]> = {
|
||||
Gender: ['性别', 'Gender'], DateOfBirth: ['出生日期', 'Date of birth'], IdCardNumber: ['身份证号', 'ID number'],
|
||||
Nationality: ['国籍', 'Nationality'], Ethnicity: ['民族', 'Ethnicity'], PoliticalStatus: ['政治面貌', 'Political status'], NativePlace: ['籍贯', 'Native place'],
|
||||
SpecialTags: ['特殊标记', 'Special tags'], SpecialNeeds: ['特殊需求说明', 'Special needs'],
|
||||
}
|
||||
const status = (s: string) => ({ Submitted: text('待审核', 'Pending'), Approved: text('已通过', 'Approved'), Rejected: text('已驳回', 'Rejected') } as Record<string, string>)[s] ?? s
|
||||
const value = (s: string | null) => ({ Male: text('男', 'Male'), Female: text('女', 'Female'), Unknown: text('未知', 'Unknown') } as Record<string, string>)[s ?? ''] ?? (s || '—')
|
||||
async function load() {
|
||||
try { rows.value = (await http.get(`/student-identity-changes/${props.reviewer ? 'pending' : 'mine'}`)).data }
|
||||
catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
||||
}
|
||||
async function review(row: any, approved: boolean) {
|
||||
try {
|
||||
const result = await ElMessageBox.prompt(text(approved ? '可填写审核意见' : '请填写驳回原因', approved ? 'Optional review comment' : 'Enter a rejection reason'), text(approved ? '通过申请' : '驳回申请', approved ? 'Approve' : 'Reject'), {
|
||||
inputType: 'textarea', inputValidator: (v: string) => approved || !!v?.trim() || text('请填写驳回原因', 'A reason is required'),
|
||||
})
|
||||
busy.value = true
|
||||
await http.post(`/student-identity-changes/${row.id}/review`, { approved, comment: result.value || null })
|
||||
ElMessage.success(text('审核完成', 'Review completed'))
|
||||
await load()
|
||||
} catch (error) { if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error)) }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
onMounted(load)
|
||||
defineExpose({ load })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="identity-changes surface-card">
|
||||
<h3>{{ text(reviewer ? '个人信息修改待审核' : '个人信息修改审批记录', reviewer ? 'Profile changes awaiting review' : 'Profile change review history') }}</h3>
|
||||
<p v-if="reviewer">{{ text('仅显示权限范围内最多 200 条待审申请,处理后可继续查看。', 'Shows up to 200 pending requests within your scope.') }}</p>
|
||||
<p v-if="!rows.length">{{ text('暂无记录', 'No records') }}</p>
|
||||
<article v-for="row in rows" :key="row.id" class="identity-change">
|
||||
<b v-if="reviewer">{{ row.studentName }} · {{ row.studentNumber }} · {{ row.className }}</b>
|
||||
<el-tag v-else>{{ status(row.status) }}</el-tag>
|
||||
<small> {{ new Date(row.createdAt + (/[zZ]|[+-]\d\d:\d\d$/.test(row.createdAt) ? '' : 'Z')).toLocaleString() }}</small>
|
||||
<div v-for="change in row.changes" :key="change.field">{{ labels[change.field]?.[locale.startsWith('zh') ? 0 : 1] ?? change.field }}: {{ value(change.oldValue) }} → {{ value(change.newValue) }}</div>
|
||||
<p v-if="row.reviewComment">{{ text('审核意见', 'Review comment') }}: {{ row.reviewComment }}</p>
|
||||
<div v-if="reviewer"><el-button type="success" :disabled="busy" @click="review(row, true)">{{ text('通过', 'Approve') }}</el-button><el-button type="danger" plain :disabled="busy" @click="review(row, false)">{{ text('驳回', 'Reject') }}</el-button></div>
|
||||
</article>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.identity-changes { padding: 20px; }
|
||||
.identity-change { border-top: 1px solid var(--line); padding: 14px 0; line-height: 1.9; overflow-wrap: anywhere; }
|
||||
.identity-change small { color: var(--muted); }
|
||||
</style>
|
||||
@@ -1484,8 +1484,10 @@ export default {
|
||||
refresh: "Refresh",
|
||||
edit: "Edit profile",
|
||||
cancel: "Cancel",
|
||||
save: "Save directly",
|
||||
saved: "Profile saved. No approval is required.",
|
||||
save: "Save",
|
||||
saved: "Profile saved.",
|
||||
approvalSubmitted: "Everyday details were saved. Changes requiring approval have been submitted and take effect when approved.",
|
||||
specialReviewHint: "Changes to special tags and special needs require approval. Emergency contacts and biographies can be saved directly.",
|
||||
visibilityNotice:
|
||||
"Your phone number, email, WeChat, emergency contact, special tags, and notes are visible to your instructors and included in class-roster exports.",
|
||||
studentNumber: "Student number",
|
||||
@@ -1505,7 +1507,7 @@ export default {
|
||||
unset: "Not set",
|
||||
identity: "Identity and background",
|
||||
identityHint:
|
||||
"Common identity details other than student number and name can be maintained directly.",
|
||||
"Changes to gender, date of birth, ID number, nationality, ethnicity, political status and native place require approval.",
|
||||
englishName: "English name",
|
||||
gender: "Gender",
|
||||
birthDate: "Date of birth",
|
||||
|
||||
Loaded 3 of 15 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user