mirror of
https://github.com/PlayEdu/backend
synced 2025-06-06 15:34:08 +08:00
管理员日志
This commit is contained in:
parent
540d1e01e7
commit
a6923632d1
21
src/api/admin-log.ts
Normal file
21
src/api/admin-log.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import client from "./internal/httpClient";
|
||||
|
||||
export function adminLogList(
|
||||
page: number,
|
||||
size: number,
|
||||
admin_id: number | null,
|
||||
title: string,
|
||||
opt: string,
|
||||
start_time: string,
|
||||
end_time: string
|
||||
) {
|
||||
return client.get("/backend/v1/admin/log/index", {
|
||||
page: page,
|
||||
size: size,
|
||||
admin_id: admin_id,
|
||||
title: title,
|
||||
opt: opt,
|
||||
start_time: start_time,
|
||||
end_time: end_time,
|
||||
});
|
||||
}
|
@ -14,3 +14,4 @@ export * as upload from "./upload";
|
||||
export * as user from "./user";
|
||||
export * as appConfig from "./app-config";
|
||||
export * as dashboard from "./dashboard";
|
||||
export * as adminLog from "./admin-log";
|
||||
|
@ -91,6 +91,7 @@ const items = [
|
||||
null,
|
||||
"admin-user-index"
|
||||
),
|
||||
getItem("管理日志", "/system/adminlog", null, null, null, "admin-log"),
|
||||
// getItem("角色配置", "/system/adminroles", null, null, null, null),
|
||||
],
|
||||
null,
|
||||
|
@ -7,6 +7,7 @@ import { Provider } from "react-redux";
|
||||
import store from "./store";
|
||||
import { ConfigProvider } from "antd";
|
||||
import zhCN from "antd/locale/zh_CN";
|
||||
import "dayjs/locale/zh-cn";
|
||||
import AutoScorllTop from "./AutoTop";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
|
0
src/pages/system/adminlog/index.module.less
Normal file
0
src/pages/system/adminlog/index.module.less
Normal file
180
src/pages/system/adminlog/index.tsx
Normal file
180
src/pages/system/adminlog/index.tsx
Normal file
@ -0,0 +1,180 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Table, Typography, Input, Select, Button, DatePicker } from "antd";
|
||||
import { adminLog } from "../../../api";
|
||||
// import styles from "./index.module.less";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
import { dateWholeFormat } from "../../../utils/index";
|
||||
const { RangePicker } = DatePicker;
|
||||
import moment from "moment";
|
||||
|
||||
interface DataType {
|
||||
id: React.Key;
|
||||
admin_id: number;
|
||||
ip: string;
|
||||
opt: string;
|
||||
adminName: string;
|
||||
module: string;
|
||||
created_at: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
const SystemLogPage = () => {
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [page, setPage] = useState(1);
|
||||
const [size, setSize] = useState(10);
|
||||
const [list, setList] = useState<any>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [title, setTitle] = useState("");
|
||||
const [adminId, setAdminId] = useState(0);
|
||||
const [created_at, setCreatedAt] = useState<any>([]);
|
||||
const [createdAts, setCreatedAts] = useState<any>([]);
|
||||
|
||||
useEffect(() => {
|
||||
getData();
|
||||
}, [refresh, page, size]);
|
||||
|
||||
const getData = () => {
|
||||
setLoading(true);
|
||||
adminLog
|
||||
.adminLogList(
|
||||
page,
|
||||
size,
|
||||
adminId > 0 ? adminId : null,
|
||||
title,
|
||||
"",
|
||||
created_at[0],
|
||||
created_at[1]
|
||||
)
|
||||
.then((res: any) => {
|
||||
setList(res.data.data);
|
||||
setTotal(res.data.total);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((e) => {
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
const resetData = () => {
|
||||
setTitle("");
|
||||
setAdminId(0);
|
||||
setPage(1);
|
||||
setSize(10);
|
||||
setList([]);
|
||||
setCreatedAts([]);
|
||||
setCreatedAt([]);
|
||||
setRefresh(!refresh);
|
||||
};
|
||||
|
||||
const paginationProps = {
|
||||
current: page, //当前页码
|
||||
pageSize: size,
|
||||
total: total, // 总条数
|
||||
onChange: (page: number, pageSize: number) =>
|
||||
handlePageChange(page, pageSize), //改变页码的函数
|
||||
showSizeChanger: true,
|
||||
};
|
||||
|
||||
const handlePageChange = (page: number, pageSize: number) => {
|
||||
setPage(page);
|
||||
setSize(pageSize);
|
||||
};
|
||||
|
||||
const disabledDate = (current: any) => {
|
||||
return current && current >= moment().add(0, "days"); // 选择时间要大于等于当前天。若今天不能被选择,去掉等号即可。
|
||||
};
|
||||
|
||||
const columns: ColumnsType<DataType> = [
|
||||
{
|
||||
title: "管理员ID",
|
||||
width: 100,
|
||||
render: (_, record: any) => <span>{record.admin_id}</span>,
|
||||
},
|
||||
{
|
||||
title: "管理员",
|
||||
width: 150,
|
||||
render: (_, record: any) => <span>{record.adminName}</span>,
|
||||
},
|
||||
{
|
||||
title: "标题",
|
||||
render: (_, record: any) => <span>{record.title}</span>,
|
||||
},
|
||||
{
|
||||
title: "操作模块",
|
||||
width: 100,
|
||||
dataIndex: "module",
|
||||
render: (module: string) => <span>{module}</span>,
|
||||
},
|
||||
{
|
||||
title: "操作指令",
|
||||
width: 100,
|
||||
dataIndex: "opt",
|
||||
render: (opt: string) => <span>{opt}</span>,
|
||||
},
|
||||
{
|
||||
title: "IP",
|
||||
width: 200,
|
||||
dataIndex: "ip",
|
||||
render: (ip: string) => <span>{ip}</span>,
|
||||
},
|
||||
{
|
||||
title: "时间",
|
||||
width: 200,
|
||||
dataIndex: "created_at",
|
||||
render: (created_at: string) => (
|
||||
<span>{dateWholeFormat(created_at)}</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="playedu-main-body">
|
||||
<div className="float-left j-b-flex mb-24">
|
||||
<div className="d-flex"></div>
|
||||
<div className="d-flex">
|
||||
<div className="d-flex mr-24">
|
||||
<RangePicker
|
||||
disabledDate={disabledDate}
|
||||
format={"YYYY-MM-DD"}
|
||||
value={createdAts}
|
||||
style={{ marginLeft: 10 }}
|
||||
onChange={(date, dateString) => {
|
||||
dateString[0] += " 00:00:00";
|
||||
dateString[1] += " 23:59:59";
|
||||
setCreatedAt(dateString);
|
||||
setCreatedAts(date);
|
||||
}}
|
||||
placeholder={["时间-开始", "时间-结束"]}
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex">
|
||||
<Button className="mr-16" onClick={resetData}>
|
||||
重 置
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setPage(1);
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
>
|
||||
查 询
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="float-left">
|
||||
<Table
|
||||
loading={loading}
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
rowKey={(record) => record.id}
|
||||
pagination={paginationProps}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemLogPage;
|
@ -62,6 +62,11 @@ export const SystemAdminrolesCreate: React.FC<PropInterface> = ({
|
||||
value: "管理员-n",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: "管理员日志",
|
||||
value: "管理员日志-n",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: "管理员角色",
|
||||
value: "管理员角色-n",
|
||||
|
@ -65,6 +65,11 @@ export const SystemAdminrolesUpdate: React.FC<PropInterface> = ({
|
||||
value: "管理员-n",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: "管理员日志",
|
||||
value: "管理员日志-n",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: "管理员角色",
|
||||
value: "管理员角色-n",
|
||||
|
@ -39,6 +39,7 @@ const SystemAdministratorPage = lazy(
|
||||
() => import("../pages/system/administrator")
|
||||
);
|
||||
const SystemAdminrolesPage = lazy(() => import("../pages/system/adminroles"));
|
||||
const SystemLogPage = lazy(() => import("../pages/system/adminlog"));
|
||||
//部门页面
|
||||
const DepartmentPage = lazy(() => import("../pages/department"));
|
||||
//测试
|
||||
@ -152,6 +153,10 @@ const routes: RouteObject[] = [
|
||||
path: "/system/adminroles",
|
||||
element: <PrivateRoute Component={<SystemAdminrolesPage />} />,
|
||||
},
|
||||
{
|
||||
path: "/system/adminlog",
|
||||
element: <PrivateRoute Component={<SystemLogPage />} />,
|
||||
},
|
||||
{
|
||||
path: "/department",
|
||||
element: <PrivateRoute Component={<DepartmentPage />} />,
|
||||
|
@ -133,3 +133,10 @@ export function checkUrl(value: any) {
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
export function dateWholeFormat(dateStr: string) {
|
||||
if (!dateStr) {
|
||||
return "";
|
||||
}
|
||||
return moment(dateStr).format("YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user