From c5ad71e8faa8eeb27b351564695a5087e5c00ccf Mon Sep 17 00:00:00 2001 From: biss Date: Sun, 8 Nov 2026 11:35:02 +0800 Subject: [PATCH] Expand approval progress to additional workflows --- .../Controllers/ApprovalsController.cs | 104 +++++++++++++++- .../ApprovalsControllerTests.cs | 117 ++++++++++++++++++ web/e2e/approval-center.spec.ts | 13 +- web/src/i18n/messages/en-US.ts | 3 +- web/src/i18n/messages/zh-CN.ts | 3 +- web/src/views/ApprovalCenterView.vue | 14 ++- web/src/views/ClassroomReservationsView.vue | 4 +- web/src/views/CourseAdjustmentsView.vue | 1 + web/src/views/DormitoryHygieneView.vue | 2 +- web/src/views/TeachingPreferencesView.vue | 3 +- 10 files changed, 241 insertions(+), 23 deletions(-) diff --git a/src/Jiaowu.Api/Controllers/ApprovalsController.cs b/src/Jiaowu.Api/Controllers/ApprovalsController.cs index b16268a..d66c543 100644 --- a/src/Jiaowu.Api/Controllers/ApprovalsController.cs +++ b/src/Jiaowu.Api/Controllers/ApprovalsController.cs @@ -67,7 +67,10 @@ public sealed class ApprovalsController( { case "CourseExemption": { - var query = manager ? Scoped(x => x.Id == id) : db.CourseExemptions.AsNoTracking().Where(x => x.Id == id && x.Student!.UserId == userId); + var restrictedCollegeId = current.RestrictedCollegeId; + var allColleges = manager && current.Scope == DataScope.All; + var query = db.CourseExemptions.AsNoTracking().Where(x => x.Id == id && + (x.Student!.UserId == userId || (manager && (allColleges || x.TeachingTask!.Course!.CollegeId == restrictedCollegeId)))); var item = await query.FirstOrDefaultAsync(ct); if (item is null) return NotFound(); AddSingleApprovalSteps(steps, item.SubmittedAt, item.ReviewedAt, item.Status, item.ReviewComment); @@ -75,7 +78,10 @@ public sealed class ApprovalsController( } case "DeferredExam": { - var query = manager ? Scoped(x => x.Id == id) : db.DeferredExams.AsNoTracking().Where(x => x.Id == id && x.Student!.UserId == userId); + var restrictedCollegeId = current.RestrictedCollegeId; + var allColleges = manager && current.Scope == DataScope.All; + var query = db.DeferredExams.AsNoTracking().Where(x => x.Id == id && + (x.Student!.UserId == userId || (manager && (allColleges || x.TeachingTask!.Course!.CollegeId == restrictedCollegeId)))); var item = await query.FirstOrDefaultAsync(ct); if (item is null) return NotFound(); AddSingleApprovalSteps(steps, item.SubmittedAt, item.ReviewedAt, item.Status, item.ReviewComment); @@ -83,7 +89,10 @@ public sealed class ApprovalsController( } case "CourseSubstitution": { - var query = manager ? Scoped(x => x.Id == id) : db.CourseSubstitutions.AsNoTracking().Where(x => x.Id == id && x.Student!.UserId == userId); + var restrictedCollegeId = current.RestrictedCollegeId; + var allColleges = manager && current.Scope == DataScope.All; + var query = db.CourseSubstitutions.AsNoTracking().Where(x => x.Id == id && + (x.Student!.UserId == userId || (manager && (allColleges || x.Student.AdministrativeClass!.Major!.CollegeId == restrictedCollegeId)))); var item = await query.FirstOrDefaultAsync(ct); if (item is null) return NotFound(); AddSingleApprovalSteps(steps, item.SubmittedAt, item.ReviewedAt, item.Status, item.ReviewComment); @@ -91,7 +100,10 @@ public sealed class ApprovalsController( } case "GradeModification": { - var query = manager ? Scoped(x => x.Id == id) : db.GradeModifications.AsNoTracking().Where(x => x.Id == id && x.ApplicantUserId == userId); + var restrictedCollegeId = current.RestrictedCollegeId; + var allColleges = manager && current.Scope == DataScope.All; + var query = db.GradeModifications.AsNoTracking().Where(x => x.Id == id && + (x.ApplicantUserId == userId || (manager && (allColleges || x.GradeRecord!.GradeSheet!.TeachingTask!.Course!.CollegeId == restrictedCollegeId)))); var item = await query.FirstOrDefaultAsync(ct); if (item is null) return NotFound(); steps.Add(new("submitted", item.SubmittedAt, item.Reason)); @@ -104,15 +116,95 @@ public sealed class ApprovalsController( steps.Add(new(item.Status == GradeModificationStatus.Rejected ? "finalRejected" : "finalApproved", finalTime, item.ReviewComment)); break; } + case "TeacherCourseApplication": + { + var query = db.TeacherCourseApplications.AsNoTracking().Where(x => x.Id == id); + if (manager) + { + if (current.RestrictedCollegeId is { } collegeId) + query = query.Where(x => x.Teacher!.CollegeId == collegeId || x.Teacher.UserId == userId); + } + else query = query.Where(x => x.Teacher!.UserId == userId); + var item = await query.FirstOrDefaultAsync(ct); + if (item is null) return NotFound(); + steps.Add(new("started", item.SubmittedAt, null)); + if (item.ReviewedAt is { } time && item.Status is TeacherCourseApplicationStatus.Approved or TeacherCourseApplicationStatus.Rejected) + steps.Add(new(item.Status == TeacherCourseApplicationStatus.Approved ? "approved" : "rejected", time, item.ReviewComment)); + if ((item.Status is TeacherCourseApplicationStatus.Approved or TeacherCourseApplicationStatus.Rejected) && item.ReviewedAt is null || + item.Status == TeacherCourseApplicationStatus.Withdrawn) + historyIncomplete = true; + break; + } + case "ClassroomReservation": + { + var collegeId = current.CollegeId; + var canReview = current.IsInRole(SystemRoles.CollegeAdmin) && collegeId.HasValue; + var item = await db.ClassroomReservations.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id && + (x.ApplicantUserId == userId || (canReview && x.ApplicantCollegeId == collegeId)), ct); + if (item is null) return NotFound(); + steps.Add(new("submitted", item.CreatedAt, null)); + if (item.ReviewedAt is { } time && item.Status is ClassroomReservationStatus.Approved or ClassroomReservationStatus.Rejected or ClassroomReservationStatus.Cancelled) + steps.Add(new(item.Status == ClassroomReservationStatus.Rejected ? "rejected" : "approved", time, item.ReviewComment)); + if (item.CancelledAt is { } cancelledAt && item.Status == ClassroomReservationStatus.Cancelled) + steps.Add(new("cancelled", cancelledAt, null)); + if ((item.Status is ClassroomReservationStatus.Approved or ClassroomReservationStatus.Rejected) && item.ReviewedAt is null || + item.Status == ClassroomReservationStatus.Cancelled && item.CancelledAt is null) + historyIncomplete = true; + break; + } + case "CourseAdjustment": + { + var restrictedCollegeId = current.RestrictedCollegeId; + var allColleges = manager && current.Scope == DataScope.All; + var query = db.CourseAdjustments.AsNoTracking().Where(x => x.Id == id && + (x.ApplicantUserId == userId || (manager && (allColleges || x.TeachingTask!.Course!.CollegeId == restrictedCollegeId)))); + var item = await query.FirstOrDefaultAsync(ct); + if (item is null) return NotFound(); + if (item.SubmittedAt is { } submittedAt) steps.Add(new("submitted", submittedAt, null)); + else if (item.Status == CourseAdjustmentStatus.Draft) steps.Add(new("created", item.CreatedAt, null)); + else historyIncomplete = true; + if (item.ReviewedAt is { } reviewedAt && item.Status is CourseAdjustmentStatus.Approved or CourseAdjustmentStatus.Rejected) + steps.Add(new(item.Status == CourseAdjustmentStatus.Approved ? "approved" : "rejected", reviewedAt, item.ReviewComment)); + else if (item.Status is CourseAdjustmentStatus.Approved or CourseAdjustmentStatus.Rejected) historyIncomplete = true; + break; + } + case "DormitoryApplication": + { + var viewer = manager || current.IsInRole(SystemRoles.DormitoryAdmin) || current.IsInRole(SystemRoles.Counselor); + var query = db.DormitoryApplications.AsNoTracking().Where(x => x.Id == id); + if (!viewer) query = query.Where(x => x.Student!.UserId == userId); + else if (current.Scope == DataScope.College) + query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId); + else if (current.Scope == DataScope.Class) + query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.CounselorUserId == userId); + else if (current.Scope != DataScope.All) + query = query.Where(x => x.Student!.UserId == userId); + var item = await query.FirstOrDefaultAsync(ct); + if (item is null) return NotFound(); + steps.Add(new("submitted", item.SubmittedAt, null)); + if (item.CounselorReviewedAt is { } counselorAt) + { + var rejected = item.Status == DormitoryApplicationStatus.Rejected && item.FinalReviewedAt is null; + steps.Add(new(rejected ? "counselorRejected" : "counselorApproved", counselorAt, item.CounselorComment)); + } + if (item.FinalReviewedAt is { } finalAt && item.Status is DormitoryApplicationStatus.Approved or DormitoryApplicationStatus.Rejected) + steps.Add(new(item.Status == DormitoryApplicationStatus.Approved ? "dormitoryApproved" : "dormitoryRejected", finalAt, item.FinalComment)); + if (item.Status == DormitoryApplicationStatus.Cancelled || + item.Status == DormitoryApplicationStatus.CounselorApproved && item.CounselorReviewedAt is null || + item.Status == DormitoryApplicationStatus.Approved && (item.CounselorReviewedAt is null || item.FinalReviewedAt is null) || + item.Status == DormitoryApplicationStatus.Rejected && item.CounselorReviewedAt is null) + historyIncomplete = true; + break; + } case "StudentStatusChange": { var query = db.StudentStatusChanges.AsNoTracking().Where(x => x.Id == id); if (manager || current.IsInRole(SystemRoles.Counselor)) { if (current.Scope == DataScope.College) - query = query.Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId); + query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId); else if (current.Scope == DataScope.Class) - query = query.Where(x => x.Student!.AdministrativeClass!.CounselorUserId == userId); + query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.CounselorUserId == userId); else if (current.Scope != DataScope.All) query = query.Where(x => x.Student!.UserId == userId); } diff --git a/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs b/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs index 14177f8..c5543cc 100644 --- a/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs +++ b/tests/Jiaowu.Api.Tests/ApprovalsControllerTests.cs @@ -13,6 +13,109 @@ namespace Jiaowu.Api.Tests; public sealed class ApprovalsControllerTests { + [Fact] + public async Task Classroom_progress_preserves_approval_and_later_cancellation_with_role_scope() + { + await using var fixture = await ApprovalFixture.CreateAsync(); + var campus = new Campus { Code = "CAMP", Name = "校区" }; + var building = new Building { Code = "BLD", Name = "教学楼", CampusId = campus.Id }; + var room = new Classroom { Code = "R1", Name = "教室", BuildingId = building.Id }; + var created = DateTime.UtcNow.AddHours(-3); + var reservation = new ClassroomReservation + { + ApplicantUserId = fixture.Student.UserId!.Value, ApplicantName = fixture.Student.Name, + ApplicantCollegeId = fixture.CurrentCourse.CollegeId, AcademicTermId = fixture.CurrentTerm.Id, + ClassroomId = room.Id, Purpose = "活动", ContactPhone = "123456", Status = ClassroomReservationStatus.Cancelled, + CreatedAt = created, ReviewedAt = created.AddHours(1), CancelledAt = created.AddHours(2), ReviewComment = "同意" + }; + fixture.Db.AddRange(campus, building, room, reservation); + await fixture.Db.SaveChangesAsync(); + var own = await fixture.Controller.GetProgress("ClassroomReservation", reservation.Id, CancellationToken.None); + var progress = Assert.IsType(Assert.IsType(own.Result).Value); + Assert.Equal(new[] { "submitted", "approved", "cancelled" }, progress.Steps.Select(x => x.Kind)); + Assert.False(progress.HistoryIncomplete); + var otherCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(Guid.NewGuid())); + Assert.IsType((await otherCollege.GetProgress("ClassroomReservation", reservation.Id, CancellationToken.None)).Result); + var superOnly = new ApprovalsController(fixture.Db, new ManagerDataScope()); + Assert.IsType((await superOnly.GetProgress("ClassroomReservation", reservation.Id, CancellationToken.None)).Result); + } + + [Fact] + public async Task Dormitory_progress_uses_recorded_stage_decisions_and_scoped_access() + { + await using var fixture = await ApprovalFixture.CreateAsync(); + var submitted = DateTime.UtcNow.AddDays(-1); + var application = new DormitoryApplication + { + StudentId = fixture.Student.Id, Reason = "住宿申请", Status = DormitoryApplicationStatus.Rejected, + SubmittedAt = submitted, CounselorReviewedAt = submitted.AddHours(1), CounselorComment = "初审同意", + FinalReviewedAt = submitted.AddHours(2), FinalComment = "床位不足" + }; + fixture.Db.DormitoryApplications.Add(application); + await fixture.Db.SaveChangesAsync(); + var response = await fixture.Controller.GetProgress("DormitoryApplication", application.Id, CancellationToken.None); + var result = Assert.IsType(Assert.IsType(response.Result).Value); + Assert.Equal(new[] { "submitted", "counselorApproved", "dormitoryRejected" }, result.Steps.Select(x => x.Kind)); + Assert.Equal("床位不足", result.Steps[2].Comment); + var outsider = new ApprovalsController(fixture.Db, new CounselorDataScope(Guid.NewGuid())); + Assert.IsType((await outsider.GetProgress("DormitoryApplication", application.Id, CancellationToken.None)).Result); + var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value)); + Assert.IsType((await dualRole.GetProgress("DormitoryApplication", application.Id, CancellationToken.None)).Result); + application.Status = DormitoryApplicationStatus.Cancelled; + application.CounselorReviewedAt = null; + application.FinalReviewedAt = null; + await fixture.Db.SaveChangesAsync(); + var cancelled = await fixture.Controller.GetProgress("DormitoryApplication", application.Id, CancellationToken.None); + var cancelledProgress = Assert.IsType(Assert.IsType(cancelled.Result).Value); + Assert.True(cancelledProgress.HistoryIncomplete); + Assert.Equal("submitted", Assert.Single(cancelledProgress.Steps).Kind); + } + + [Fact] + public async Task Teacher_course_progress_is_visible_only_to_owner_or_scoped_manager() + { + await using var fixture = await ApprovalFixture.CreateAsync(); + var teacher = new Teacher { TeacherNumber = "T-HISTORY", Name = "教师", CollegeId = fixture.CurrentCourse.CollegeId, UserId = fixture.Student.UserId }; + var application = new TeacherCourseApplication + { + TeacherId = teacher.Id, CourseId = fixture.CurrentCourse.Id, AcademicTermId = fixture.CurrentTerm.Id, + Status = TeacherCourseApplicationStatus.Rejected, ReviewedAt = DateTime.UtcNow, ReviewComment = "不符合条件" + }; + fixture.Db.AddRange(teacher, application); + await fixture.Db.SaveChangesAsync(); + var response = await fixture.Controller.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None); + var result = Assert.IsType(Assert.IsType(response.Result).Value); + Assert.Equal(new[] { "started", "rejected" }, result.Steps.Select(x => x.Kind)); + var otherCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(Guid.NewGuid())); + Assert.IsType((await otherCollege.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None)).Result); + var sameCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(fixture.CurrentCourse.CollegeId)); + Assert.IsType((await sameCollege.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None)).Result); + var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value)); + Assert.IsType((await dualRole.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None)).Result); + application.Status = TeacherCourseApplicationStatus.Withdrawn; + application.ReviewedAt = null; + await fixture.Db.SaveChangesAsync(); + var withdrawn = await fixture.Controller.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None); + var withdrawnProgress = Assert.IsType(Assert.IsType(withdrawn.Result).Value); + Assert.True(withdrawnProgress.HistoryIncomplete); + Assert.Equal("started", Assert.Single(withdrawnProgress.Steps).Kind); + } + + [Fact] + public async Task Adjustment_draft_does_not_claim_it_was_submitted() + { + await using var fixture = await ApprovalFixture.CreateAsync(); + var draft = new CourseAdjustment { TeachingTaskId = fixture.CurrentTask.Id, ApplicantUserId = fixture.Student.UserId!.Value, Status = CourseAdjustmentStatus.Draft }; + fixture.Db.CourseAdjustments.Add(draft); + await fixture.Db.SaveChangesAsync(); + var response = await fixture.Controller.GetProgress("CourseAdjustment", draft.Id, CancellationToken.None); + var result = Assert.IsType(Assert.IsType(response.Result).Value); + Assert.Equal("created", Assert.Single(result.Steps).Kind); + Assert.False(result.HistoryIncomplete); + var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value)); + Assert.IsType((await dualRole.GetProgress("CourseAdjustment", draft.Id, CancellationToken.None)).Result); + } + [Fact] public void Overdue_filter_translates_with_mysql_provider() { @@ -127,6 +230,8 @@ public sealed class ApprovalsControllerTests Assert.Equal(3, await fixture.Db.StudentStatusChangeEvents.CountAsync()); var outsider = new ApprovalsController(fixture.Db, new CounselorDataScope(Guid.NewGuid())); Assert.IsType((await outsider.GetProgress("StudentStatusChange", change.Id, CancellationToken.None)).Result); + var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value)); + Assert.IsType((await dualRole.GetProgress("StudentStatusChange", change.Id, CancellationToken.None)).Result); } [Fact] @@ -169,6 +274,9 @@ public sealed class ApprovalsControllerTests Assert.Equal(new[] { "submitted", "collegeApproved", "finalRejected" }, result.Steps.Select(x => x.Kind)); Assert.Null(result.Steps[1].Comment); Assert.Equal("校级未通过", result.Steps[2].Comment); + var applicantWithOtherCollegeRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(change.ApplicantUserId)); + Assert.IsType((await applicantWithOtherCollegeRole.GetProgress("GradeModification", change.Id, CancellationToken.None)).Result); + Assert.IsType((await fixture.Controller.GetProgress("GradeModification", change.Id, CancellationToken.None)).Result); } [Fact] @@ -194,6 +302,8 @@ public sealed class ApprovalsControllerTests Assert.IsType((await outsider.GetProgress("CourseExemption", exemption.Id, CancellationToken.None)).Result); var otherCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(Guid.NewGuid())); Assert.IsType((await otherCollege.GetProgress("CourseExemption", exemption.Id, CancellationToken.None)).Result); + var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value)); + Assert.IsType((await dualRole.GetProgress("CourseExemption", exemption.Id, CancellationToken.None)).Result); } [Fact] @@ -695,4 +805,11 @@ public sealed class ApprovalsControllerTests userId, "辅导员", null, DataScope.Class, new HashSet([SystemRoles.Counselor])); } + + private sealed class DualRoleDataScope(Guid userId) : ICurrentUserDataScope + { + public CurrentUserScope Current { get; } = new( + userId, "多角色用户", Guid.NewGuid(), DataScope.College, + new HashSet([SystemRoles.CollegeAdmin, SystemRoles.Student, SystemRoles.Teacher])); + } } diff --git a/web/e2e/approval-center.spec.ts b/web/e2e/approval-center.spec.ts index 9d37456..d549ff4 100644 --- a/web/e2e/approval-center.spec.ts +++ b/web/e2e/approval-center.spec.ts @@ -3,13 +3,14 @@ import { expect, test } from '@playwright/test' const cases: { type: string; stage: string | null; secondaryId?: string; endpoint: string; body: Record | null; reject?: boolean; progress?: 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 }, progress: true }, - { 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: 'TeacherCourseApplication', stage: null, endpoint: '/api/teacher-course-applications/item-1/review', body: { status: 'Approved', reviewComment: null }, progress: true }, + { type: 'ClassroomReservation', stage: null, endpoint: '/api/classroom-reservations/item-1/approve', body: { comment: null }, progress: true }, { 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: 'DormitoryApplication', stage: 'counselor', endpoint: '/api/dormitory-services/applications/item-1/counselor-review', body: { approved: true, comment: null }, progress: true }, { 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 }, { type: 'CourseExemption', stage: null, endpoint: '/api/approvals/exemptions/item-1/approve', body: null, progress: true }, + { type: 'CourseAdjustment', stage: null, endpoint: '/api/course-adjustments/item-1/approve', body: null, progress: true }, ] for (const scenario of cases) test(`${scenario.type} can be ${scenario.reject ? 'rejected' : 'approved'} from the approval center`, async ({ page }) => { @@ -41,7 +42,7 @@ for (const scenario of cases) test(`${scenario.type} can be ${scenario.reject ? return route.fulfill({ status: 204 }) } if (url.pathname === `/api/approvals/progress/${scenario.type}/item-1`) - return route.fulfill({ json: { type: scenario.type, id: 'item-1', historyIncomplete: scenario.type === 'StudentStatusChange', steps: [{ kind: 'submitted', time: '2026-11-01T00:00:00Z', comment: null }] } }) + return route.fulfill({ json: { type: scenario.type, id: 'item-1', historyIncomplete: scenario.type === 'StudentStatusChange', steps: [{ kind: scenario.type === 'TeacherCourseApplication' ? 'started' : 'submitted', time: '2026-11-01T00:00:00Z', comment: null }] } }) 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: {} }) @@ -57,8 +58,8 @@ for (const scenario of cases) test(`${scenario.type} can be ${scenario.reject ? if (scenario.progress) { await card.getByRole('button', { name: '办理进度' }).click() const dialog = page.getByRole('dialog') - await expect(dialog.getByText('已提交')).toBeVisible() - if (scenario.type === 'StudentStatusChange') await expect(dialog.getByText('该申请较早的审核详情未留存。')).toBeVisible() + await expect(dialog.getByText(scenario.type === 'TeacherCourseApplication' ? '本次申报开始' : '已提交')).toBeVisible() + if (scenario.type === 'StudentStatusChange') await expect(dialog.getByText('该申请部分办理详情未留存。')).toBeVisible() await dialog.locator('.el-dialog__headerbtn').click() } if (scenario.reject) { diff --git a/web/src/i18n/messages/en-US.ts b/web/src/i18n/messages/en-US.ts index aef0378..72571f1 100644 --- a/web/src/i18n/messages/en-US.ts +++ b/web/src/i18n/messages/en-US.ts @@ -1,6 +1,7 @@ export default { + approvalTeacherCurrentCycle: 'Only the current course application cycle is shown.', approvalOverdue: { only: 'Waiting longer than', hours: 'hours', hint: 'Measured from the time shown on each item. The threshold is saved in this browser.' }, - approvalProgress: { title: 'Progress', submitted: 'Submitted', approved: 'Approved', rejected: 'Rejected', cancelled: 'Withdrawn', counselorApproved: 'Counselor review approved', counselorRejected: 'Counselor review rejected', collegeApproved: 'College review approved', collegeRejected: 'College review rejected', finalApproved: 'Final review approved', finalRejected: 'Final review rejected', legacyReviewed: 'Most recent review', incomplete: 'Earlier review details are unavailable for this request.' }, + approvalProgress: { title: 'Progress', submitted: 'Submitted', started: 'Current request started', created: 'Draft created', approved: 'Approved', rejected: 'Rejected', cancelled: 'Withdrawn', counselorApproved: 'Counselor review approved', counselorRejected: 'Counselor review rejected', collegeApproved: 'College review approved', collegeRejected: 'College review rejected', finalApproved: 'Final review approved', finalRejected: 'Final review rejected', dormitoryApproved: 'Dormitory review approved', dormitoryRejected: 'Dormitory review rejected', legacyReviewed: 'Most recent review', incomplete: 'Some event details are unavailable for this request.' }, approvalCenterAdjustment: 'Class adjustment', approvalCenterClearance: 'Graduation clearance', approvalCenterCounselorStage: 'Counselor review', diff --git a/web/src/i18n/messages/zh-CN.ts b/web/src/i18n/messages/zh-CN.ts index 6841c6f..f85db6d 100644 --- a/web/src/i18n/messages/zh-CN.ts +++ b/web/src/i18n/messages/zh-CN.ts @@ -1,6 +1,7 @@ export default { + approvalTeacherCurrentCycle: '这里只展示当前课程申报轮次。', approvalOverdue: { only: '只看等待超过', hours: '小时', hint: '按每条事项显示的时间计算,阈值保存在当前浏览器。' }, - approvalProgress: { title: '办理进度', submitted: '已提交', approved: '审核通过', rejected: '审核驳回', cancelled: '已撤回', counselorApproved: '辅导员审核通过', counselorRejected: '辅导员审核驳回', collegeApproved: '学院审核通过', collegeRejected: '学院审核驳回', finalApproved: '校级审核通过', finalRejected: '校级审核驳回', legacyReviewed: '最近一次审核', incomplete: '该申请较早的审核详情未留存。' }, + approvalProgress: { title: '办理进度', submitted: '已提交', started: '本次申报开始', created: '已创建草稿', approved: '审核通过', rejected: '审核驳回', cancelled: '已撤回', counselorApproved: '辅导员审核通过', counselorRejected: '辅导员审核驳回', collegeApproved: '学院审核通过', collegeRejected: '学院审核驳回', finalApproved: '校级审核通过', finalRejected: '校级审核驳回', dormitoryApproved: '宿舍管理审核通过', dormitoryRejected: '宿舍管理审核驳回', legacyReviewed: '最近一次审核', incomplete: '该申请部分办理详情未留存。' }, approvalCenterAdjustment: '调停课', approvalCenterClearance: '毕业离校办理', approvalCenterCounselorStage: '辅导员审核', diff --git a/web/src/views/ApprovalCenterView.vue b/web/src/views/ApprovalCenterView.vue index 78f6c14..4a6a58e 100644 --- a/web/src/views/ApprovalCenterView.vue +++ b/web/src/views/ApprovalCenterView.vue @@ -99,7 +99,7 @@ const progressDialog = ref(false) const progressSteps = ref<{ kind: string; time: string; comment?: string | null }[]>([]) const progressType = ref('') const progressIncomplete = ref(false) -const progressTypes = new Set(['CourseExemption', 'DeferredExam', 'CourseSubstitution', 'GradeModification', 'StudentStatusChange']) +const progressTypes = new Set(['CourseExemption', 'DeferredExam', 'CourseSubstitution', 'GradeModification', 'StudentStatusChange', 'TeacherCourseApplication', 'ClassroomReservation', 'CourseAdjustment', 'DormitoryApplication']) const enrolledCourses = ref([]) const gradeRecords = ref([]) @@ -366,10 +366,10 @@ async function openProgress(type: string, id: string) { function progressLabel(kind: string) { const labels: Record = { - submitted: 'submitted', approved: 'approved', rejected: 'rejected', cancelled: 'cancelled', + submitted: 'submitted', started: 'started', created: 'created', approved: 'approved', rejected: 'rejected', cancelled: 'cancelled', counselorApproved: 'counselorApproved', counselorRejected: 'counselorRejected', legacyReviewed: 'legacyReviewed', collegeApproved: 'collegeApproved', collegeRejected: 'collegeRejected', - finalApproved: 'finalApproved', finalRejected: 'finalRejected', + finalApproved: 'finalApproved', finalRejected: 'finalRejected', dormitoryApproved: 'dormitoryApproved', dormitoryRejected: 'dormitoryRejected', } return t(`approvalProgress.${labels[kind] ?? 'submitted'}`) } @@ -455,7 +455,7 @@ function approvalLabel(item: any) { if (extra[item.type]) return t(`approvalCenterExtra.${extra[item.type]}`) if (item.type === 'CourseAdjustment') { const adjustments: Record = { '调课': 'k0', '停课': 'k1', '补课': 'k2', '代课': 'k3' } - return adjustments[item.label] ? t(`adjustmentBatch.${adjustments[item.label]}`) : item.label + return adjustments[item.label] ? t(`adjustmentBatch.${adjustments[item.label]}`) : item.label || t('approvalCenterAdjustment') } return types[item.type] ? t(`approvalBatch.${types[item.type]}`) : item.label } @@ -520,8 +520,8 @@ function courseScheduleText(course: CourseOption) { onMounted(async () => { if (isManager.value && (route.query.tab === 'pending' || targetApprovalId.value)) tab.value = 'pending' await load() - if (route.query.progressType === 'StudentStatusChange' && typeof route.query.progressId === 'string') - await openProgress('StudentStatusChange', route.query.progressId) + if (typeof route.query.progressType === 'string' && progressTypes.has(route.query.progressType) && typeof route.query.progressId === 'string') + await openProgress(route.query.progressType, route.query.progressId) }) @@ -554,6 +554,7 @@ onMounted(async () => { +
  1. {{ progressLabel(step.kind) }} @@ -654,6 +655,7 @@ onMounted(async () => { {{ t('businessLabels.approve') }}
    + {{ t('approvalProgress.title') }} { - +