From 88ef93022d2dd3776367aa43094b77ba4ea9dd7d Mon Sep 17 00:00:00 2001 From: biss Date: Sat, 7 Nov 2026 20:22:47 +0800 Subject: [PATCH] Enable direct review and filter approval queues --- .../Controllers/ApprovalsController.cs | 23 +++--- .../ApprovalsControllerTests.cs | 35 +++++++++ web/e2e/approval-center.spec.ts | 53 +++++++++++++ web/src/i18n/messages/en-US.ts | 3 + web/src/i18n/messages/zh-CN.ts | 3 + web/src/views/ApprovalCenterView.vue | 78 +++++++++++++++---- 6 files changed, 169 insertions(+), 26 deletions(-) create mode 100644 web/e2e/approval-center.spec.ts diff --git a/src/Jiaowu.Api/Controllers/ApprovalsController.cs b/src/Jiaowu.Api/Controllers/ApprovalsController.cs index f1e7ba9..cf12ae6 100644 --- a/src/Jiaowu.Api/Controllers/ApprovalsController.cs +++ b/src/Jiaowu.Api/Controllers/ApprovalsController.cs @@ -61,7 +61,8 @@ public sealed class ApprovalsController( int page = 1, int pageSize = 20, CancellationToken ct = default, - bool oldestFirst = false) + bool oldestFirst = false, + string? type = null) { if (page < 1 || pageSize is < 1 or > 100 || (long)page * pageSize > 100000) return ValidationProblem("page 必须大于 0,pageSize 必须在 1 到 100 之间,且分页窗口不能超过 100000 条。"); @@ -114,7 +115,7 @@ public sealed class ApprovalsController( var canCollegeReview = scope.Current.IsInRole(SystemRoles.CollegeAdmin); items.AddRange(await Scoped(x => (canCollegeReview && x.State == StudentStatusChangeState.CounselorApproved) || (canFinalReview && x.State == StudentStatusChangeState.CollegeApproved)) .OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take) - .Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — {SSCLabel(x.Type)}", x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name)) + .Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — {SSCLabel(x.Type)}", x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, x.State == StudentStatusChangeState.CounselorApproved ? "college" : "final")) .ToListAsync(ct)); AddCount("StudentStatusChange", await Scoped(x => (canCollegeReview && x.State == StudentStatusChangeState.CounselorApproved) || (canFinalReview && x.State == StudentStatusChangeState.CollegeApproved)).CountAsync(ct)); @@ -189,7 +190,7 @@ public sealed class ApprovalsController( items.AddRange(await dormApplications.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take) .Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, - x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct)); + x.Student.AdministrativeClass!.Major!.College!.Name, x.Status == DormitoryApplicationStatus.Submitted ? "counselor" : "dormitory")).ToListAsync(ct)); AddCount("DormitoryApplication", await dormApplications.CountAsync(ct)); } @@ -197,7 +198,7 @@ public sealed class ApprovalsController( items.AddRange(await declarations.OrderByApprovalTime(x => x.SubmittedAt ?? x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take) .Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料复核", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, - x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct)); + x.Student.AdministrativeClass!.Major!.College!.Name, "college")).ToListAsync(ct)); AddCount("AssessmentDeclaration", await declarations.CountAsync(ct)); var assessmentAppeals = Scoped(x => x.Status == ComprehensiveAssessmentAppealStatus.Submitted); @@ -213,17 +214,17 @@ public sealed class ApprovalsController( var userId = current.UserId; var changes = db.StudentStatusChanges.AsNoTracking().Where(x => x.State == StudentStatusChangeState.Submitted && x.Student!.AdministrativeClass!.CounselorUserId == userId); items.AddRange(await changes.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take) - .Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct)); + .Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — {SSCLabel(x.Type)}", x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "counselor")).ToListAsync(ct)); AddCount("StudentStatusChange", await changes.CountAsync(ct)); var declarations = db.ComprehensiveAssessmentDeclarations.AsNoTracking().Where(x => x.Status == ComprehensiveAssessmentDeclarationStatus.Submitted && x.Student!.AdministrativeClass!.CounselorUserId == userId); items.AddRange(await declarations.OrderByApprovalTime(x => x.SubmittedAt ?? x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take) - .Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料初审", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct)); + .Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料初审", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "counselor")).ToListAsync(ct)); AddCount("AssessmentDeclaration", await declarations.CountAsync(ct)); if (!isManager) { var dorm = db.DormitoryApplications.AsNoTracking().Where(x => x.Status == DormitoryApplicationStatus.Submitted && x.Student!.AdministrativeClass!.CounselorUserId == userId); items.AddRange(await dorm.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take) - .Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct)); + .Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "counselor")).ToListAsync(ct)); AddCount("DormitoryApplication", await dorm.CountAsync(ct)); } } @@ -253,14 +254,14 @@ public sealed class ApprovalsController( { var dorm = Scoped(x => x.Status == DormitoryApplicationStatus.CounselorApproved); items.AddRange(await dorm.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take) - .Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct)); + .Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "dormitory")).ToListAsync(ct)); AddCount("DormitoryApplication", await dorm.CountAsync(ct)); } if (current.IsInRole(SystemRoles.StudentAffairsAdmin) && !isManager) { var declarations = Scoped(x => x.Status == ComprehensiveAssessmentDeclarationStatus.CounselorApproved); items.AddRange(await declarations.OrderByApprovalTime(x => x.SubmittedAt ?? x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take) - .Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料复核", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct)); + .Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料复核", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "college")).ToListAsync(ct)); AddCount("AssessmentDeclaration", await declarations.CountAsync(ct)); var appeals = Scoped(x => x.Status == ComprehensiveAssessmentAppealStatus.Submitted); items.AddRange(await appeals.OrderByApprovalTime(x => x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take) @@ -296,7 +297,9 @@ public sealed class ApprovalsController( AddCount("GraduationClearance", await clearances.CountAsync(ct)); } - var ordered = oldestFirst ? items.OrderBy(x => x.Time) : items.OrderByDescending(x => x.Time); + var filtered = string.IsNullOrWhiteSpace(type) ? items : items.Where(x => x.Type == type); + if (!string.IsNullOrWhiteSpace(type)) total = counts.GetValueOrDefault(type); + var ordered = oldestFirst ? filtered.OrderBy(x => x.Time) : filtered.OrderByDescending(x => x.Time); var pageItems = ordered .ThenBy(x => x.Type) .ThenBy(x => x.Id) diff --git a/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs b/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs index 2921085..1a71eec 100644 --- a/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs +++ b/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs @@ -13,6 +13,28 @@ namespace Jiaowu.Api.Tests; public sealed class ApprovalsControllerTests { + [Fact] + public async Task Counselor_queue_shows_the_status_change_stage_and_type() + { + await using var fixture = await ApprovalFixture.CreateAsync(); + var counselorId = Guid.NewGuid(); + fixture.Db.Users.Add(new ApplicationUser { Id = counselorId, UserName = "counselor-test", DisplayName = "辅导员" }); + var administrativeClass = await fixture.Db.AdministrativeClasses.FindAsync(fixture.Student.AdministrativeClassId); + administrativeClass!.CounselorUserId = counselorId; + fixture.Db.StudentStatusChanges.Add(new StudentStatusChange + { + StudentId = fixture.Student.Id, Type = StudentStatusChangeType.Suspension, + Reason = "需要休学", State = StudentStatusChangeState.Submitted + }); + await fixture.Db.SaveChangesAsync(); + var response = await new ApprovalsController(fixture.Db, new CounselorDataScope(counselorId)) + .GetPending(1, 20, CancellationToken.None); + var result = Assert.IsType(Assert.IsType(response.Result).Value); + var item = Assert.Single(result.Items); + Assert.Equal("counselor", item.Stage); + Assert.Contains("休学", item.Title); + } + [Fact] public async Task Clearance_pending_only_includes_the_responsible_role() { @@ -164,6 +186,12 @@ public sealed class ApprovalsControllerTests var oldestPage = Assert.IsType(Assert.IsType(oldest.Result).Value); Assert.Equal("较早提交", Assert.Single(oldestPage.Items).Desc); Assert.Equal(2, oldestPage.Total); + + var filtered = await controller.GetPending(1, 1, CancellationToken.None, type: "CourseExemption"); + var filteredPage = Assert.IsType(Assert.IsType(filtered.Result).Value); + Assert.Equal(1, filteredPage.Total); + Assert.Equal("CourseExemption", Assert.Single(filteredPage.Items).Type); + Assert.Equal(1, filteredPage.Counts["DeferredExam"]); } [Fact] @@ -477,4 +505,11 @@ public sealed class ApprovalsControllerTests Guid.NewGuid(), "学院管理员", collegeId, DataScope.College, new HashSet([SystemRoles.CollegeAdmin])); } + + private sealed class CounselorDataScope(Guid userId) : ICurrentUserDataScope + { + public CurrentUserScope Current { get; } = new( + userId, "辅导员", null, DataScope.Class, + new HashSet([SystemRoles.Counselor])); + } } diff --git a/web/e2e/approval-center.spec.ts b/web/e2e/approval-center.spec.ts new file mode 100644 index 0000000..2cbca77 --- /dev/null +++ b/web/e2e/approval-center.spec.ts @@ -0,0 +1,53 @@ +import { expect, test } from '@playwright/test' + +const cases: { type: string; stage: string | null; secondaryId?: string; endpoint: string; body: Record; reject?: boolean }[] = [ + { type: 'AttendanceAppeal', stage: null, secondaryId: 'sheet-1', endpoint: '/api/attendance/appeals/sheet-1/item-1/review', body: { approve: true, comment: null } }, + { type: 'StudentStatusChange', stage: 'final', endpoint: '/api/student-status-changes/item-1/review', body: { approved: true, comment: null } }, + { type: 'TeacherCourseApplication', stage: null, endpoint: '/api/teacher-course-applications/item-1/review', body: { status: 'Approved', reviewComment: null } }, + { type: 'ClassroomReservation', stage: null, endpoint: '/api/classroom-reservations/item-1/approve', body: { comment: null } }, + { type: 'CampusRegistration', stage: null, endpoint: '/api/campus-registrations/applications/item-1/review', body: { approved: true, comment: null } }, + { type: 'DormitoryApplication', stage: 'counselor', endpoint: '/api/dormitory-services/applications/item-1/counselor-review', body: { approved: true, comment: null } }, + { type: 'AttendanceAppeal', stage: null, secondaryId: 'sheet-1', endpoint: '/api/attendance/appeals/sheet-1/item-1/review', body: { approve: false, comment: '理由不充分' }, reject: true }, + { type: 'TeacherCourseApplication', stage: null, endpoint: '/api/teacher-course-applications/item-1/review', body: { status: 'Rejected', reviewComment: '理由不充分' }, reject: true }, +] + +for (const scenario of cases) test(`${scenario.type} can be ${scenario.reject ? 'rejected' : 'approved'} from the approval center`, async ({ page }) => { + const pageErrors: string[] = [] + page.on('pageerror', error => pageErrors.push(error.message)) + const user = { id: 'reviewer', userName: 'reviewer', displayName: '审核员', roles: ['AcademicAdmin'], permissions: [], effectiveDataScope: 'All' } + await page.addInitScript((savedUser) => { + localStorage.setItem('jiaowu_token', 'test-token') + localStorage.setItem('jiaowu_user', JSON.stringify(savedUser)) + localStorage.setItem('jiaowu_access_expires_at', '2099-01-01T00:00:00Z') + localStorage.setItem('jiaowu_session_expires_at', '2099-01-01T00:00:00Z') + }, user) + let reviewed = false + await page.route(url => url.pathname.startsWith('/api/'), async route => { + const url = new URL(route.request().url()) + if (url.pathname === '/api/approvals/pending') { + const items = reviewed ? [] : [{ id: 'item-1', secondaryId: scenario.secondaryId, type: scenario.type, stage: scenario.stage, label: '申请', title: '学生 — 《课程》', desc: '申请事由', time: '2026-11-01T00:00:00Z', college: '学院' }] + return route.fulfill({ json: { items, total: items.length, page: 1, pageSize: 20, counts: reviewed ? {} : { [scenario.type]: 1 } } }) + } + if (url.pathname === scenario.endpoint) { + expect(route.request().method()).toBe('POST') + expect(route.request().postDataJSON()).toEqual(scenario.body) + reviewed = true + return route.fulfill({ status: 204 }) + } + if (url.pathname === '/api/auth/me') return route.fulfill({ json: user }) + if (url.pathname === '/api/plugins/runtime') return route.fulfill({ json: [] }) + return route.fulfill({ json: {} }) + }) + await page.goto('/approvals') + const card = page.locator('.appr-card').filter({ hasText: '申请事由' }) + await expect(card).toBeVisible() + if (scenario.reject) { + await card.getByRole('button', { name: '驳回' }).click() + const dialog = page.getByRole('dialog') + await dialog.locator('textarea').fill('理由不充分') + await dialog.getByRole('button', { name: '确认驳回' }).click() + } else await card.getByRole('button', { name: '通过' }).click() + await expect(card).toHaveCount(0) + expect(reviewed).toBe(true) + expect(pageErrors).toEqual([]) +}) diff --git a/web/src/i18n/messages/en-US.ts b/web/src/i18n/messages/en-US.ts index ca94e09..bf01150 100644 --- a/web/src/i18n/messages/en-US.ts +++ b/web/src/i18n/messages/en-US.ts @@ -1,6 +1,9 @@ export default { approvalCenterAdjustment: 'Class adjustment', approvalCenterClearance: 'Graduation clearance', + approvalCenterCounselorStage: 'Counselor review', + approvalCenterAllTypes: 'All types', + approvalCenterDormitoryStage: 'Dormitory review', approvalCenterExtra: { teacherCourse: 'Course application', classroom: 'Classroom reservation', collegeStage: 'College review', finalStage: 'Final review', gradeBatch: 'Partial grade review', experimentGrade: 'Experiment grade review', campusRegistration: 'Registration review', dormitory: 'Dormitory application', assessmentDeclaration: 'Assessment evidence review', assessmentAppeal: 'Assessment appeal', gradeAppeal: 'Grade appeal', teachingImprovement: 'Teaching improvement review', pendingTotal: '{count} pending in your scope', oldest: 'Oldest: {title} · submitted {time}', oldestFirst: 'Oldest first', settings: 'Review routing', settingsHint: 'Choose the reviewer for new exemption, deferred exam and substitution requests. Existing requests retain their original rule; other workflows retain their existing stages. Super administrators may always review.', anyManager: 'Any academic manager', collegeReviewer: 'College administrator', academicReviewer: 'Academic administrator', settingsSaved: 'Routing saved for new requests' }, assessmentScript: {"k0": "Academic performance", "k1": "Physical fitness", "k2": "Dormitory hygiene", "k3": "Attendance", "k4": "Evidence submission", "k5": "Draft", "k6": "Collecting evidence", "k7": "Review and calculation", "k8": "Public review", "k9": "Published", "k10": "Awaiting counselor review", "k11": "Awaiting college review", "k12": "Approved", "k13": "Rejected", "k14": "Withdrawn", "k15": "Plan published", "k16": "Evidence opens", "k17": "Evidence closes", "k18": "Counselor review deadline", "k19": "College review deadline", "k20": "Overall freeze", "k21": "Public review starts", "k22": "Public review ends", "k23": "Final publication", "k24": "Not set", "k25": "Dimension weights must total 100%", "k26": "Assessment scheme updated", "k27": "Assessment scheme saved as draft", "k28": "Add an evidence-submission dimension first", "k29": "Scheme published and version locked", "k30": "Delete draft scheme", "k31": "Delete", "k32": "Draft scheme deleted", "k33": "Schedule milestones in workflow order", "k34": "Term assessment plan created", "k35": "Future milestones updated", "k36": "Term scheme published; live calculation started", "k37": "Evidence collection ended", "k38": "Live calculation queued", "k39": "Calculation queued", "k40": "Lock dimension scores", "k41": "Confirm lock", "k42": "Unlocking invalidates official results and resumes live calculation. Enter a reason.", "k43": "Enter a reason for unlocking", "k44": "Results entered public review", "k45": "Students can see final results after publication. Have all appeals been handled?", "k46": "Assessment results published", "k47": "Live assessment estimate", "k48": "Official assessment results", "k49": "Exported all records matching the filters", "k50": "Enter a description or a link to evidence", "k51": "Evidence draft updated", "k52": "Evidence draft saved", "k53": "Evidence submitted for review", "k54": "Withdrawn evidence will not be reviewed; its record will be retained.", "k55": "Withdraw evidence", "k56": "Evidence withdrawn", "k57": "Delete this draft? This cannot be undone.", "k58": "Delete draft", "k59": "Draft deleted", "k60": "Approve score", "k61": "Optionally provide review comments, including the reason for score adjustments.", "k62": "Enter a rejection reason", "k63": "Approve", "k64": "Reject evidence", "k65": "A reason is required for rejection", "k66": "Review saved", "k67": "Appeal submitted", "k68": "After accepting the appeal, correct the source data, recalculate and repeat public review. Enter the decision rationale.", "k69": "Enter the reason for rejection.", "k70": "Accept appeal", "k71": "Reject appeal", "k72": "Enter a decision comment", "k73": "Appeal accepted; correct the data and recalculate", "k74": "Appeal rejected", "deleteScheme": "Delete draft “{name} v{version}” and its dimensions and rules?", "lock": "Locking “{name}” makes the official assessment use the current snapshot, without subsequent source changes.", "locked": "{name} locked", "unlock": "Unlock {name}", "unlocked": "{name} unlocked", "scorePrompt": "Claimed score: {score}; approve a score within ±{maximum}.", "scoreValidation": "Score must be within ±{maximum}."}, schedulesScript: {"k0": "Monday", "k1": "Tuesday", "k2": "Wednesday", "k3": "Thursday", "k4": "Friday", "k5": "Saturday", "k6": "Sunday", "k7": "General classroom", "k8": "Laboratory", "k9": "Training room", "k10": "Computer lab", "k11": "Language lab", "k12": "Sports venue", "k13": "Arts venue", "k14": "Draft", "k15": "Published", "k16": "Archived", "k17": "Every week", "k18": "Odd weeks", "k19": "Even weeks", "k20": "Job queued for background processing", "k21": "Background scheduling failed. Try again later.", "k22": "Publication queued for background checks", "k23": "Checking and publishing the timetable", "k24": "Checks passed; timetable published", "k25": "Timetable check failed", "k26": "Automatic scheduling strategy saved", "k27": "Teaching time slots saved", "k28": "Scheduling constraints saved", "k29": "No editable teaching tasks match the current filters.", "k30": "Select at least one setting to change.", "k31": "Change scheduling constraints in bulk", "k32": "Update filtered results", "k33": "Cancel", "k34": "Existing manual assignments are preserved while theory and lab classes are filled in. Labs use suitable venues; generated entries remain editable.", "k35": "Start automatic scheduling", "k36": "Generate schedule", "k37": "Scheduling job submitted; progress is available on this page", "k38": "Timetable checks passed and it was published", "k39": "Timetable checks failed. Adjust the schedule and try again.", "k40": "Enter the term, version name and version number.", "k41": "Revision draft created; the published timetable remains active", "k42": "Copied to an editable draft", "k43": "All instructor, class and room conflicts will be checked. Publishing locks this version and replaces the previous timetable; a revision can be created afterward.", "k44": "Publish timetable", "k45": "Check and publish", "k46": "Check and publication job submitted; progress is available here", "k47": "Delete this draft and all scheduling entries?", "k48": "Delete scheduling draft", "k49": "The draft covers all teaching classes requiring scheduling.", "k50": "OK", "k51": "Select a teaching task and a classroom if required.", "k52": "The selected day is not allowed for this teaching task.", "k53": "Schedule entry updated", "k54": "Schedule entry added", "k55": "Remove schedule entry", "generation": "Genetic algorithm is searching generation {current}/{total}", "processing": "Processing {processed}/{total} classes; {entries} entries planned", "complete": "Scheduling completed with {entries} entries", "period": "Period {period}", "confirmBulk": "Update {count} filtered teaching tasks?", "updated": "Updated {count} teaching tasks", "completeManual": "Scheduling completed with {entries} entries; {tasks} tasks still need manual attention", "unscheduled": "{count} teaching classes remain unscheduled:\n{messages}", "checkTitle": "Pre-scheduling check · {scheduled}/{total} covered", "weekRange": "The schedule must fall within weeks {start}–{end} of this teaching task.", "remove": "Remove this entry for “{name}”?"}, diff --git a/web/src/i18n/messages/zh-CN.ts b/web/src/i18n/messages/zh-CN.ts index 4ce3a20..3c0c0d7 100644 --- a/web/src/i18n/messages/zh-CN.ts +++ b/web/src/i18n/messages/zh-CN.ts @@ -1,6 +1,9 @@ export default { approvalCenterAdjustment: '调停课', approvalCenterClearance: '毕业离校办理', + approvalCenterCounselorStage: '辅导员审核', + approvalCenterAllTypes: '全部类型', + approvalCenterDormitoryStage: '宿舍管理审核', approvalCenterExtra: { teacherCourse: '课程申报', classroom: '教室借用', collegeStage: '学院审核', finalStage: '校级审核', gradeBatch: '部分成绩审核', experimentGrade: '实验成绩审核', campusRegistration: '校园报名审核', dormitory: '住宿申请', assessmentDeclaration: '综合测评材料复核', assessmentAppeal: '综合测评申诉', gradeAppeal: '成绩异议', teachingImprovement: '教学改进复评', pendingTotal: '当前范围待处理 {count} 项', oldest: '等待最久:{title} · 提交于 {time}', oldestFirst: '等待最久优先', settings: '审核角色配置', settingsHint: '为新提交的免修、缓考、课程替代申请设置审核角色;已提交申请沿用原规则,其他事项保持原有流程。超级管理员始终可以审核。', anyManager: '任一教务管理角色', collegeReviewer: '学院管理员', academicReviewer: '教务管理员', settingsSaved: '新申请的审核规则已保存' }, assessmentScript: {"k0": "学业表现", "k1": "体育健康", "k2": "宿舍卫生", "k3": "日常考勤", "k4": "材料申报", "k5": "草稿", "k6": "材料采集中", "k7": "审核计算", "k8": "公示中", "k9": "已发布", "k10": "待辅导员初审", "k11": "待学院复核", "k12": "已通过", "k13": "已驳回", "k14": "已撤回", "k15": "方案发布", "k16": "材料开放", "k17": "材料截止", "k18": "辅导员初审截止", "k19": "学院复核截止", "k20": "总体冻结", "k21": "公示开始", "k22": "公示结束", "k23": "正式发布", "k24": "未设置", "k25": "维度权重合计必须为 100%", "k26": "测评方案已更新", "k27": "测评方案已保存为草稿", "k28": "请先添加“材料申报”来源的维度", "k29": "方案已发布并锁定版本", "k30": "删除草稿方案", "k31": "删除", "k32": "草稿方案已删除", "k33": "时间节点应按业务流程先后排列", "k34": "学期测评计划已建立", "k35": "未来时间节点已更新", "k36": "学期方案已发布,实时测算已启动", "k37": "材料采集已结束", "k38": "实时测算任务已进入后台队列", "k39": "计算任务已进入后台队列", "k40": "锁定维度成绩", "k41": "确认锁定", "k42": "解锁会使正式结果失效,并重新进入实时测算。请填写原因。", "k43": "必须填写解锁原因", "k44": "结果已进入公示期", "k45": "正式发布后学生可查看最终结果,确认所有申诉均已处理?", "k46": "综合测评结果已发布", "k47": "综合测评实时预估", "k48": "综合测评正式结果", "k49": "已导出当前筛选范围的全部记录", "k50": "证明说明和证明链接至少填写一项", "k51": "材料草稿已更新", "k52": "材料草稿已保存", "k53": "材料已提交审核", "k54": "撤回后该材料不会进入审核,本次记录仍会保留。", "k55": "撤回材料", "k56": "材料已撤回", "k57": "确定删除这份草稿?删除后无法恢复。", "k58": "删除草稿", "k59": "草稿已删除", "k60": "核定分值", "k61": "可填写审核意见;学院复核时可在意见中说明调分依据。", "k62": "请填写驳回原因", "k63": "审核通过", "k64": "驳回材料", "k65": "驳回时必须填写原因", "k66": "审核结果已保存", "k67": "申诉已提交", "k68": "支持后必须修正源数据,重新计算并再次公示。请填写处理依据。", "k69": "请填写驳回依据。", "k70": "支持申诉", "k71": "驳回申诉", "k72": "必须填写处理意见", "k73": "已支持申诉,请修正数据并重新计算", "k74": "申诉已驳回", "deleteScheme": "确定删除“{name} v{version}”草稿?方案中的维度和规则也会一并删除。", "lock": "锁定“{name}”后,正式评定将使用当前测算快照,不再随源数据变化。", "locked": "{name}已锁定", "unlock": "解锁{name}", "unlocked": "{name}已解锁", "scorePrompt": "规则申报 {score} 分,可在 ±{maximum} 分范围内核定。", "scoreValidation": "分值必须在 ±{maximum} 分范围内"}, schedulesScript: {"k0": "星期一", "k1": "星期二", "k2": "星期三", "k3": "星期四", "k4": "星期五", "k5": "星期六", "k6": "星期日", "k7": "普通教室", "k8": "实验室", "k9": "实训室", "k10": "计算机机房", "k11": "语音室", "k12": "体育场地", "k13": "艺术场地", "k14": "草稿", "k15": "已发布", "k16": "已归档", "k17": "每周", "k18": "单周", "k19": "双周", "k20": "任务已进入队列,等待后台执行", "k21": "后台排课失败,请稍后重试", "k22": "发布任务已进入队列,等待后台检查", "k23": "正在检查并发布课表", "k24": "检查已通过,课表发布成功", "k25": "课表检查未通过", "k26": "自动排课优化策略已保存", "k27": "上课时间表已保存", "k28": "排课约束已保存", "k29": "当前筛选结果中没有可修改的教学任务。", "k30": "请至少勾选一项需要批量修改的设置。", "k31": "批量修改排课约束", "k32": "修改当前结果", "k33": "取消", "k34": "系统会保留当前手工安排,同时补齐理论课和实验课。实验课仅使用实验室、实训室、机房等场地;生成后仍可手工调整。", "k35": "开始自动排课", "k36": "生成排课", "k37": "自动排课任务已提交,可留在当前页面查看进度", "k38": "课表检查通过,已发布", "k39": "课表检查未通过,请调整后重试", "k40": "请填写学期、版本名称和版本号。", "k41": "已建立修订草稿,原已发布课表继续生效", "k42": "已复制为可调整的草稿版本", "k43": "系统将再次检查全部教师、行政班和教室冲突;发布后本版本锁定并替换旧课表,后续仍可通过“发布后修改”建立修订版。", "k44": "发布课表", "k45": "检查并发布", "k46": "检查并发布任务已提交,可在当前页面查看进度", "k47": "删除该草稿及全部排课条目?", "k48": "删除排课草稿", "k49": "当前草稿已覆盖全部需要排课的教学班。", "k50": "知道了", "k51": "请选择教学任务,并按课程要求选择教室。", "k52": "所选星期不在该教学任务允许的上课日内。", "k53": "排课已调整", "k54": "排课已添加", "k55": "移除排课", "generation": "遗传算法正在搜索第 {current}/{total} 代", "processing": "正在处理 {processed}/{total} 个教学班,已规划 {entries} 条安排", "complete": "后台排课已完成,共生成 {entries} 条安排", "period": "第 {period} 节", "confirmBulk": "将修改当前筛选到的 {count} 个教学任务,确定继续吗?", "updated": "已批量更新 {count} 个教学任务", "completeManual": "后台排课完成,已生成 {entries} 条安排,仍有 {tasks} 个任务需人工处理", "unscheduled": "尚有 {count} 个教学班未安排:\n{messages}", "checkTitle": "排课前检查 · 已覆盖 {scheduled}/{total}", "weekRange": "排课周次必须位于该教学任务的第 {start}—{end} 周内。", "remove": "移除“{name}”的这条安排?"}, diff --git a/web/src/views/ApprovalCenterView.vue b/web/src/views/ApprovalCenterView.vue index e129a65..a1f6374 100644 --- a/web/src/views/ApprovalCenterView.vue +++ b/web/src/views/ApprovalCenterView.vue @@ -67,6 +67,7 @@ const pendingTotal = ref(0) const pendingPageSize = 20 const oldestPending = ref(null) const oldestFirst = ref(false) +const selectedPendingType = ref('') const pendingCounts = ref>({}) const targetApprovalType = computed(() => { const value = route.query.type @@ -87,6 +88,7 @@ const substituteKeyword = ref('') const rejectDialog = ref(false) const rejectItem = ref(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 = { StudentStatusChange: '/student-status-changes', @@ -529,7 +573,8 @@ onMounted(() => { {{ t('approvalCenterExtra.oldest', { title: oldestPending.title, time: new Date(oldestPending.time).toLocaleString(getDisplayLocale()) }) }}
- {{ approvalCountLabel(String(type)) }} · {{ count }} + {{ t('approvalCenterAllTypes') }} + {{ approvalCountLabel(String(type)) }} · {{ count }}
@@ -537,11 +582,12 @@ onMounted(() => {
{{ item.title }}

{{ item.desc }}

- {{ item.college }} · {{ new Date(item.time).toLocaleString(getDisplayLocale()) }} + {{ item.college }} · {{ new Date(item.time).toLocaleString(getDisplayLocale()) }}
-
- {{ t('businessLabels.reject') }} - {{ t('businessLabels.approve') }} +
+ {{ t('approvalBatch.k76') }} + {{ t('businessLabels.reject') }} + {{ t('businessLabels.approve') }}
{ - +