feat: 实现查看团队成员模态框
This commit is contained in:
parent
087fa440b6
commit
4c554401a9
33
src/pages/admin/TeamDetailModal.jsx
Normal file
33
src/pages/admin/TeamDetailModal.jsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
@ -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);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user