Route student record changes through auditable workflows
This commit is contained in:
1 parent
d513f001b7
commit
db7b137148
15 files changed
+12444
-27
No files matched your search
@@ -656,7 +656,7 @@ watch(active, async () => {
|
||||
<el-form-item :label="t('businessLabels.name')" required><el-input v-model="form.name" /></el-form-item>
|
||||
</div>
|
||||
<el-form-item :label="t('businessLabels.administrativeClass')" required>
|
||||
<el-select v-model="form.administrativeClassId" filterable>
|
||||
<el-select v-model="form.administrativeClassId" filterable :disabled="Boolean(editingId)">
|
||||
<el-option
|
||||
v-for="item in formClasses"
|
||||
:key="item.id"
|
||||
@@ -676,11 +676,12 @@ watch(active, async () => {
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('personnel.studentStatus')">
|
||||
<el-select v-model="form.status">
|
||||
<el-select v-model="form.status" :disabled="Boolean(editingId)">
|
||||
<el-option v-for="(label, value) in studentStatusLabels" :key="value" :label="label" :value="value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-alert v-if="editingId" :title="t('statusChangeImpact.registryGuard')" type="info" :closable="false" show-icon />
|
||||
<el-divider content-position="left">{{ t('studentProfile.dormitory') }}</el-divider>
|
||||
<div v-if="form.dormitoryBuildingName" class="form-grid">
|
||||
<el-form-item :label="t('personnel.dormRoom')"><el-input :model-value="`${form.dormitoryBuildingName} · ${form.dormitoryRoomNumber}`" disabled /></el-form-item>
|
||||
|
||||
@@ -16,8 +16,21 @@ type ChangeState =
|
||||
const auth = useAuthStore()
|
||||
const { locale, t } = useI18n()
|
||||
const isStudent = computed(() => auth.user?.roles.includes('Student') ?? false)
|
||||
const canApplyForStudent = computed(() => (auth.user?.roles ?? []).some(role => ['Counselor', 'CollegeAdmin', 'AcademicAdmin', 'SuperAdmin'].includes(role)))
|
||||
const canCorrect = computed(() => auth.user?.effectiveDataScope === 'All' && (auth.user.roles ?? []).some(role => ['AcademicAdmin', 'SuperAdmin'].includes(role)))
|
||||
const changes = ref<any[]>([])
|
||||
const options = ref<any | null>(null)
|
||||
const proxyOptions = ref<any | null>(null)
|
||||
const formOptions = computed(() => proxyApply.value ? proxyOptions.value : options.value)
|
||||
const proxyApply = ref(false)
|
||||
const proxyStudentId = ref('')
|
||||
const studentSearch = ref<any[]>([])
|
||||
const studentSearchLoading = ref(false)
|
||||
let studentSearchVersion = 0
|
||||
const correctionDialog = ref(false)
|
||||
const correctionStudentId = ref('')
|
||||
const correctionOptions = ref<any | null>(null)
|
||||
const correctionForm = reactive({ targetStatus: '', targetClassId: '', reason: '' })
|
||||
const loading = ref(false)
|
||||
const applyDialog = ref(false)
|
||||
const reviewDialog = ref(false)
|
||||
@@ -37,14 +50,14 @@ const actionableTotal = ref(0)
|
||||
const finishedTotal = ref(0)
|
||||
const pageSize = 20
|
||||
watch(() => applyForm.type, type => {
|
||||
applyForm.targetClassId = ['Demotion', 'ClassTransfer', 'MajorTransfer'].includes(type) ? '' : (options.value?.currentClassId ?? '')
|
||||
applyForm.targetClassId = ['Demotion', 'ClassTransfer', 'MajorTransfer'].includes(type) ? '' : (formOptions.value?.currentClassId ?? '')
|
||||
})
|
||||
const targetClasses = computed(() => classes.value.filter(item => {
|
||||
if (!item.isEnabled) return false
|
||||
if (applyForm.type === 'MajorTransfer') return item.majorId !== options.value?.majorId
|
||||
if (item.majorId !== options.value?.majorId) return false
|
||||
if (applyForm.type === 'Demotion') return item.grade > options.value?.currentGrade
|
||||
if (applyForm.type === 'ClassTransfer') return item.grade === options.value?.currentGrade && item.id !== options.value?.currentClassId
|
||||
if (applyForm.type === 'MajorTransfer') return item.majorId !== formOptions.value?.majorId
|
||||
if (item.majorId !== formOptions.value?.majorId) return false
|
||||
if (applyForm.type === 'Demotion') return item.grade > formOptions.value?.currentGrade
|
||||
if (applyForm.type === 'ClassTransfer') return item.grade === formOptions.value?.currentGrade && item.id !== formOptions.value?.currentClassId
|
||||
return true
|
||||
}))
|
||||
|
||||
@@ -121,16 +134,82 @@ async function load(resetPage = false) {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
function openApply() {
|
||||
applyForm.type = options.value?.types?.[0] ?? ''
|
||||
function openApply(proxy = false) {
|
||||
proxyApply.value = proxy
|
||||
proxyStudentId.value = ''
|
||||
proxyOptions.value = null
|
||||
studentSearch.value = []
|
||||
applyForm.type = formOptions.value?.types?.[0] ?? ''
|
||||
applyForm.reason = ''
|
||||
applyForm.affectedTermId = terms.value.find(x => x.isCurrent)?.id ?? ''
|
||||
applyForm.targetClassId = options.value?.currentClassId ?? ''
|
||||
applyForm.targetClassId = formOptions.value?.currentClassId ?? ''
|
||||
applyForm.serviceStartDate = ''
|
||||
applyForm.dischargeDate = ''
|
||||
applyDialog.value = true
|
||||
}
|
||||
async function searchStudents(keyword: string) {
|
||||
const version = ++studentSearchVersion
|
||||
if (keyword.trim().length < 2) { studentSearch.value = []; studentSearchLoading.value = false; return }
|
||||
studentSearchLoading.value = true
|
||||
try {
|
||||
const result = await http.get('/student-status-changes/students/search', { params: { keyword } })
|
||||
if (version === studentSearchVersion) studentSearch.value = result.data
|
||||
} catch (error) { if (version === studentSearchVersion) ElMessage.error(apiErrorMessage(error)) }
|
||||
finally { if (version === studentSearchVersion) studentSearchLoading.value = false }
|
||||
}
|
||||
async function selectProxyStudent(studentId: string) {
|
||||
proxyOptions.value = null
|
||||
applyForm.type = ''
|
||||
if (!studentId) return
|
||||
try {
|
||||
const result = await http.get(`/student-status-changes/students/${studentId}/options`)
|
||||
if (proxyStudentId.value !== studentId) return
|
||||
proxyOptions.value = result.data
|
||||
applyForm.type = proxyOptions.value?.types?.[0] ?? ''
|
||||
} catch (error) { if (proxyStudentId.value === studentId) ElMessage.error(apiErrorMessage(error)) }
|
||||
}
|
||||
function openCorrection() {
|
||||
correctionStudentId.value = ''
|
||||
correctionOptions.value = null
|
||||
correctionForm.targetStatus = ''
|
||||
correctionForm.targetClassId = ''
|
||||
correctionForm.reason = ''
|
||||
studentSearch.value = []
|
||||
correctionDialog.value = true
|
||||
}
|
||||
async function selectCorrectionStudent(studentId: string) {
|
||||
correctionOptions.value = null
|
||||
if (!studentId) return
|
||||
try {
|
||||
const result = await http.get(`/student-status-changes/students/${studentId}/options`)
|
||||
if (correctionStudentId.value !== studentId) return
|
||||
correctionOptions.value = result.data
|
||||
correctionForm.targetStatus = correctionOptions.value.status
|
||||
correctionForm.targetClassId = correctionOptions.value.currentClassId
|
||||
} catch (error) { if (correctionStudentId.value === studentId) ElMessage.error(apiErrorMessage(error)) }
|
||||
}
|
||||
async function submitCorrection() {
|
||||
if (!correctionStudentId.value || !correctionOptions.value || !correctionForm.targetClassId ||
|
||||
!correctionForm.targetStatus || correctionForm.reason.trim().length < 10) {
|
||||
ElMessage.warning(t('statusChangeImpact.correctionRequired'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
await http.post(`/student-status-changes/students/${correctionStudentId.value}/data-correction`, {
|
||||
expectedStatus: correctionOptions.value.status,
|
||||
expectedClassId: correctionOptions.value.currentClassId,
|
||||
...correctionForm,
|
||||
})
|
||||
correctionDialog.value = false
|
||||
ElMessage.success(t('statusChangeImpact.correctionSaved'))
|
||||
await load(true)
|
||||
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
||||
}
|
||||
async function submitApply() {
|
||||
if (proxyApply.value && (!proxyStudentId.value || !proxyOptions.value || proxyOptions.value.hasPending)) {
|
||||
ElMessage.warning(t('statusChangeImpact.proxyStudentRequired'))
|
||||
return
|
||||
}
|
||||
if (!applyForm.type || applyForm.reason.trim().length < 10) {
|
||||
ElMessage.warning(t('statusChanges.messages.invalidApplication'))
|
||||
return
|
||||
@@ -147,12 +226,13 @@ async function submitApply() {
|
||||
ElMessage.warning(t('statusChangeImpact.serviceDateRequired'))
|
||||
return
|
||||
}
|
||||
if (applyForm.type === 'Resumption' && options.value?.requiresDischargeDate && !applyForm.dischargeDate) {
|
||||
if (applyForm.type === 'Resumption' && formOptions.value?.requiresDischargeDate && !applyForm.dischargeDate) {
|
||||
ElMessage.warning(t('statusChangeImpact.dischargeDateRequired'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
await http.post('/student-status-changes', { ...applyForm, affectedTermId: applyForm.affectedTermId, targetClassId: ['Resumption', 'Demotion', 'ClassTransfer', 'MajorTransfer'].includes(applyForm.type) ? applyForm.targetClassId : null, serviceStartDate: applyForm.type === 'Enlistment' ? applyForm.serviceStartDate : null, dischargeDate: applyForm.type === 'Resumption' && applyForm.dischargeDate ? applyForm.dischargeDate : null })
|
||||
const path = proxyApply.value ? `/student-status-changes/students/${proxyStudentId.value}` : '/student-status-changes'
|
||||
await http.post(path, { ...applyForm, affectedTermId: applyForm.affectedTermId, targetClassId: ['Resumption', 'Demotion', 'ClassTransfer', 'MajorTransfer'].includes(applyForm.type) ? applyForm.targetClassId : null, serviceStartDate: applyForm.type === 'Enlistment' ? applyForm.serviceStartDate : null, dischargeDate: applyForm.type === 'Resumption' && applyForm.dischargeDate ? applyForm.dischargeDate : null })
|
||||
applyDialog.value = false
|
||||
ElMessage.success(t('statusChanges.messages.submitted'))
|
||||
await load(true)
|
||||
@@ -212,7 +292,7 @@ async function submitReview() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
if (isStudent.value) {
|
||||
if (isStudent.value || canApplyForStudent.value) {
|
||||
try {
|
||||
const [termResponse, classResponse] = await Promise.all([http.get('/base-data/terms'), http.get('/base-data/classes')])
|
||||
terms.value = termResponse.data
|
||||
@@ -236,8 +316,10 @@ onMounted(async () => {
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
:disabled="options?.hasPending || !options?.types?.length"
|
||||
@click="openApply"
|
||||
@click="openApply(false)"
|
||||
>{{ t('statusChanges.apply') }}</el-button><el-button v-else :icon="RefreshRight" @click="() => load()">{{ t('statusChanges.refresh') }}</el-button>
|
||||
<el-button v-if="canApplyForStudent" :icon="Plus" @click="openApply(true)">{{ t('statusChangeImpact.proxyApply') }}</el-button>
|
||||
<el-button v-if="canCorrect" @click="openCorrection">{{ t('statusChangeImpact.correctionTitle') }}</el-button>
|
||||
</section>
|
||||
|
||||
<section v-if="isStudent && options" class="status-identity">
|
||||
@@ -275,6 +357,7 @@ onMounted(async () => {
|
||||
<p v-if="change.targetClassName">{{ t('statusChangeImpact.classTransition') }}: {{ change.originalClassName }} → {{ change.targetClassName }}</p>
|
||||
<p v-if="change.serviceStartDate">{{ t('statusChangeImpact.serviceDate') }}: {{ change.serviceStartDate }}</p>
|
||||
<p v-if="change.dischargeDate">{{ t('statusChangeImpact.dischargeDate') }}: {{ change.dischargeDate }}</p>
|
||||
<p v-if="change.submittedByUserId && change.submittedByUserId !== change.studentUserId">{{ t('statusChangeImpact.proxySubmitted') }} · {{ change.submittedByName || change.submittedByUserId }}</p>
|
||||
<p v-if="change.type === 'MajorTransfer' && change.originalCollegeId !== change.targetCollegeId">{{ t(change.receivingCollegeReviewedAt ? 'statusChangeImpact.receivingReviewed' : 'statusChangeImpact.receivingPending') }}<span v-if="change.receivingCollegeReviewComment"> · {{ change.receivingCollegeReviewComment }}</span></p>
|
||||
</div>
|
||||
|
||||
@@ -318,9 +401,15 @@ onMounted(async () => {
|
||||
|
||||
<el-dialog v-model="applyDialog" :title="t('statusChanges.applyTitle')" width="620px">
|
||||
<el-form label-position="top">
|
||||
<el-form-item v-if="proxyApply" :label="t('statusChangeImpact.proxyStudent')" required>
|
||||
<el-select v-model="proxyStudentId" filterable remote clearable :remote-method="searchStudents" :loading="studentSearchLoading" :placeholder="t('statusChangeImpact.proxyStudentHint')" style="width: 100%" @change="selectProxyStudent">
|
||||
<el-option v-for="item in studentSearch" :key="item.id" :value="item.id" :label="`${item.studentNumber} · ${item.name} · ${item.className}`" />
|
||||
</el-select>
|
||||
<small v-if="proxyOptions?.hasPending">{{ t('statusChanges.pendingHint') }}</small>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('statusChanges.type')">
|
||||
<el-radio-group v-model="applyForm.type">
|
||||
<el-radio-button v-for="type in options?.types" :key="type" :value="type">{{ typeLabel(type) }}</el-radio-button>
|
||||
<el-radio-button v-for="type in formOptions?.types" :key="type" :value="type">{{ typeLabel(type) }}</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('statusChanges.reason')"><el-input v-model="applyForm.reason" type="textarea" :rows="6" maxlength="1000" show-word-limit :placeholder="t('statusChanges.reasonPlaceholder')" />
|
||||
@@ -340,7 +429,7 @@ onMounted(async () => {
|
||||
<el-form-item v-if="applyForm.type === 'Enlistment'" :label="t('statusChangeImpact.serviceDate')">
|
||||
<el-date-picker v-model="applyForm.serviceStartDate" type="date" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="applyForm.type === 'Resumption' && options?.requiresDischargeDate" :label="t('statusChangeImpact.dischargeDate')">
|
||||
<el-form-item v-if="applyForm.type === 'Resumption' && formOptions?.requiresDischargeDate" :label="t('statusChangeImpact.dischargeDate')">
|
||||
<el-date-picker v-model="applyForm.dischargeDate" type="date" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -349,6 +438,28 @@ onMounted(async () => {
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="correctionDialog" :title="t('statusChangeImpact.correctionTitle')" width="620px">
|
||||
<el-alert :title="t('statusChangeImpact.correctionHint')" type="warning" :closable="false" show-icon />
|
||||
<el-form label-position="top">
|
||||
<el-form-item :label="t('statusChangeImpact.proxyStudent')" required>
|
||||
<el-select v-model="correctionStudentId" filterable remote clearable :remote-method="searchStudents" :loading="studentSearchLoading" :placeholder="t('statusChangeImpact.proxyStudentHint')" style="width: 100%" @change="selectCorrectionStudent">
|
||||
<el-option v-for="item in studentSearch" :key="item.id" :value="item.id" :label="`${item.studentNumber} · ${item.name} · ${item.className}`" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<template v-if="correctionOptions">
|
||||
<p>{{ t('statusChangeImpact.correctionCurrent', { status: statusLabel(correctionOptions.status), className: classes.find(x => x.id === correctionOptions.currentClassId)?.name ?? '—' }) }}</p>
|
||||
<el-form-item :label="t('statusChangeImpact.correctionStatus')">
|
||||
<el-select v-model="correctionForm.targetStatus"><el-option v-for="status in ['Active', 'Suspended', 'Retained', 'Graduated', 'Withdrawn']" :key="status" :value="status" :label="statusLabel(status)" /></el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('statusChangeImpact.targetClass')">
|
||||
<el-select v-model="correctionForm.targetClassId" filterable style="width: 100%"><el-option v-for="item in classes.filter(x => x.isEnabled)" :key="item.id" :value="item.id" :label="`${item.collegeName} · ${item.majorName} · ${item.name}`" /></el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('statusChangeImpact.correctionReason')" required><el-input v-model="correctionForm.reason" type="textarea" :rows="4" maxlength="1000" show-word-limit /></el-form-item>
|
||||
</template>
|
||||
</el-form>
|
||||
<template #footer><el-button @click="correctionDialog = false">{{ t('statusChanges.cancel') }}</el-button><el-button type="primary" @click="submitCorrection">{{ t('statusChangeImpact.correctionConfirm') }}</el-button></template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="reviewDialog" :title="t(receivingReview ? (reviewApproved ? 'statusChangeImpact.receivingApprove' : 'statusChangeImpact.receivingReject') : (reviewApproved ? 'statusChanges.approveTitle' : 'statusChanges.rejectTitle'))" width="600px">
|
||||
<div v-if="selected" class="review-target">
|
||||
<span>{{ selected.studentNumber }}</span>
|
||||
|
||||
Reference in new issue
Block a user