From ec7d04aa247f9da997e2deab0b0b8fec79fdedc0 Mon Sep 17 00:00:00 2001
From: BenjaminNH <1249376374@qq.com>
Date: Mon, 30 Jun 2025 15:47:15 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8B=86=E5=88=86=E5=AE=A1=E6=A0=B8?=
=?UTF-8?q?=E9=A2=84=E7=BA=A6=E5=85=AC=E5=85=B1=E7=BB=84=E4=BB=B6=E3=80=81?=
=?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E5=85=AC=E5=85=B1=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/axios.js | 1 +
src/components/ApprovalTable.jsx | 119 ++++++++++++++++++++++++++++
src/config/menuConfig.js | 19 +++--
src/pages/{user => }/UserDetail.jsx | 4 +-
src/pages/deviceAdmin/Approval.jsx | 5 ++
src/pages/leader/Approval.jsx | 101 +----------------------
src/router/index.jsx | 30 ++++---
7 files changed, 163 insertions(+), 116 deletions(-)
create mode 100644 src/components/ApprovalTable.jsx
rename src/pages/{user => }/UserDetail.jsx (97%)
create mode 100644 src/pages/deviceAdmin/Approval.jsx
diff --git a/src/api/axios.js b/src/api/axios.js
index 95c4862..df4372f 100644
--- a/src/api/axios.js
+++ b/src/api/axios.js
@@ -39,6 +39,7 @@ axiosInstance.interceptors.response.use(
if (status === 403) {
message.error("请登录后重试");
store.dispatch(logout());
+ window.location.href = "/login";
}
}
}
diff --git a/src/components/ApprovalTable.jsx b/src/components/ApprovalTable.jsx
new file mode 100644
index 0000000..3da6381
--- /dev/null
+++ b/src/components/ApprovalTable.jsx
@@ -0,0 +1,119 @@
+import { Button, message, Space, Table } from "antd";
+import Column from "antd/es/table/Column";
+import { useEffect, useState } from "react";
+import { useSelector } from "react-redux";
+import axiosInstance from "../api/axios";
+import { selectUserId } from "../features/auth/authSlice";
+
+export default function ApprovalTable({ showNeedAssist }) {
+ const [reservations, setReservations] = useState([]);
+ const [pagination, setPagination] = useState({
+ current: 1,
+ pageSize: 10,
+ total: 0,
+ });
+
+ const userId = useSelector(selectUserId);
+
+ const fetchData = async (pagination) => {
+ const data = await axiosInstance.get(`/reservation/approval/${userId}`, {
+ params: {
+ page: pagination.current,
+ size: pagination.pageSize,
+ },
+ });
+
+ setReservations(data.records);
+ setPagination({
+ ...pagination,
+ total: data.total,
+ });
+ };
+
+ useEffect(() => {
+ fetchData(pagination);
+ }, []);
+
+ const handlePageChange = (pagination) => {
+ fetchData(pagination);
+ };
+
+ const handleApproval = (reservationId, isApprove, needAssist) => {
+ axiosInstance.post("/approval", {
+ userId,
+ reservationId,
+ isApprove,
+ needAssist,
+ });
+
+ message.success("审核成功");
+ const newPagination = {
+ ...pagination,
+ current: 1,
+ };
+ setPagination(newPagination);
+ fetchData(newPagination);
+ };
+
+ // "预约人、所属团队、联系方式、预约设备、预约时间: 设备详情、"
+ return (
+
+
+
+
+
+
+
+ {
+ return (
+
+
+ {showNeedAssist && (
+
+ )}
+
+
+ );
+ }}
+ />
+
+ );
+}
diff --git a/src/config/menuConfig.js b/src/config/menuConfig.js
index 019faee..b4e32f7 100644
--- a/src/config/menuConfig.js
+++ b/src/config/menuConfig.js
@@ -18,12 +18,7 @@ const menuConfig = [
icon: UnorderedListOutlined,
roles: ["USER"],
},
- {
- path: "/user/userdetail",
- label: "个人信息",
- icon: UserOutlined,
- roles: ["USER"],
- },
+
{
path: "/leader/approval",
label: "预约审批",
@@ -36,6 +31,18 @@ const menuConfig = [
icon: UnorderedListOutlined,
roles: ["LEADER"],
},
+ {
+ path: "/device-admin/approval",
+ label: "预约审批",
+ icon: FileDoneOutlined,
+ roles: ["DEVICE_ADMIN"],
+ },
+ {
+ path: "/userdetail",
+ label: "个人信息",
+ icon: UserOutlined,
+ roles: ["USER", "DEVICE_ADMIN"],
+ },
];
export default menuConfig;
diff --git a/src/pages/user/UserDetail.jsx b/src/pages/UserDetail.jsx
similarity index 97%
rename from src/pages/user/UserDetail.jsx
rename to src/pages/UserDetail.jsx
index 24c63f2..59d3a30 100644
--- a/src/pages/user/UserDetail.jsx
+++ b/src/pages/UserDetail.jsx
@@ -2,8 +2,8 @@ import { Button, Col, Form, Input, message, Row } from "antd";
import { useForm } from "antd/es/form/Form";
import { useEffect, useState } from "react";
import { useSelector } from "react-redux";
-import axiosInstance from "../../api/axios";
-import { selectUserId } from "../../features/auth/authSlice";
+import axiosInstance from "../api/axios";
+import { selectUserId } from "../features/auth/authSlice";
export default function UserDetail() {
const [form] = useForm();
diff --git a/src/pages/deviceAdmin/Approval.jsx b/src/pages/deviceAdmin/Approval.jsx
new file mode 100644
index 0000000..ebf7768
--- /dev/null
+++ b/src/pages/deviceAdmin/Approval.jsx
@@ -0,0 +1,5 @@
+import ApprovalTable from "../../components/ApprovalTable";
+
+export default function DeviceAdminApproval() {
+ return ;
+}
diff --git a/src/pages/leader/Approval.jsx b/src/pages/leader/Approval.jsx
index 002e5f8..3420380 100644
--- a/src/pages/leader/Approval.jsx
+++ b/src/pages/leader/Approval.jsx
@@ -1,102 +1,5 @@
-import { Button, message, Space, Table } from "antd";
-import Column from "antd/es/table/Column";
-import { useEffect, useState } from "react";
-import { useSelector } from "react-redux";
-import axiosInstance from "../../api/axios";
-import { selectUserId } from "../../features/auth/authSlice";
+import ApprovalTable from "../../components/ApprovalTable";
export default function LeaderApproval() {
- const [reservations, setReservations] = useState([]);
- const [pagination, setPagination] = useState({
- current: 1,
- pageSize: 10,
- total: 0,
- });
-
- const userId = useSelector(selectUserId);
-
- const fetchData = async (pagination) => {
- const data = await axiosInstance.get(`/reservation/leader/${userId}`, {
- params: {
- page: pagination.current,
- size: pagination.pageSize,
- },
- });
-
- setReservations(data.records);
- setPagination({
- ...pagination,
- total: data.total,
- });
- };
-
- useEffect(() => {
- fetchData(pagination);
- }, []);
-
- const handlePageChange = (pagination) => {
- fetchData(pagination);
- };
-
- const handleApproval = (reservationId, isApprove) => {
- axiosInstance.post("/approval/leader", {
- leaderId: userId,
- reservationId,
- isApprove,
- });
-
- message.success("审核成功");
- const newPagination = {
- ...pagination,
- current: 1,
- };
- setPagination(newPagination);
- fetchData(newPagination);
- };
-
- // "预约人、所属团队、联系方式、预约设备、预约时间: 设备详情、"
- return (
-
-
-
-
-
-
-
- {
- return (
-
-
-
-
- );
- }}
- />
-
- );
+ return ;
}
diff --git a/src/router/index.jsx b/src/router/index.jsx
index 364f7d8..5a3f688 100644
--- a/src/router/index.jsx
+++ b/src/router/index.jsx
@@ -1,12 +1,13 @@
import { createBrowserRouter, Navigate } from "react-router-dom";
-import Login from "../pages/Login";
-import ProtectedRoute from "./ProtectedRoute";
import CommonLayout from "../layouts/CommonLayout";
-import Reserve from "../pages/user/Reserve";
-import MyReservation from "../pages/user/MyReservation";
-import UserDetail from "../pages/user/UserDetail";
+import DeviceAdminApproval from "../pages/deviceAdmin/Approval";
import LeaderApproval from "../pages/leader/Approval";
import LeaderMyApproval from "../pages/leader/MyApproval";
+import Login from "../pages/Login";
+import MyReservation from "../pages/user/MyReservation";
+import Reserve from "../pages/user/Reserve";
+import UserDetail from "../pages/UserDetail";
+import ProtectedRoute from "./ProtectedRoute";
const router = createBrowserRouter([
{
@@ -33,10 +34,6 @@ const router = createBrowserRouter([
path: "my-reservation",
element: ,
},
- {
- path: "userdetail",
- element: ,
- },
],
},
{
@@ -53,6 +50,21 @@ const router = createBrowserRouter([
},
],
},
+ {
+ path: "device-admin",
+ element: ,
+ children: [
+ {
+ path: "approval",
+ element: ,
+ },
+ ],
+ },
+
+ {
+ path: "userdetail",
+ element: ,
+ },
],
},
]);