feat: replace tenants with organization management
This commit is contained in:
@@ -11,8 +11,8 @@ function getCardStyle(room: any): React.CSSProperties {
|
||||
else if (room.currentCount === 0) base = { background: '#f6ffed', borderColor: '#b7eb8f' };
|
||||
else if (room.currentCount >= room.capacity) base = { background: '#fff2f0', borderColor: '#ffccc7' };
|
||||
else base = { background: '#e6f4ff', borderColor: '#91caff' };
|
||||
if (room.tenantColor) {
|
||||
return { ...base, background: `color-mix(in srgb, ${room.tenantColor} 15%, ${base.background || '#fff'} 85%)` };
|
||||
if (room.organizationColor) {
|
||||
return { ...base, background: `color-mix(in srgb, ${room.organizationColor} 15%, ${base.background || '#fff'} 85%)` };
|
||||
}
|
||||
return base;
|
||||
}
|
||||
@@ -24,18 +24,18 @@ function getStatusLabel(room: any) {
|
||||
return <Tag color="processing">部分入住</Tag>;
|
||||
}
|
||||
|
||||
function getTenantTags(occupants: any[]) {
|
||||
const tenantList = [
|
||||
function getOrganizationTags(occupants: any[]) {
|
||||
const organizationList = [
|
||||
...new Map(
|
||||
occupants
|
||||
.filter((o: any) => o.tenantName)
|
||||
.map((o: any) => [o.tenantId, { name: o.tenantName, color: o.tenantColor }]),
|
||||
.filter((o: any) => o.organizationName)
|
||||
.map((o: any) => [o.organizationId, { name: o.organizationName, color: o.organizationColor }]),
|
||||
).values(),
|
||||
] as { name: string; color: string | null }[];
|
||||
if (tenantList.length === 0) return null;
|
||||
if (organizationList.length === 0) return null;
|
||||
return (
|
||||
<div className="room-card-tag-wrapper" style={{ marginBottom: 6 }}>
|
||||
{tenantList.map((t) => (
|
||||
{organizationList.map((t) => (
|
||||
<Tag
|
||||
key={t.name}
|
||||
color={t.color || 'gold'}
|
||||
@@ -53,7 +53,7 @@ const RoomVisualPage: React.FC = () => {
|
||||
const [data, setData] = useState<any>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [selectedBuilding, setSelectedBuilding] = useState<string>('all');
|
||||
const [selectedTenant, setSelectedTenant] = useState<number | 'all'>('all');
|
||||
const [selectedOrganization, setSelectedOrganization] = useState<number | 'all'>('all');
|
||||
const [detailRoom, setDetailRoom] = useState<any>(null);
|
||||
const [asOf, setAsOf] = useState<Dayjs | null>(null);
|
||||
|
||||
@@ -80,7 +80,7 @@ const RoomVisualPage: React.FC = () => {
|
||||
|
||||
const rooms = data.rooms.filter((r: any) => {
|
||||
if (selectedBuilding !== 'all' && r.building !== selectedBuilding) return false;
|
||||
if (selectedTenant !== 'all' && !(r.tenantIds || []).includes(selectedTenant)) return false;
|
||||
if (selectedOrganization !== 'all' && !(r.organizationIds || []).includes(selectedOrganization)) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ const RoomVisualPage: React.FC = () => {
|
||||
const availableBedsCount = totalBeds - occupiedBeds;
|
||||
const fullRooms = rooms.filter((r: any) => r.currentCount >= r.capacity).length;
|
||||
|
||||
/* getCardStyle, getStatusLabel, getTenantTags are now standalone functions outside the component */
|
||||
/* getCardStyle, getStatusLabel, getOrganizationTags are now standalone functions outside the component */
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -128,12 +128,12 @@ const RoomVisualPage: React.FC = () => {
|
||||
]}
|
||||
/>
|
||||
<Select
|
||||
value={selectedTenant}
|
||||
onChange={setSelectedTenant}
|
||||
value={selectedOrganization}
|
||||
onChange={setSelectedOrganization}
|
||||
style={{ width: 180 }}
|
||||
options={[
|
||||
{ value: 'all', label: '全部租赁方' },
|
||||
...(data.tenants || []).map((t: any) => ({
|
||||
{ value: 'all', label: '全部机构' },
|
||||
...(data.organizations || []).map((t: any) => ({
|
||||
value: t.id,
|
||||
label: (
|
||||
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
|
||||
@@ -215,10 +215,10 @@ const RoomVisualPage: React.FC = () => {
|
||||
}}
|
||||
>
|
||||
<span style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 16, fontWeight: 600, color: '#1d1d1f' }}>
|
||||
{room.tenantColor && (
|
||||
{room.organizationColor && (
|
||||
<span style={{
|
||||
width: 10, height: 10, borderRadius: '50%',
|
||||
backgroundColor: room.tenantColor, display: 'inline-block',
|
||||
backgroundColor: room.organizationColor, display: 'inline-block',
|
||||
flexShrink: 0,
|
||||
}} />
|
||||
)}
|
||||
@@ -257,7 +257,7 @@ const RoomVisualPage: React.FC = () => {
|
||||
</Tag>
|
||||
</div>
|
||||
)}
|
||||
{getTenantTags(room.occupants)}
|
||||
{getOrganizationTags(room.occupants)}
|
||||
{room.occupants.length > 0 && (
|
||||
<div className="room-card-tag-wrapper" style={{ borderTop: '1px solid rgba(0,0,0,0.06)', paddingTop: 6 }}>
|
||||
{room.occupants.slice(0, 4).map((o: any) => (
|
||||
@@ -303,10 +303,10 @@ const RoomVisualPage: React.FC = () => {
|
||||
位置:{detailRoom.building || '-'} {detailRoom.floor ? `${detailRoom.floor}F` : ''}
|
||||
</div>
|
||||
|
||||
{detailRoom.tenantColor && (
|
||||
{detailRoom.organizationColor && (
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<Tag color={detailRoom.tenantColor}>
|
||||
{detailRoom.occupants[0]?.tenantName || '租户'}
|
||||
<Tag color={detailRoom.organizationColor}>
|
||||
{detailRoom.occupants[0]?.organizationName || '机构'}
|
||||
</Tag>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user