104 lines
2.7 KiB
TypeScript
Raw Normal View History

2025-06-30 15:55:47 +08:00
import {
MyButtons,
MyColumns,
MyPageContainer,
2025-06-30 15:55:47 +08:00
MyProTableProps,
usePageTabs,
2025-06-30 15:55:47 +08:00
} from '@/common';
2025-06-30 14:24:39 +08:00
import { Apis } from '@/gen/Apis';
2025-06-30 15:55:47 +08:00
import { OrganizationsTypeEnum } from '@/gen/Enums';
2025-06-30 14:24:39 +08:00
import { ProTable } from '@ant-design/pro-components';
import { useNavigate } from '@umijs/max';
2025-06-30 15:55:47 +08:00
import { Space } from 'antd';
import OrganizationChange from './modals/OrganizationChange';
import OrganizationCreate from './modals/OrganizationCreate';
import OrganizationUpdate from './modals/OrganizationUpdate';
2025-06-30 14:24:39 +08:00
export default function Index({ title = '组织列表' }) {
const navigate = useNavigate();
// 注册当前页面为标签页
usePageTabs({
tabKey: 'company-organizations',
tabLabel: title,
});
2025-06-30 14:24:39 +08:00
return (
<MyPageContainer
title={title}
enableTabs={true}
tabKey="company-organizations"
tabLabel={title}
>
2025-06-30 14:24:39 +08:00
<ProTable
{...MyProTableProps.props}
request={async (params, sort) =>
MyProTableProps.request(
params,
2025-06-30 14:24:39 +08:00
sort,
Apis.Company.Organizations.TreeList,
2025-06-30 14:24:39 +08:00
)
}
toolBarRender={(action) => [
<OrganizationCreate
2025-06-30 14:24:39 +08:00
key="Create"
reload={action?.reload}
2025-09-19 00:16:07 +08:00
title={'组织'}
2025-06-30 14:24:39 +08:00
/>,
]}
columns={[
2025-07-16 10:18:01 +08:00
{
2025-09-19 18:55:51 +08:00
title: '组织ID',
dataIndex: 'id',
search: false,
2025-07-16 10:18:01 +08:00
},
2025-07-01 16:21:27 +08:00
{
2025-09-19 18:55:51 +08:00
title: '机构',
dataIndex: ['company', 'name'],
2025-07-01 16:21:27 +08:00
search: false,
},
{
title: '组织名称',
dataIndex: 'name',
},
MyColumns.EnumTag({
title: '组织类型',
dataIndex: 'type',
valueEnum: OrganizationsTypeEnum,
search: false,
}),
2025-06-30 14:24:39 +08:00
{
2025-06-30 15:55:47 +08:00
title: '上级组织',
dataIndex: ['organization_parent', 'name'],
2025-07-01 16:21:27 +08:00
search: false,
2025-06-30 15:55:47 +08:00
},
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
<OrganizationUpdate
item={{ ...item, companies_id: item?.id }}
2025-07-17 13:58:54 +08:00
reload={action?.reload}
title="组织"
/>
<OrganizationChange
item={{ ...item, companies_id: item?.id }}
2025-06-30 15:55:47 +08:00
reload={action?.reload}
title="组织"
/>
<MyButtons.Delete
onConfirm={() =>
Apis.Company.Organizations.Delete({ id: item.id }).then(
() => action?.reload(),
)
}
/>
</Space>
),
}),
2025-06-30 14:24:39 +08:00
]}
/>
</MyPageContainer>
2025-06-30 14:24:39 +08:00
);
}