|
|
@@ -1,7 +1,8 @@
|
|
|
import { fetchDeleteDept } from '@/services/dept';
|
|
|
-import { PageContainer } from '@ant-design/pro-components';
|
|
|
+import { ReloadOutlined } from '@ant-design/icons';
|
|
|
+import { PageContainer, ProCard } from '@ant-design/pro-components';
|
|
|
import { useIntl } from '@umijs/max';
|
|
|
-import { Button, Empty, Popconfirm, Space, Spin, Tree, message } from 'antd';
|
|
|
+import { Button, Empty, Popconfirm, Space, Spin, Tooltip, Tree, message } from 'antd';
|
|
|
import type { DataNode } from 'antd/es/tree';
|
|
|
import { DeptForm } from './components/Form';
|
|
|
import { DeptUserTable } from './components/UserTable';
|
|
|
@@ -31,21 +32,23 @@ export default function DeptPage() {
|
|
|
const renderTitle = (node: API.DeptItem) => (
|
|
|
<Space>
|
|
|
<span>{node.name}</span>
|
|
|
- <DeptForm
|
|
|
- mode="edit"
|
|
|
- initialValues={node}
|
|
|
- onSuccess={loadData}
|
|
|
- trigger={<a className="text-xs">编辑</a>}
|
|
|
- />
|
|
|
- <DeptForm
|
|
|
- mode="add"
|
|
|
- initialValues={{ parentId: node.id }}
|
|
|
- onSuccess={loadData}
|
|
|
- trigger={<a className="text-xs">新建子部门</a>}
|
|
|
- />
|
|
|
- <Popconfirm title="确认删除?" onConfirm={() => handleDelete(node.id)}>
|
|
|
- <a className="text-xs text-red-500">删除</a>
|
|
|
- </Popconfirm>
|
|
|
+ <Space onClick={(e) => e.stopPropagation()}>
|
|
|
+ <DeptForm
|
|
|
+ mode="edit"
|
|
|
+ initialValues={node}
|
|
|
+ onSuccess={loadData}
|
|
|
+ trigger={<a className="text-xs">编辑</a>}
|
|
|
+ />
|
|
|
+ <DeptForm
|
|
|
+ mode="add"
|
|
|
+ initialValues={{ parentId: node.id }}
|
|
|
+ onSuccess={loadData}
|
|
|
+ trigger={<a className="text-xs">新建子部门</a>}
|
|
|
+ />
|
|
|
+ <Popconfirm title={`确认删除「${node.name}」?`} onConfirm={() => handleDelete(node.id)}>
|
|
|
+ <a className="text-xs text-(--ant-color-error)">删除</a>
|
|
|
+ </Popconfirm>
|
|
|
+ </Space>
|
|
|
</Space>
|
|
|
);
|
|
|
|
|
|
@@ -58,38 +61,49 @@ export default function DeptPage() {
|
|
|
|
|
|
return (
|
|
|
<PageContainer title={intl.formatMessage({ id: 'admin.dept.title' })}>
|
|
|
- <div className="mb-4">
|
|
|
- <DeptForm
|
|
|
- mode="add"
|
|
|
- initialValues={{ parentId: 0 }}
|
|
|
- onSuccess={loadData}
|
|
|
- trigger={
|
|
|
- <Button type="primary">{intl.formatMessage({ id: 'admin.dept.createRoot' })}</Button>
|
|
|
- }
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className="flex gap-4">
|
|
|
- <div className="w-80 shrink-0 border border-gray-100 rounded p-3 bg-white">
|
|
|
- <Spin spinning={loading}>
|
|
|
- {treeData.length > 0 && (
|
|
|
- <Tree
|
|
|
- treeData={renderNodes(treeData)}
|
|
|
- defaultExpandAll
|
|
|
- showLine
|
|
|
- selectedKeys={selectedDeptId ? [selectedDeptId] : []}
|
|
|
- onSelect={(keys) => setSelectedDeptId(keys[0] as number | undefined)}
|
|
|
- />
|
|
|
- )}
|
|
|
- </Spin>
|
|
|
+ <ProCard>
|
|
|
+ <div className="flex items-center justify-between mb-3">
|
|
|
+ <DeptForm
|
|
|
+ mode="add"
|
|
|
+ initialValues={{ parentId: 0 }}
|
|
|
+ onSuccess={loadData}
|
|
|
+ trigger={
|
|
|
+ <Button type="primary">{intl.formatMessage({ id: 'admin.dept.createRoot' })}</Button>
|
|
|
+ }
|
|
|
+ />
|
|
|
+ <Tooltip title="刷新">
|
|
|
+ <span
|
|
|
+ className="cursor-pointer text-(--ant-color-text) hover:text-(--ant-color-primary) transition-colors"
|
|
|
+ onClick={loadData}
|
|
|
+ >
|
|
|
+ <ReloadOutlined style={{ fontSize: 16 }} />
|
|
|
+ </span>
|
|
|
+ </Tooltip>
|
|
|
</div>
|
|
|
- <div className="flex-1 min-w-0">
|
|
|
- {selectedDeptIds ? (
|
|
|
- <DeptUserTable users={filteredUsers} productRolesBase={productRolesBase} />
|
|
|
- ) : (
|
|
|
- <Empty description="请在左侧选择部门" className="py-16" />
|
|
|
- )}
|
|
|
+ <div className="flex gap-4">
|
|
|
+ <div className="w-80 shrink-0 bg-(--ant-color-fill-quaternary) rounded p-2">
|
|
|
+ <Spin spinning={loading}>
|
|
|
+ {treeData.length > 0 && (
|
|
|
+ <Tree
|
|
|
+ className="bg-transparent!"
|
|
|
+ treeData={renderNodes(treeData)}
|
|
|
+ defaultExpandAll
|
|
|
+ showLine
|
|
|
+ selectedKeys={selectedDeptId ? [selectedDeptId] : []}
|
|
|
+ onSelect={(keys) => setSelectedDeptId(keys[0] as number | undefined)}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </Spin>
|
|
|
+ </div>
|
|
|
+ <div className="flex-1 min-w-0">
|
|
|
+ {selectedDeptIds ? (
|
|
|
+ <DeptUserTable users={filteredUsers} productRolesBase={productRolesBase} />
|
|
|
+ ) : (
|
|
|
+ <Empty description="请在左侧选择部门" className="py-16" />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </ProCard>
|
|
|
</PageContainer>
|
|
|
);
|
|
|
}
|