|
|
@@ -2,8 +2,9 @@ import React, { useState } from 'react';
|
|
|
import { Table, Button, Modal, Form, Input, Switch, message, Space, Popconfirm } from 'antd';
|
|
|
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
-import { departmentsClient } from '@/client/api';
|
|
|
+import { departmentsClient, userClient } from '@/client/api';
|
|
|
import LazyDepartmentTreeSelect from '@/client/admin/components/LazyDepartmentTreeSelect';
|
|
|
+import UserSelect from '@/client/admin/components/UserSelect';
|
|
|
|
|
|
const Departments: React.FC = () => {
|
|
|
const [form] = Form.useForm();
|
|
|
@@ -21,6 +22,16 @@ const Departments: React.FC = () => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // 查询用户列表
|
|
|
+ const { data: usersData } = useQuery({
|
|
|
+ queryKey: ['users-for-departments'],
|
|
|
+ queryFn: async () => {
|
|
|
+ const response = await userClient.$get({ query: { page: 1, pageSize: 1000 } });
|
|
|
+ if (response.status !== 200) throw new Error('获取用户列表失败');
|
|
|
+ return response.json();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
// 创建部门
|
|
|
const createMutation = useMutation({
|
|
|
mutationFn: async (data: any) => {
|
|
|
@@ -97,6 +108,17 @@ const Departments: React.FC = () => {
|
|
|
return parent?.name || '-';
|
|
|
},
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '负责人',
|
|
|
+ dataIndex: 'managerId',
|
|
|
+ key: 'managerId',
|
|
|
+ width: 120,
|
|
|
+ render: (managerId: number) => {
|
|
|
+ if (!managerId) return '-';
|
|
|
+ const manager = usersData?.data.find((u: any) => u.id === managerId);
|
|
|
+ return manager?.name || manager?.username || '-';
|
|
|
+ },
|
|
|
+ },
|
|
|
{
|
|
|
title: '排序',
|
|
|
dataIndex: 'sortOrder',
|
|
|
@@ -248,7 +270,7 @@ const Departments: React.FC = () => {
|
|
|
label="负责人"
|
|
|
name="managerId"
|
|
|
>
|
|
|
- <Input placeholder="请输入负责人ID" type="number" />
|
|
|
+ <UserSelect placeholder="请选择负责人" />
|
|
|
</Form.Item>
|
|
|
|
|
|
<Form.Item
|