pay-admin/src/pages/company/list/table/Organizations.tsx

95 lines
2.8 KiB
TypeScript
Raw Normal View History

2025-06-30 15:55:47 +08:00
import {
MyBetaModalFormProps,
MyButtons,
MyColumns,
MyProTableProps,
} 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';
2025-06-30 15:55:47 +08:00
import { Space } from 'antd';
import NextOrganizationChange from '../../organizations/modals/NextOrganizationChange';
import OrganizationChange from '../../organizations/modals/OrganizationChange';
import OrganizationCreate from '../../organizations/modals/OrganizationCreate';
import OrganizationUpdate from '../../organizations/modals/OrganizationUpdate';
2025-06-30 14:24:39 +08:00
export default function Organizations(props: MyBetaModalFormProps) {
return (
<>
<ProTable
{...MyProTableProps.props}
request={async (params, sort) =>
MyProTableProps.request(
{ ...params, companies_id: props?.item?.id },
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-06-30 15:55:47 +08:00
item={props?.item}
2025-06-30 14:24:39 +08:00
title="组织"
/>,
]}
// search={false}
2025-08-27 11:24:29 +08:00
// options={false}
2025-06-30 14:24:39 +08:00
columns={[
2025-07-16 10:18:01 +08:00
{
title: '组织名称',
dataIndex: 'name',
},
2025-07-01 16:21:27 +08:00
{
title: '组织ID',
dataIndex: 'id',
search: false,
},
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}
2025-07-17 13:58:54 +08:00
reload={action?.reload}
title="组织"
/>
{item?.type !== OrganizationsTypeEnum.Group.value && (
<OrganizationChange
item={{ ...item, companies_id: props?.item?.companies_id }}
reload={action?.reload}
title="组织"
/>
)}
<NextOrganizationChange
item={{ ...item, companies_id: item?.companies_id }}
2025-06-30 15:55:47 +08:00
reload={action?.reload}
title="下级组织"
2025-06-30 15:55:47 +08:00
/>
<MyButtons.Delete
onConfirm={() =>
Apis.Company.Organizations.Delete({ id: item.id }).then(
() => action?.reload(),
)
}
/>
</Space>
),
}),
2025-06-30 14:24:39 +08:00
]}
/>
</>
);
}