83 lines
2.2 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';
2025-06-30 14:24:39 +08:00
import OrganizationsCreate from '../modals/OrganizationsCreate';
2025-06-30 15:55:47 +08:00
import OrganizationsUpdate from '../modals/OrganizationsUpdate';
2025-06-30 14:24:39 +08:00
export default function Organizations(props: MyBetaModalFormProps) {
return (
<>
<ProTable
{...MyProTableProps.props}
search={false}
request={async (params, sort) =>
MyProTableProps.request(
{ ...params, companies_id: props?.item?.id },
sort,
Apis.Company.Organizations.List,
)
}
toolBarRender={(action) => [
<OrganizationsCreate
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="组织"
/>,
]}
options={false}
columns={[
MyColumns.ID(),
{
2025-06-30 15:55:47 +08:00
title: '上级组织',
dataIndex: ['organization_parent', 'name'],
},
{
title: '组织',
2025-06-30 14:24:39 +08:00
dataIndex: 'name',
},
2025-06-30 15:55:47 +08:00
MyColumns.EnumTag({
title: '类型',
dataIndex: 'type',
valueEnum: OrganizationsTypeEnum,
}),
{
title: '负责人',
dataIndex: ['manager', 'name'],
},
{
title: '联系电话',
dataIndex: 'manager_phone',
},
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
<OrganizationsUpdate
item={{ ...item, companies_id: props?.item?.id }}
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
]}
/>
</>
);
}