import { MyPageContainer, usePageTabs } from '@/common'; import { Apis } from '@/gen/Apis'; import { ProCard } from '@ant-design/pro-components'; import { useParams } from '@umijs/max'; import { Badge, Tabs } from 'antd'; import { useEffect, useState } from 'react'; import HouseInfo from './components/HouseInfo'; import OccupantsHistory from './components/OccupantsHistory'; import OccupantsNow from './components/OccupantsNow'; import RegistersList from './components/RegistersList'; export default function Show({ title = '房屋档案' }) { const { id } = useParams<{ id: string }>(); const [data, setShow] = useState({}); const [pendingCount, setPendingCount] = useState(0); // 注册标签页 const { addTab } = usePageTabs({ tabKey: `asset-house-detail-${id}`, tabLabel: `${data?.name}档案` || title, }); const loadShow = () => { let paramsId: any = { id: id ?? 0 }; Apis.Asset.AssetHouses.Show(paramsId).then((res) => { setShow(res?.data); // 更新标签页标题 if (res?.data?.full_name) { addTab({ key: `asset-house-detail-${id}`, label: title, path: `/archive/${id}`, }); } }); }; const loadPendingCount = () => { Apis.Archive.HouseRegisters.List({ asset_houses_id: Number(id), status: 'Pending', }).then((res) => { setPendingCount(res?.meta?.total || 0); }); }; useEffect(() => { loadShow(); loadPendingCount(); }, [id]); let items = [ { label: '当前客户', key: '1', closable: false, children: ( { loadShow(); loadPendingCount(); }} /> ), }, { label: '历史客户', key: '2', closable: false, children: , }, { label: (
操作记录 {pendingCount > 0 && ( )}
), key: '3', closable: false, children: ( ), }, ]; return ( ); }