feat: replace tenants with organization management

This commit is contained in:
2026-07-10 21:27:26 +08:00
parent 8ed1682b90
commit 8f0991a51f
49 changed files with 1292 additions and 698 deletions

View File

@@ -191,7 +191,7 @@ export class RoomsService {
{ checkInDate: LessThanOrEqual(targetDate), checkOutDate: MoreThanOrEqual(targetDate) },
]
: { checkOutDate: IsNull() },
relations: ['student', 'tenant'],
relations: ['student', 'student.organization', 'responsibleOrganization'],
order: { checkInDate: 'ASC' },
});
@@ -212,11 +212,11 @@ export class RoomsService {
checkInDate: occ.checkInDate,
billingStartDate: occ.billingStartDate,
days,
organization: occ.student?.organization || null,
organization: occ.student?.organization?.name || null,
supervisor: occ.student?.supervisor || null,
tenantId: occ.tenantId || null,
tenantName: occ.tenant?.name || null,
tenantColor: occ.tenant?.color || null,
organizationId: occ.responsibleOrganizationId || null,
organizationName: occ.responsibleOrganization?.name || null,
organizationColor: occ.responsibleOrganization?.color || null,
});
}
@@ -250,9 +250,9 @@ export class RoomsService {
const allSameOrg = occ.every((o: any) => o.organization && o.organization === orgs[0]);
orgLabel = allSameOrg ? `均为${orgs[0]}人员` : `存在${orgs.join('、')}人员`;
}
const tenantColors = [...new Set(occ.map((o: any) => o.tenantColor).filter(Boolean))];
const tenantColor: string | null = tenantColors.length === 1 ? tenantColors[0] : null;
const tenantIds = [...new Set(occ.map((o: any) => o.tenantId).filter(Boolean))];
const organizationColors = [...new Set(occ.map((o: any) => o.organizationColor).filter(Boolean))];
const organizationColor: string | null = organizationColors.length === 1 ? organizationColors[0] : null;
const organizationIds = [...new Set(occ.map((o: any) => o.organizationId).filter(Boolean))];
return {
id: room.id,
roomNumber: room.roomNumber,
@@ -265,16 +265,16 @@ export class RoomsService {
occupiedBeds: bedMap.get(room.id)?.occupied ?? 0,
occupants: occ,
orgLabel,
tenantColor,
tenantIds,
organizationColor,
organizationIds,
};
}),
// 当前视图内出现过的租赁方,供筛选下拉使用
tenants: [
// 当前视图内出现过的负责机构,供筛选下拉使用
organizations: [
...new Map(
occupancies
.filter((o) => o.tenantId && o.tenant)
.map((o) => [o.tenantId, { id: o.tenantId, name: o.tenant.name, color: o.tenant.color || null }]),
.filter((o) => o.responsibleOrganizationId && o.responsibleOrganization)
.map((o) => [o.responsibleOrganizationId, { id: o.responsibleOrganizationId, name: o.responsibleOrganization.name, color: o.responsibleOrganization.color || null }]),
).values(),
].sort((a, b) => a.name.localeCompare(b.name)),
};