feat: 增加宿舍查寝功能

This commit is contained in:
2026-07-22 10:55:48 +08:00
parent c888dce065
commit 54e283b687
19 changed files with 923 additions and 18 deletions

View File

@@ -0,0 +1,25 @@
export interface InspectionOccupant {
occupancyId: number;
inspectionStatus?: 'present' | 'absent' | null;
}
export function getInitialPresentOccupancyIds(
occupants: InspectionOccupant[],
submitted: boolean,
): number[] {
if (!submitted) return [];
return occupants
.filter((occupant) => occupant.inspectionStatus === 'present')
.map((occupant) => occupant.occupancyId);
}
export function togglePresentOccupancy(
currentIds: number[],
occupancyId: number,
present: boolean,
): number[] {
const next = new Set(currentIds);
if (present) next.add(occupancyId);
else next.delete(occupancyId);
return [...next];
}