mirror of
https://github.com/PlayEdu/backend
synced 2025-08-20 13:49:36 +08:00
部门管理部门列表
This commit is contained in:
parent
872ce3e5e9
commit
3f29132a80
@ -26,7 +26,7 @@ export function updateDepartment(
|
|||||||
parentId: number,
|
parentId: number,
|
||||||
sort: number
|
sort: number
|
||||||
) {
|
) {
|
||||||
return client.post(`/backend/v1/department/${id}`, {
|
return client.put(`/backend/v1/department/${id}`, {
|
||||||
name,
|
name,
|
||||||
parent_id: parentId,
|
parent_id: parentId,
|
||||||
sort,
|
sort,
|
||||||
|
@ -3,10 +3,17 @@ import { Button, Space, Table, Popconfirm, message } from "antd";
|
|||||||
import type { ColumnsType } from "antd/es/table";
|
import type { ColumnsType } from "antd/es/table";
|
||||||
import styles from "./index.module.less";
|
import styles from "./index.module.less";
|
||||||
import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
|
import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
|
||||||
import { adminRole } from "../../api/index";
|
import { department } from "../../api/index";
|
||||||
import { dateFormat } from "../../utils/index";
|
import { dateFormat } from "../../utils/index";
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
|
interface Option {
|
||||||
|
id: string | number;
|
||||||
|
name: string;
|
||||||
|
created_at: string;
|
||||||
|
children?: Option[];
|
||||||
|
}
|
||||||
|
|
||||||
interface DataType {
|
interface DataType {
|
||||||
id: React.Key;
|
id: React.Key;
|
||||||
name: string;
|
name: string;
|
||||||
@ -20,16 +27,16 @@ export const DepartmentPage: React.FC = () => {
|
|||||||
const [refresh, setRefresh] = useState(false);
|
const [refresh, setRefresh] = useState(false);
|
||||||
|
|
||||||
const columns: ColumnsType<DataType> = [
|
const columns: ColumnsType<DataType> = [
|
||||||
|
{
|
||||||
|
title: "部门名",
|
||||||
|
dataIndex: "name",
|
||||||
|
render: (text: string) => <span>{text}</span>,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "ID",
|
title: "ID",
|
||||||
key: "id",
|
key: "id",
|
||||||
dataIndex: "id",
|
dataIndex: "id",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "角色名",
|
|
||||||
dataIndex: "name",
|
|
||||||
render: (text: string) => <span>{text}</span>,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "时间",
|
title: "时间",
|
||||||
dataIndex: "created_at",
|
dataIndex: "created_at",
|
||||||
@ -72,21 +79,45 @@ export const DepartmentPage: React.FC = () => {
|
|||||||
|
|
||||||
const getData = () => {
|
const getData = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
adminRole.adminRoleList().then((res: any) => {
|
department.departmentList().then((res: any) => {
|
||||||
setList(res.data);
|
const departments = res.data.departments;
|
||||||
|
const new_arr: Option[] = checkArr(departments, 0);
|
||||||
|
setList(new_arr);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, 1000);
|
}, 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 = () => {
|
const resetData = () => {
|
||||||
setList([]);
|
setList([]);
|
||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
};
|
};
|
||||||
|
|
||||||
const delUser = (id: any) => {
|
const delUser = (id: any) => {
|
||||||
adminRole.destroyAdminRole(id).then((res: any) => {
|
department.destroyDepartment(id).then((res: any) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
message.success("操作成功");
|
message.success("操作成功");
|
||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
|
@ -171,59 +171,59 @@ export const MemberPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Row>
|
<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={4}></Col>
|
||||||
<Col span={20}>
|
<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="playedu-main-body">
|
||||||
<div className="float-left j-b-flex mb-24">
|
<div className="float-left j-b-flex mb-24">
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user