Enable direct review and filter approval queues
This commit is contained in:
1 parent
2d1a43fd39
commit
88ef93022d
6 files changed
+169
-26
No files matched your search
@@ -67,6 +67,7 @@ const pendingTotal = ref(0)
|
||||
const pendingPageSize = 20
|
||||
const oldestPending = ref<any | null>(null)
|
||||
const oldestFirst = ref(false)
|
||||
const selectedPendingType = ref('')
|
||||
const pendingCounts = ref<Record<string, number>>({})
|
||||
const targetApprovalType = computed(() => {
|
||||
const value = route.query.type
|
||||
@@ -87,6 +88,7 @@ const substituteKeyword = ref('')
|
||||
const rejectDialog = ref(false)
|
||||
const rejectItem = ref<any>(null)
|
||||
const rejectComment = ref('')
|
||||
const reviewInProgress = ref(false)
|
||||
const workflowDialog = ref(false)
|
||||
const workflowSettings = ref<{ type: string; reviewerRole: string }[]>([])
|
||||
const workflowSaving = ref('')
|
||||
@@ -114,7 +116,8 @@ const dialogTitle = computed(() => ({
|
||||
substitution: t('approvalBatch.k3'),
|
||||
}[dialogType.value] ?? t('approvalBatch.k4')))
|
||||
|
||||
const actionableApprovalTypes = ['CourseExemption', 'DeferredExam', 'CourseSubstitution', 'CourseAdjustment', 'GradeModification']
|
||||
const actionableApprovalTypes = ['CourseExemption', 'DeferredExam', 'CourseSubstitution', 'CourseAdjustment', 'GradeModification', 'StudentStatusChange', 'TeacherCourseApplication', 'ClassroomReservation', 'CampusRegistration', 'AttendanceAppeal']
|
||||
const isActionable = (item: any) => actionableApprovalTypes.includes(item.type) || (item.type === 'DormitoryApplication' && item.stage === 'counselor')
|
||||
|
||||
const selectedCourse = computed(() =>
|
||||
enrolledCourses.value.find(course => course.teachingTaskId === form.teachingTaskId))
|
||||
@@ -205,7 +208,7 @@ async function load() {
|
||||
pendingCounts.value = {}
|
||||
} else {
|
||||
const { data } = await http.get('/approvals/pending', {
|
||||
params: { page: pendingPage.value, pageSize: pendingPageSize, oldestFirst: oldestFirst.value },
|
||||
params: { page: pendingPage.value, pageSize: pendingPageSize, oldestFirst: oldestFirst.value, type: selectedPendingType.value || undefined },
|
||||
})
|
||||
pending.value = data.items
|
||||
pendingTotal.value = data.total
|
||||
@@ -312,16 +315,18 @@ async function submitForm() {
|
||||
}
|
||||
|
||||
async function approveItem(item: any) {
|
||||
if (reviewInProgress.value) return
|
||||
reviewInProgress.value = true
|
||||
try {
|
||||
const ep = approvalEndpoint(item.type)
|
||||
if (ep) {
|
||||
await http.post(`${ep}/${item.id}/${item.type === 'GradeModification' && item.stage === 'college' ? 'college-approve' : 'approve'}`)
|
||||
if (await submitReview(item, true, '')) {
|
||||
ElMessage.success(t('approvalBatch.k11'))
|
||||
if (targetApprovalId.value) await router.replace({ path: '/approvals', query: { tab: 'pending' } })
|
||||
await load()
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.error(apiErrorMessage(e))
|
||||
} finally {
|
||||
reviewInProgress.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,11 +353,14 @@ function openReject(item: any) {
|
||||
}
|
||||
|
||||
async function rejectSubmit() {
|
||||
if (!rejectItem.value) return
|
||||
if (!rejectItem.value || reviewInProgress.value) return
|
||||
if (!rejectComment.value.trim()) {
|
||||
ElMessage.warning(t('approvalBatch.k68'))
|
||||
return
|
||||
}
|
||||
reviewInProgress.value = true
|
||||
try {
|
||||
const ep = approvalEndpoint(rejectItem.value.type)
|
||||
if (ep) {
|
||||
await http.post(`${ep}/${rejectItem.value.id}/reject`, { comment: rejectComment.value })
|
||||
if (await submitReview(rejectItem.value, false, rejectComment.value.trim())) {
|
||||
rejectDialog.value = false
|
||||
ElMessage.success(t('statusChanges.states.Rejected'))
|
||||
if (targetApprovalId.value) await router.replace({ path: '/approvals', query: { tab: 'pending' } })
|
||||
@@ -360,9 +368,33 @@ async function rejectSubmit() {
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.error(apiErrorMessage(e))
|
||||
} finally {
|
||||
reviewInProgress.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReview(item: any, approved: boolean, comment: string) {
|
||||
if (item.type === 'StudentStatusChange')
|
||||
await http.post(`/student-status-changes/${item.id}/review`, { approved, comment: comment || null })
|
||||
else if (item.type === 'TeacherCourseApplication')
|
||||
await http.post(`/teacher-course-applications/${item.id}/review`, { status: approved ? 'Approved' : 'Rejected', reviewComment: comment || null })
|
||||
else if (item.type === 'ClassroomReservation')
|
||||
await http.post(`/classroom-reservations/${item.id}/${approved ? 'approve' : 'reject'}`, { comment: comment || null })
|
||||
else if (item.type === 'CampusRegistration')
|
||||
await http.post(`/campus-registrations/applications/${item.id}/review`, { approved, comment: comment || null })
|
||||
else if (item.type === 'AttendanceAppeal' && item.secondaryId)
|
||||
await http.post(`/attendance/appeals/${item.secondaryId}/${item.id}/review`, { approve: approved, comment: comment || null })
|
||||
else if (item.type === 'DormitoryApplication' && item.stage === 'counselor')
|
||||
await http.post(`/dormitory-services/applications/${item.id}/counselor-review`, { approved, comment: comment || null })
|
||||
else {
|
||||
const ep = approvalEndpoint(item.type)
|
||||
if (!ep) return false
|
||||
const action = approved ? (item.type === 'GradeModification' && item.stage === 'college' ? 'college-approve' : 'approve') : 'reject'
|
||||
await http.post(`${ep}/${item.id}/${action}`, approved ? undefined : { comment })
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function approvalEndpoint(type: string) {
|
||||
if (type === 'CourseAdjustment') return '/course-adjustments'
|
||||
if (type === 'GradeModification') return '/approvals/grade-modifications'
|
||||
@@ -396,6 +428,18 @@ function approvalCountLabel(type: string) {
|
||||
return approvalLabel({ type, label: type })
|
||||
}
|
||||
|
||||
function selectPendingType(type: string) {
|
||||
selectedPendingType.value = type
|
||||
pendingPage.value = 1
|
||||
void load()
|
||||
}
|
||||
|
||||
function approvalStageLabel(stage: string) {
|
||||
if (stage === 'counselor') return t('approvalCenterCounselorStage')
|
||||
if (stage === 'dormitory') return t('approvalCenterDormitoryStage')
|
||||
return stage === 'college' ? t('approvalCenterExtra.collegeStage') : t('approvalCenterExtra.finalStage')
|
||||
}
|
||||
|
||||
function approvalRoute(type: string) {
|
||||
const routes: Record<string, string> = {
|
||||
StudentStatusChange: '/student-status-changes',
|
||||
@@ -529,7 +573,8 @@ onMounted(() => {
|
||||
<span v-if="oldestPending">{{ t('approvalCenterExtra.oldest', { title: oldestPending.title, time: new Date(oldestPending.time).toLocaleString(getDisplayLocale()) }) }}</span>
|
||||
<el-switch v-model="oldestFirst" :active-text="t('approvalCenterExtra.oldestFirst')" @change="pendingPage = 1; load()" />
|
||||
<div v-if="Object.keys(pendingCounts).length" class="approval-monitor-counts">
|
||||
<el-tag v-for="(count, type) in pendingCounts" :key="type" type="info" effect="plain">{{ approvalCountLabel(String(type)) }} · {{ count }}</el-tag>
|
||||
<el-button size="small" :type="selectedPendingType ? 'default' : 'primary'" @click="selectPendingType('')">{{ t('approvalCenterAllTypes') }}</el-button>
|
||||
<el-button v-for="(count, type) in pendingCounts" :key="type" size="small" :type="selectedPendingType === type ? 'primary' : 'default'" @click="selectPendingType(String(type))">{{ approvalCountLabel(String(type)) }} · {{ count }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<article v-for="item in pending" :key="`${item.type}-${item.id}-${item.secondaryId ?? ''}`" class="appr-card">
|
||||
@@ -537,11 +582,12 @@ onMounted(() => {
|
||||
<div class="appr-body">
|
||||
<b>{{ item.title }}</b>
|
||||
<p>{{ item.desc }}</p>
|
||||
<small>{{ item.college }} · {{ new Date(item.time).toLocaleString(getDisplayLocale()) }}<template v-if="item.stage"> · {{ item.stage === 'college' ? t('approvalCenterExtra.collegeStage') : t('approvalCenterExtra.finalStage') }}</template></small>
|
||||
<small>{{ item.college }} · {{ new Date(item.time).toLocaleString(getDisplayLocale()) }}<template v-if="item.stage"> · {{ approvalStageLabel(item.stage) }}</template></small>
|
||||
</div>
|
||||
<div v-if="actionableApprovalTypes.includes(item.type)" class="appr-actions">
|
||||
<el-button size="small" type="danger" plain :icon="Close" @click="openReject(item)">{{ t('businessLabels.reject') }}</el-button>
|
||||
<el-button size="small" type="success" :icon="Check" @click="approveItem(item)">{{ t('businessLabels.approve') }}</el-button>
|
||||
<div v-if="isActionable(item)" class="appr-actions">
|
||||
<el-button v-if="approvalRoute(item.type)" size="small" text type="primary" @click="$router.push({ path: approvalRoute(item.type), query: item.type === 'ClassroomReservation' ? { tab: 'review' } : {} })">{{ t('approvalBatch.k76') }}</el-button>
|
||||
<el-button size="small" type="danger" plain :disabled="reviewInProgress" :icon="Close" @click="openReject(item)">{{ t('businessLabels.reject') }}</el-button>
|
||||
<el-button size="small" type="success" :disabled="reviewInProgress" :icon="Check" @click="approveItem(item)">{{ t('businessLabels.approve') }}</el-button>
|
||||
</div>
|
||||
<div v-else-if="approvalRoute(item.type)" class="appr-actions">
|
||||
<el-button
|
||||
@@ -757,10 +803,10 @@ onMounted(() => {
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="rejectDialog" :title="t('statusChanges.rejectTitle')" width="min(460px, calc(100vw - 24px))">
|
||||
<el-input v-model="rejectComment" type="textarea" :rows="3" maxlength="500" show-word-limit :placeholder="t('approvalBatch.k68')" />
|
||||
<el-input v-model="rejectComment" type="textarea" :rows="3" :maxlength="rejectItem?.type === 'AttendanceAppeal' ? 300 : 500" show-word-limit :placeholder="t('approvalBatch.k68')" />
|
||||
<template #footer>
|
||||
<el-button @click="rejectDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
||||
<el-button type="danger" @click="rejectSubmit">{{ t('statusChanges.confirmReject') }}</el-button>
|
||||
<el-button type="danger" :loading="reviewInProgress" @click="rejectSubmit">{{ t('statusChanges.confirmReject') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user