mirror of
https://github.com/PlayEdu/backend
synced 2025-06-21 06:32:47 +08:00
部门管理部门列表
This commit is contained in:
parent
872ce3e5e9
commit
3f29132a80
@ -26,7 +26,7 @@ export function updateDepartment(
|
||||
parentId: number,
|
||||
sort: number
|
||||
) {
|
||||
return client.post(`/backend/v1/department/${id}`, {
|
||||
return client.put(`/backend/v1/department/${id}`, {
|
||||
name,
|
||||
parent_id: parentId,
|
||||
sort,
|
||||
|
@ -3,10 +3,17 @@ import { Button, Space, Table, Popconfirm, message } from "antd";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
import styles from "./index.module.less";
|
||||
import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
|
||||
import { adminRole } from "../../api/index";
|
||||
import { department } from "../../api/index";
|
||||
import { dateFormat } from "../../utils/index";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
|
||||
interface Option {
|
||||
id: string | number;
|
||||
name: string;
|
||||
created_at: string;
|
||||
children?: Option[];
|
||||
}
|
||||
|
||||
interface DataType {
|
||||
id: React.Key;
|
||||
name: string;
|
||||
@ -20,16 +27,16 @@ export const DepartmentPage: React.FC = () => {
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
|
||||
const columns: ColumnsType<DataType> = [
|
||||
{
|
||||
title: "部门名",
|
||||
dataIndex: "name",
|
||||
render: (text: string) => <span>{text}</span>,
|
||||
},
|
||||
{
|
||||
title: "ID",
|
||||
key: "id",
|
||||
dataIndex: "id",
|
||||
},
|
||||
{
|
||||
title: "角色名",
|
||||
dataIndex: "name",
|
||||
render: (text: string) => <span>{text}</span>,
|
||||
},
|
||||
{
|
||||
title: "时间",
|
||||
dataIndex: "created_at",
|
||||
@ -72,21 +79,45 @@ export const DepartmentPage: React.FC = () => {
|
||||
|
||||
const getData = () => {
|
||||
setLoading(true);
|
||||
adminRole.adminRoleList().then((res: any) => {
|
||||
setList(res.data);
|
||||
department.departmentList().then((res: any) => {
|
||||
const departments = res.data.departments;
|
||||
const new_arr: Option[] = checkArr(departments, 0);
|
||||
setList(new_arr);
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
}, 1000);
|
||||
});
|
||||
};
|
||||
|
||||
const checkArr = (departments: any[], id: number) => {
|
||||
const arr = [];
|
||||
for (let i = 0; i < departments[id].length; i++) {
|
||||
if (!departments[departments[id][i].id]) {
|
||||
arr.push({
|
||||
name: departments[id][i].name,
|
||||
id: departments[id][i].id,
|
||||
created_at: departments[id][i].created_at,
|
||||
});
|
||||
} else {
|
||||
const new_arr: Option[] = checkArr(departments, departments[id][i].id);
|
||||
arr.push({
|
||||
name: departments[id][i].name,
|
||||
id: departments[id][i].id,
|
||||
created_at: departments[id][i].created_at,
|
||||
children: new_arr,
|
||||
});
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
const resetData = () => {
|
||||
setList([]);
|
||||
setRefresh(!refresh);
|
||||
};
|
||||
|
||||
const delUser = (id: any) => {
|
||||
adminRole.destroyAdminRole(id).then((res: any) => {
|
||||
department.destroyDepartment(id).then((res: any) => {
|
||||
setTimeout(() => {
|
||||
message.success("操作成功");
|
||||
setRefresh(!refresh);
|
||||
|
@ -171,59 +171,59 @@ export const MemberPage: React.FC = () => {
|
||||
return (
|
||||
<>
|
||||
<Row>
|
||||
<div className="playedu-main-body mb-24">
|
||||
<div className="float-left d-flex">
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>昵称:</Typography.Text>
|
||||
<Input
|
||||
value={nickname}
|
||||
onChange={(e) => {
|
||||
setNickname(e.target.value);
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入昵称"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>邮箱:</Typography.Text>
|
||||
<Input
|
||||
value={email}
|
||||
onChange={(e) => {
|
||||
setEmail(e.target.value);
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入邮箱"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>身份证号:</Typography.Text>
|
||||
<Input
|
||||
value={id_card}
|
||||
onChange={(e) => {
|
||||
setIdCard(e.target.value);
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入身份证号"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Button className="mr-16" onClick={resetData}>
|
||||
重 置
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setPage(1);
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
>
|
||||
查 询
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Col span={4}></Col>
|
||||
<Col span={20}>
|
||||
<div className="playedu-main-body mb-24">
|
||||
<div className="float-left d-flex">
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>昵称:</Typography.Text>
|
||||
<Input
|
||||
value={nickname}
|
||||
onChange={(e) => {
|
||||
setNickname(e.target.value);
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入昵称"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>邮箱:</Typography.Text>
|
||||
<Input
|
||||
value={email}
|
||||
onChange={(e) => {
|
||||
setEmail(e.target.value);
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入邮箱"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>身份证号:</Typography.Text>
|
||||
<Input
|
||||
value={id_card}
|
||||
onChange={(e) => {
|
||||
setIdCard(e.target.value);
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入身份证号"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Button className="mr-16" onClick={resetData}>
|
||||
重 置
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setPage(1);
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
>
|
||||
查 询
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="playedu-main-body">
|
||||
<div className="float-left j-b-flex mb-24">
|
||||
<div className="d-flex">
|
||||
|
Loading…
x
Reference in New Issue
Block a user