feat: 实现查看团队成员模态框

This commit is contained in:
BenjaminNH 2025-07-21 11:46:39 +08:00
parent 087fa440b6
commit 4c554401a9
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,33 @@
import { List, Modal, Typography } from "antd";
import { useEffect, useState } from "react";
import axiosInstance from "../../api/axios";
export default function TeamDetailModal({ open, team, onclose }) {
const [data, setData] = useState([]);
const fetchData = async () => {
const data = await axiosInstance.get(`/user-team/${team.id}`);
setData(data);
};
useEffect(() => {
if (open) {
fetchData();
}
}, [open, team]);
return (
<Modal
open={open}
onCancel={() => {
onclose();
}}
>
<List
header={<div>{team?.name}</div>}
dataSource={data}
renderItem={(item) => <List.Item>{item}</List.Item>}
/>
</Modal>
);
}

View File

@ -3,6 +3,7 @@ import Column from "antd/es/table/Column";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import axiosInstance from "../../api/axios"; import axiosInstance from "../../api/axios";
import TeamDeleteButton from "../../components/TeamDeleteButton"; import TeamDeleteButton from "../../components/TeamDeleteButton";
import TeamDetailModal from "./TeamDetailModal";
export default function TeamManage() { export default function TeamManage() {
const [teams, setTeams] = useState([]); const [teams, setTeams] = useState([]);
@ -11,6 +12,8 @@ export default function TeamManage() {
const [editingId, setEditingId] = useState(); const [editingId, setEditingId] = useState();
const [editingName, setEditingName] = useState(""); const [editingName, setEditingName] = useState("");
const [newTeamName, setNewTeamName] = useState(); const [newTeamName, setNewTeamName] = useState();
const [open, setOpen] = useState(false);
const [selectedTeam, setSelectedTeam] = useState(null);
const fetchData = async () => { const fetchData = async () => {
const data = await axiosInstance.get("/teams"); const data = await axiosInstance.get("/teams");
@ -124,6 +127,15 @@ export default function TeamManage() {
编辑 编辑
</Button> </Button>
)} )}
<Button
size="small"
onClick={() => {
setSelectedTeam(record);
setOpen(true);
}}
>
人员列表
</Button>
<TeamDeleteButton <TeamDeleteButton
record={record} record={record}
onConfirm={() => handleDelete(record)} onConfirm={() => handleDelete(record)}
@ -133,6 +145,14 @@ export default function TeamManage() {
}} }}
/> />
</Table> </Table>
<TeamDetailModal
open={open}
team={selectedTeam}
onclose={() => {
setOpen(false);
setSelectedTeam(null);
}}
/>
</> </>
); );
} }