105 lines
3.0 KiB
TypeScript
Raw Normal View History

import { MyPageContainer, usePageTabs } from '@/common';
2025-06-29 18:42:50 +08:00
import { Apis } from '@/gen/Apis';
import { ProCard } from '@ant-design/pro-components';
import { useParams } from '@umijs/max';
import { Space, Tabs } from 'antd';
2025-06-29 18:42:50 +08:00
import { useEffect, useState } from 'react';
2025-07-16 10:18:01 +08:00
import AssetAccounts from './components/AssetAccounts';
2025-06-29 18:42:50 +08:00
import MyAssetBuildings from './components/AssetBuildings';
2025-06-30 18:42:21 +08:00
import AssetGrid from './components/AssetGrid';
2025-06-30 14:20:46 +08:00
import AssetInfo from './components/AssetInfo';
import ChargeStandard from './components/ChargeStandard';
import BindCompany from './components/modals/BindCompany';
import AssetUpdate from './modals/AssetUpdate';
2025-06-30 18:42:21 +08:00
export default function Show({ title }: { title?: string } = {}) {
2025-06-29 18:42:50 +08:00
const { id } = useParams<{ id: string }>();
const [data, setShow] = useState<any>({});
// 注册当前页面为标签页
const { addTab } = usePageTabs({
tabKey: `asset-show-${id}`,
2025-08-27 11:24:29 +08:00
tabLabel: data?.name || title || '项目详情',
});
2025-06-29 18:42:50 +08:00
const loadShow = () => {
let paramsId: any = { id: id ?? 0 };
Apis.Asset.AssetProjects.Show(paramsId).then((res) => {
setShow(res?.data);
// 更新标签页名称为API返回的name
if (res?.data?.name) {
addTab({
key: `asset-show-${id}`,
label: res.data.name,
path: `/asset/${id}`,
});
}
2025-06-29 18:42:50 +08:00
});
};
useEffect(() => {
loadShow();
}, [id]);
let items = [
// {
// label: '基本信息',
// key: 'info',
// closable: false,
// children: <AssetInfo item={data} reload={() => loadShow()} />,
// },
2025-06-29 18:42:50 +08:00
{
label: '楼栋管理',
key: 'asset_buildings',
closable: false,
children: <MyAssetBuildings item={data} />,
},
2025-06-30 18:42:21 +08:00
{
label: '楼栋划分',
2025-06-30 18:42:21 +08:00
key: 'grid',
closable: false,
children: <AssetGrid item={data} />,
},
{
label: '收费标准',
key: 'charge_standard',
closable: false,
children: <ChargeStandard item={data} />,
},
2025-07-16 10:18:01 +08:00
{
label: '收款账号',
key: 'asset_accounts',
closable: false,
children: <AssetAccounts item={data} />,
},
2025-06-30 14:20:46 +08:00
// {
// label: '车位管理',
// key: 'carport',
// closable: false,
// children: <MyAssetBuildings item={data} />,
// },
2025-06-29 18:42:50 +08:00
];
return (
2025-08-27 11:24:29 +08:00
<MyPageContainer title={data?.name || title || '项目详情'}>
<ProCard
title={`${data?.name} (${data?.alias_name})`}
extra={
<Space>
<AssetInfo
item={{ ...data, type: 'primary' }}
title="查看"
reload={loadShow}
/>
<AssetUpdate item={data} title="项目" reload={loadShow} />
<BindCompany item={data} title="机构" reload={loadShow} />
</Space>
}
>
<div>* </div>
</ProCard>
2025-06-29 18:42:50 +08:00
<ProCard>
<Tabs type="card" items={data?.id ? items : []} />
</ProCard>
</MyPageContainer>
);
}