82 lines
2.2 KiB
TypeScript
Raw Normal View History

import { MyPageContainer, usePageTabs } from '@/common';
2025-06-30 14:24:39 +08:00
import { Apis } from '@/gen/Apis';
import { ProCard } from '@ant-design/pro-components';
import { useParams } from '@umijs/max';
import { Tabs } from 'antd';
import { useEffect, useState } from 'react';
2025-06-30 16:07:20 +08:00
import ComponentsInfo from './components/ComponentsInfo';
2025-07-01 11:35:54 +08:00
import Employees from './components/Employees';
2025-06-30 14:24:39 +08:00
import Organizations from './components/Organizations';
2025-07-01 10:40:00 +08:00
import Positions from './components/Positions';
import Projects from './components/Projects';
2025-07-16 10:18:01 +08:00
import ReceiptAccounts from './components/ReceiptAccounts';
export default function Show({ title }: { title?: string } = {}) {
2025-06-30 14:24:39 +08:00
const { id } = useParams<{ id: string }>();
const [data, setShow] = useState<any>({});
// 注册当前页面为标签页
const { addTab } = usePageTabs({
tabKey: `company-show-${id}`,
tabLabel: data?.short_name || title || '资产详情',
});
2025-06-30 14:24:39 +08:00
const loadShow = () => {
let paramsId: any = { id: id ?? 0 };
Apis.Company.Companies.Show(paramsId).then((res) => {
setShow(res?.data);
// 更新标签页名称为API返回的name
if (res?.data?.short_name) {
addTab({
key: `company-show-${id}`,
label: res.data.short_name,
path: `/company/${id}`,
});
}
2025-06-30 14:24:39 +08:00
});
};
useEffect(() => {
loadShow();
}, [id]);
let items = [
{
label: '项目管理',
2025-06-30 14:24:39 +08:00
key: '1',
closable: false,
children: <Projects item={data} />,
2025-06-30 16:07:20 +08:00
},
{
label: '组织管理',
2025-06-30 16:07:20 +08:00
key: '2',
closable: false,
children: <Organizations item={data} />,
2025-07-01 10:40:00 +08:00
},
{
label: '岗位管理',
2025-07-01 10:40:00 +08:00
key: '3',
closable: false,
children: <Positions item={data} />,
2025-06-30 14:24:39 +08:00
},
2025-07-01 10:40:00 +08:00
{
label: '员工管理',
key: '4',
closable: false,
2025-07-01 11:35:54 +08:00
children: <Employees item={data} />,
2025-07-01 10:40:00 +08:00
},
2025-07-16 10:18:01 +08:00
{
label: '收款账号',
key: '5',
2025-07-16 10:18:01 +08:00
closable: false,
children: <ReceiptAccounts item={data} />,
},
2025-06-30 14:24:39 +08:00
];
return (
<MyPageContainer title={title}>
<ComponentsInfo item={data} />
2025-06-30 14:24:39 +08:00
<ProCard>
<Tabs type="card" items={data?.id ? items : []} />
</ProCard>
</MyPageContainer>
);
}