| | |
| | | import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; |
| | | import type { Key } from 'react'; |
| | | import { PlusOutlined } from '@ant-design/icons'; |
| | | import { ProTable } from '@ant-design/pro-components'; |
| | | import type { ActionType } from '@ant-design/pro-components'; |
| | | import { App as AntdApp, Button } from 'antd'; |
| | | import { App as AntdApp } from 'antd'; |
| | | import { createDepartmentColumns } from './columns'; |
| | | import DepartmentFormDrawer from './components/DepartmentFormDrawer'; |
| | | import { deleteOrg, getLeaderOptions, getOrgTree, toggleOrgStatus } from './server'; |
| | | import { deleteOrg, getLeaderOptions, getOrgTree, toggleOrgStatus } from './service'; |
| | | import type { DepartmentListQuery, OrgVO } from './types'; |
| | | import { collectOrgIds, filterOrgTree } from './utils'; |
| | | |
| | |
| | | |
| | | const loadLeaders = async () => { |
| | | try { |
| | | const result = await getLeaderOptions(); |
| | | const result = await getLeaderOptions({ page: 1, size: 200 }); |
| | | if (!active) return; |
| | | |
| | | setLeaderOptions( |
| | |
| | | |
| | | const data = filterOrgTree(list, params); |
| | | return { data, total: data.length, success: true }; |
| | | }, []); |
| | | |
| | | const openCreateRoot = useCallback(() => { |
| | | setActiveOrg(null); |
| | | setParentId(undefined); |
| | | setFormMode('create'); |
| | | setFormOpen(true); |
| | | }, []); |
| | | |
| | | const openCreateChild = useCallback((record: OrgVO) => { |
| | |
| | | expandedRowKeys, |
| | | onExpandedRowsChange: (keys) => setExpandedRowKeys([...keys]), |
| | | }} |
| | | toolBarRender={() => [ |
| | | <Button key="create" type="primary" icon={<PlusOutlined />} onClick={openCreateRoot}> |
| | | 新增部门 |
| | | </Button>, |
| | | ]} |
| | | request={fetchDepartments} |
| | | /> |
| | | |
| | |
| | | record={activeOrg} |
| | | parentId={parentId} |
| | | orgTree={orgTree} |
| | | leaderOptions={leaderOptions} |
| | | onClose={closeForm} |
| | | onSuccess={handleFormSuccess} |
| | | /> |