Expand approval center and configure reviewer routing
This commit is contained in:
1 parent
cc1b60450f
commit
2d1a43fd39
14 files changed
+12632
-78
No files matched your search
@@ -3,7 +3,7 @@ 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 { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
Check,
|
||||
Clock,
|
||||
@@ -54,7 +54,10 @@ interface SubstitutionTarget {
|
||||
|
||||
const auth = useAuthStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const isManager = computed(() => auth.user?.roles.some(r => ['SuperAdmin', 'AcademicAdmin', 'CollegeAdmin'].includes(r)) ?? false)
|
||||
const isSuperAdmin = computed(() => auth.user?.roles.includes('SuperAdmin') ?? false)
|
||||
const isApprover = computed(() => auth.user?.roles.some(r => ['SuperAdmin', 'AcademicAdmin', 'CollegeAdmin', 'Counselor', 'Teacher', 'DormitoryAdmin', 'StudentAffairsAdmin', 'Leader'].includes(r)) ?? false)
|
||||
const isTeacher = computed(() => auth.user?.roles.includes('Teacher') && !isManager.value)
|
||||
const isStudent = computed(() => auth.user?.roles.includes('Student') && !isManager.value)
|
||||
|
||||
@@ -62,6 +65,9 @@ const pending = ref<any[]>([])
|
||||
const pendingPage = ref(1)
|
||||
const pendingTotal = ref(0)
|
||||
const pendingPageSize = 20
|
||||
const oldestPending = ref<any | null>(null)
|
||||
const oldestFirst = ref(false)
|
||||
const pendingCounts = ref<Record<string, number>>({})
|
||||
const targetApprovalType = computed(() => {
|
||||
const value = route.query.type
|
||||
return typeof value === 'string' ? value : undefined
|
||||
@@ -72,7 +78,7 @@ const targetApprovalId = computed(() => {
|
||||
})
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
const tab = ref(isManager.value ? 'pending' : 'mine')
|
||||
const tab = ref(isApprover.value ? 'pending' : 'mine')
|
||||
const dialog = ref(false)
|
||||
const dialogType = ref('')
|
||||
const courseKeyword = ref('')
|
||||
@@ -81,6 +87,9 @@ const substituteKeyword = ref('')
|
||||
const rejectDialog = ref(false)
|
||||
const rejectItem = ref<any>(null)
|
||||
const rejectComment = ref('')
|
||||
const workflowDialog = ref(false)
|
||||
const workflowSettings = ref<{ type: string; reviewerRole: string }[]>([])
|
||||
const workflowSaving = ref('')
|
||||
|
||||
const enrolledCourses = ref<CourseOption[]>([])
|
||||
const gradeRecords = ref<any[]>([])
|
||||
@@ -105,7 +114,7 @@ const dialogTitle = computed(() => ({
|
||||
substitution: t('approvalBatch.k3'),
|
||||
}[dialogType.value] ?? t('approvalBatch.k4')))
|
||||
|
||||
const actionableApprovalTypes = ['CourseExemption', 'DeferredExam', 'CourseSubstitution', 'CourseAdjustment']
|
||||
const actionableApprovalTypes = ['CourseExemption', 'DeferredExam', 'CourseSubstitution', 'CourseAdjustment', 'GradeModification']
|
||||
|
||||
const selectedCourse = computed(() =>
|
||||
enrolledCourses.value.find(course => course.teachingTaskId === form.teachingTaskId))
|
||||
@@ -186,20 +195,23 @@ const recordCount = computed(() =>
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
if (isManager.value) {
|
||||
if (targetApprovalType.value && targetApprovalId.value) {
|
||||
if (isApprover.value) {
|
||||
if (isManager.value && targetApprovalType.value && targetApprovalId.value) {
|
||||
const { data } = await http.get(
|
||||
`/approvals/pending/${targetApprovalType.value}/${targetApprovalId.value}`,
|
||||
)
|
||||
pending.value = [data]
|
||||
pendingTotal.value = 1
|
||||
pendingCounts.value = {}
|
||||
} else {
|
||||
const { data } = await http.get('/approvals/pending', {
|
||||
params: { page: pendingPage.value, pageSize: pendingPageSize },
|
||||
params: { page: pendingPage.value, pageSize: pendingPageSize, oldestFirst: oldestFirst.value },
|
||||
})
|
||||
pending.value = data.items
|
||||
pendingTotal.value = data.total
|
||||
pendingCounts.value = data.counts ?? {}
|
||||
}
|
||||
oldestPending.value = oldestFirst.value && pendingPage.value === 1 && !targetApprovalId.value ? pending.value[0] ?? null : null
|
||||
if (!pending.value.length && pendingPage.value > 1) {
|
||||
pendingPage.value--
|
||||
return await load()
|
||||
@@ -303,8 +315,9 @@ async function approveItem(item: any) {
|
||||
try {
|
||||
const ep = approvalEndpoint(item.type)
|
||||
if (ep) {
|
||||
await http.post(`${ep}/${item.id}/approve`)
|
||||
await http.post(`${ep}/${item.id}/${item.type === 'GradeModification' && item.stage === 'college' ? 'college-approve' : 'approve'}`)
|
||||
ElMessage.success(t('approvalBatch.k11'))
|
||||
if (targetApprovalId.value) await router.replace({ path: '/approvals', query: { tab: 'pending' } })
|
||||
await load()
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -312,6 +325,22 @@ async function approveItem(item: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function openWorkflowSettings() {
|
||||
try {
|
||||
workflowSettings.value = (await http.get('/approvals/workflow-settings')).data
|
||||
workflowDialog.value = true
|
||||
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
|
||||
}
|
||||
|
||||
async function saveWorkflowSetting(setting: { type: string; reviewerRole: string }) {
|
||||
workflowSaving.value = setting.type
|
||||
try {
|
||||
await http.put(`/approvals/workflow-settings/${setting.type}`, { reviewerRole: setting.reviewerRole })
|
||||
ElMessage.success(t('approvalCenterExtra.settingsSaved'))
|
||||
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
|
||||
finally { workflowSaving.value = '' }
|
||||
}
|
||||
|
||||
function openReject(item: any) {
|
||||
rejectItem.value = item
|
||||
rejectComment.value = ''
|
||||
@@ -326,6 +355,7 @@ async function rejectSubmit() {
|
||||
await http.post(`${ep}/${rejectItem.value.id}/reject`, { comment: rejectComment.value })
|
||||
rejectDialog.value = false
|
||||
ElMessage.success(t('statusChanges.states.Rejected'))
|
||||
if (targetApprovalId.value) await router.replace({ path: '/approvals', query: { tab: 'pending' } })
|
||||
await load()
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -335,6 +365,7 @@ async function rejectSubmit() {
|
||||
|
||||
function approvalEndpoint(type: string) {
|
||||
if (type === 'CourseAdjustment') return '/course-adjustments'
|
||||
if (type === 'GradeModification') return '/approvals/grade-modifications'
|
||||
const segment = type === 'CourseExemption' ? 'exemptions'
|
||||
: type === 'DeferredExam' ? 'deferred'
|
||||
: type === 'CourseSubstitution' ? 'substitutions' : ''
|
||||
@@ -346,6 +377,13 @@ function approvalLabel(item: any) {
|
||||
CourseExemption: 'k69', DeferredExam: 'k70', GradeModification: 'k71',
|
||||
CourseSubstitution: 'k72', StudentStatusChange: 'k73', GradeSheet: 'k74', AttendanceAppeal: 'k75',
|
||||
}
|
||||
if (item.type === 'TeacherCourseApplication') return t('approvalCenterExtra.teacherCourse')
|
||||
if (item.type === 'ClassroomReservation') return t('approvalCenterExtra.classroom')
|
||||
if (item.type === 'GradeAppeal') return t('approvalCenterExtra.gradeAppeal')
|
||||
if (item.type === 'TeachingImprovement') return t('approvalCenterExtra.teachingImprovement')
|
||||
if (item.type === 'GraduationClearance') return t('approvalCenterClearance')
|
||||
const extra: Record<string, string> = { GradeSubmissionBatch: 'gradeBatch', ExperimentGradeSheet: 'experimentGrade', CampusRegistration: 'campusRegistration', DormitoryApplication: 'dormitory', AssessmentDeclaration: 'assessmentDeclaration', AssessmentAppeal: 'assessmentAppeal' }
|
||||
if (extra[item.type]) return t(`approvalCenterExtra.${extra[item.type]}`)
|
||||
if (item.type === 'CourseAdjustment') {
|
||||
const adjustments: Record<string, string> = { '调课': 'k0', '停课': 'k1', '补课': 'k2', '代课': 'k3' }
|
||||
return adjustments[item.label] ? t(`adjustmentBatch.${adjustments[item.label]}`) : item.label
|
||||
@@ -353,6 +391,31 @@ function approvalLabel(item: any) {
|
||||
return types[item.type] ? t(`approvalBatch.${types[item.type]}`) : item.label
|
||||
}
|
||||
|
||||
function approvalCountLabel(type: string) {
|
||||
if (type === 'CourseAdjustment') return t('approvalCenterAdjustment')
|
||||
return approvalLabel({ type, label: type })
|
||||
}
|
||||
|
||||
function approvalRoute(type: string) {
|
||||
const routes: Record<string, string> = {
|
||||
StudentStatusChange: '/student-status-changes',
|
||||
GradeSheet: '/grades',
|
||||
AttendanceAppeal: '/teacher-attendance',
|
||||
TeacherCourseApplication: '/teaching-preferences',
|
||||
ClassroomReservation: '/classroom-reservations',
|
||||
GradeSubmissionBatch: '/grades',
|
||||
ExperimentGradeSheet: '/experiment-grades',
|
||||
CampusRegistration: '/campus-registrations',
|
||||
DormitoryApplication: '/dormitory-applications',
|
||||
AssessmentDeclaration: '/comprehensive-assessments',
|
||||
AssessmentAppeal: '/comprehensive-assessments',
|
||||
GradeAppeal: '/grades',
|
||||
TeachingImprovement: '/evaluations',
|
||||
GraduationClearance: '/graduation-clearance',
|
||||
}
|
||||
return routes[type]
|
||||
}
|
||||
|
||||
function statusText(status: string) {
|
||||
return status === 'Submitted' ? t('approvalBatch.k12') : status === 'Approved' ? t('approvalBatch.k11') : t('approvalBatch.k13')
|
||||
}
|
||||
@@ -380,9 +443,25 @@ onMounted(() => {
|
||||
<h2>{{ t('dashboard.admin.actions.approvals.label') }}</h2>
|
||||
<p>{{ isStudent ? t('approvalBatch.k17') : isTeacher ? t('approvalBatch.k18') : t('approvalBatch.k19') }}</p>
|
||||
</div>
|
||||
<el-button :icon="Refresh" @click="load">{{ t('businessLabels.refresh') }}</el-button>
|
||||
<div>
|
||||
<el-button v-if="isSuperAdmin" @click="openWorkflowSettings">{{ t('approvalCenterExtra.settings') }}</el-button>
|
||||
<el-button :icon="Refresh" @click="load">{{ t('businessLabels.refresh') }}</el-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog v-model="workflowDialog" :title="t('approvalCenterExtra.settings')" width="min(620px, 95vw)">
|
||||
<p>{{ t('approvalCenterExtra.settingsHint') }}</p>
|
||||
<div v-for="setting in workflowSettings" :key="setting.type" class="workflow-setting-row">
|
||||
<strong>{{ approvalLabel({ type: setting.type }) }}</strong>
|
||||
<el-select v-model="setting.reviewerRole">
|
||||
<el-option value="AnyManager" :label="t('approvalCenterExtra.anyManager')" />
|
||||
<el-option value="CollegeAdmin" :label="t('approvalCenterExtra.collegeReviewer')" />
|
||||
<el-option value="AcademicAdmin" :label="t('approvalCenterExtra.academicReviewer')" />
|
||||
</el-select>
|
||||
<el-button type="primary" :disabled="!!workflowSaving" :loading="workflowSaving === setting.type" @click="saveWorkflowSetting(setting)">{{ t('businessLabels.save') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<section v-if="isStudent" v-loading="loading" class="application-launcher">
|
||||
<button class="launch-card exemption" type="button" @click="openDialog('exemption')">
|
||||
<span class="launch-icon"><DocumentChecked /></span>
|
||||
@@ -438,30 +517,38 @@ onMounted(() => {
|
||||
<el-segmented
|
||||
v-model="tab"
|
||||
:options="[
|
||||
...(isManager ? [{ label: t('approvalBatch.k80', { count: pendingTotal }), value: 'pending' }] : []),
|
||||
...(isApprover ? [{ label: t('approvalBatch.k80', { count: pendingTotal }), value: 'pending' }] : []),
|
||||
{ label: isStudent ? t('approvalBatch.k82', { count: recordCount }) : t('approvalBatch.k81'), value: 'mine' },
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<section v-if="tab === 'pending'" v-loading="loading" class="appr-list">
|
||||
<article v-for="item in pending" :key="`${item.type}-${item.id}`" class="appr-card">
|
||||
<div class="approval-monitor">
|
||||
<span>{{ t('approvalCenterExtra.pendingTotal', { count: pendingTotal }) }}</span>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<article v-for="item in pending" :key="`${item.type}-${item.id}-${item.secondaryId ?? ''}`" class="appr-card">
|
||||
<el-tag size="small" :type="item.type === 'AttendanceAppeal' ? 'warning' : 'primary'">{{ approvalLabel(item) }}</el-tag>
|
||||
<div class="appr-body">
|
||||
<b>{{ item.title }}</b>
|
||||
<p>{{ item.desc }}</p>
|
||||
<small>{{ item.college }} · {{ new Date(item.time).toLocaleString(getDisplayLocale()) }}</small>
|
||||
<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>
|
||||
</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>
|
||||
<div v-else class="appr-actions">
|
||||
<div v-else-if="approvalRoute(item.type)" class="appr-actions">
|
||||
<el-button
|
||||
size="small"
|
||||
text
|
||||
type="primary"
|
||||
@click="$router.push(item.type==='StudentStatusChange'?'/student-status-changes':item.type==='GradeSheet'?'/grades':'/teacher-attendance')"
|
||||
@click="$router.push({ path: approvalRoute(item.type), query: item.type === 'ClassroomReservation' ? { tab: 'review' } : {} })"
|
||||
>
|
||||
{{ t('approvalBatch.k76') }}
|
||||
</el-button>
|
||||
@@ -746,6 +833,10 @@ onMounted(() => {
|
||||
|
||||
.approval-tabs { display: flex; justify-content: space-between; gap: 12px; }
|
||||
.appr-list { display: grid; gap: 8px; }
|
||||
.approval-monitor { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 16px; color: #475467; background: #f3f6fb; border-radius: 10px; font-size: 13px; }
|
||||
.approval-monitor .el-switch { margin-left: auto; }
|
||||
.approval-monitor-counts { display: flex; flex-basis: 100%; flex-wrap: wrap; gap: 6px; }
|
||||
.workflow-setting-row { display: grid; grid-template-columns: 1fr 1.5fr auto; gap: 12px; align-items: center; margin: 12px 0; }
|
||||
.appr-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: #fff; border: 1px solid #e4e7ed; border-radius: 10px; }
|
||||
.appr-card.compact { align-items: flex-start; padding: 13px; }
|
||||
.appr-body { flex: 1; min-width: 0; }
|
||||
|
||||
@@ -3,6 +3,7 @@ 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'
|
||||
@@ -96,7 +97,8 @@ const auth = useAuthStore()
|
||||
const isCollegeAdmin = computed(() =>
|
||||
auth.user?.roles.includes('CollegeAdmin') ?? false,
|
||||
)
|
||||
const activeTab = ref<'mine' | 'review'>('mine')
|
||||
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)
|
||||
@@ -430,7 +432,7 @@ function formatDateTime(value?: string) {
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await Promise.all([loadOptions(), loadMine()])
|
||||
await Promise.all([loadOptions(), loadMine(), ...(activeTab.value === 'review' ? [loadReview()] : [])])
|
||||
} catch (error) {
|
||||
ElMessage.error(apiErrorMessage(error))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user