feat: 拆分历史审核公共页面,优化审核预约拆分逻辑
This commit is contained in:
parent
ec7d04aa24
commit
beb32673b5
@ -20,28 +20,22 @@ const menuConfig = [
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/leader/approval",
|
path: "/approval",
|
||||||
label: "预约审批",
|
label: "预约审批",
|
||||||
icon: FileDoneOutlined,
|
icon: FileDoneOutlined,
|
||||||
roles: ["LEADER"],
|
roles: ["LEADER", "DEVICE_ADMIN"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/leader/my-approval",
|
path: "/my-approval",
|
||||||
label: "审批记录",
|
label: "审批记录",
|
||||||
icon: UnorderedListOutlined,
|
icon: UnorderedListOutlined,
|
||||||
roles: ["LEADER"],
|
roles: ["LEADER", "DEVICE_ADMIN"],
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/device-admin/approval",
|
|
||||||
label: "预约审批",
|
|
||||||
icon: FileDoneOutlined,
|
|
||||||
roles: ["DEVICE_ADMIN"],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/userdetail",
|
path: "/userdetail",
|
||||||
label: "个人信息",
|
label: "个人信息",
|
||||||
icon: UserOutlined,
|
icon: UserOutlined,
|
||||||
roles: ["USER", "DEVICE_ADMIN"],
|
roles: ["USER", "LEADER", "DEVICE_ADMIN", "ADMIN"],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const roleRoute = {
|
const roleRoute = {
|
||||||
USER: "/user/reserve",
|
USER: "/user/reserve",
|
||||||
ADMIN: "/admin/user-manage",
|
ADMIN: "/admin/user-manage",
|
||||||
LEADER: "/leader/approval",
|
LEADER: "/approval",
|
||||||
DEVICE_ADMIN: "/device-admin/approval",
|
DEVICE_ADMIN: "/approval",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default roleRoute;
|
export default roleRoute;
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import ApprovalTable from "../../components/ApprovalTable";
|
|
||||||
|
|
||||||
export default function DeviceAdminApproval() {
|
|
||||||
return <ApprovalTable showNeedAssist={true} />;
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
import ApprovalTable from "../../components/ApprovalTable";
|
|
||||||
|
|
||||||
export default function LeaderApproval() {
|
|
||||||
return <ApprovalTable showNeedAssist={false} />;
|
|
||||||
}
|
|
@ -2,10 +2,11 @@ import { Button, message, Space, Table } from "antd";
|
|||||||
import Column from "antd/es/table/Column";
|
import Column from "antd/es/table/Column";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import axiosInstance from "../api/axios";
|
import axiosInstance from "../../api/axios";
|
||||||
import { selectUserId } from "../features/auth/authSlice";
|
import { selectUserId } from "../../features/auth/authSlice";
|
||||||
|
import { selectUserRole } from "../../features/auth/authSlice";
|
||||||
|
|
||||||
export default function ApprovalTable({ showNeedAssist }) {
|
export default function Approval() {
|
||||||
const [reservations, setReservations] = useState([]);
|
const [reservations, setReservations] = useState([]);
|
||||||
const [pagination, setPagination] = useState({
|
const [pagination, setPagination] = useState({
|
||||||
current: 1,
|
current: 1,
|
||||||
@ -14,6 +15,11 @@ export default function ApprovalTable({ showNeedAssist }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const userId = useSelector(selectUserId);
|
const userId = useSelector(selectUserId);
|
||||||
|
const roles = useSelector(selectUserRole);
|
||||||
|
let showNeedAssist = false;
|
||||||
|
if (roles.some((r) => r === "DEVICE_ADMIN")) {
|
||||||
|
showNeedAssist = true;
|
||||||
|
}
|
||||||
|
|
||||||
const fetchData = async (pagination) => {
|
const fetchData = async (pagination) => {
|
||||||
const data = await axiosInstance.get(`/reservation/approval/${userId}`, {
|
const data = await axiosInstance.get(`/reservation/approval/${userId}`, {
|
||||||
@ -34,12 +40,12 @@ export default function ApprovalTable({ showNeedAssist }) {
|
|||||||
fetchData(pagination);
|
fetchData(pagination);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handlePageChange = (pagination) => {
|
const handlePageChange = async (pagination) => {
|
||||||
fetchData(pagination);
|
await fetchData(pagination);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleApproval = (reservationId, isApprove, needAssist) => {
|
const handleApproval = async (reservationId, isApprove, needAssist) => {
|
||||||
axiosInstance.post("/approval", {
|
await axiosInstance.post("/approval", {
|
||||||
userId,
|
userId,
|
||||||
reservationId,
|
reservationId,
|
||||||
isApprove,
|
isApprove,
|
||||||
@ -52,7 +58,7 @@ export default function ApprovalTable({ showNeedAssist }) {
|
|||||||
current: 1,
|
current: 1,
|
||||||
};
|
};
|
||||||
setPagination(newPagination);
|
setPagination(newPagination);
|
||||||
fetchData(newPagination);
|
await fetchData(newPagination);
|
||||||
};
|
};
|
||||||
|
|
||||||
// "预约人、所属团队、联系方式、预约设备、预约时间: 设备详情、"
|
// "预约人、所属团队、联系方式、预约设备、预约时间: 设备详情、"
|
@ -6,7 +6,7 @@ import { useSelector } from "react-redux";
|
|||||||
import axiosInstance from "../../api/axios";
|
import axiosInstance from "../../api/axios";
|
||||||
import { selectUserId } from "../../features/auth/authSlice";
|
import { selectUserId } from "../../features/auth/authSlice";
|
||||||
|
|
||||||
export default function LeaderMyApproval() {
|
export default function MyApproval() {
|
||||||
const [approvals, setApprovals] = useState([]);
|
const [approvals, setApprovals] = useState([]);
|
||||||
const [form] = useForm();
|
const [form] = useForm();
|
||||||
const [pagination, setPagination] = useState({
|
const [pagination, setPagination] = useState({
|
||||||
@ -18,7 +18,7 @@ export default function LeaderMyApproval() {
|
|||||||
const userId = useSelector(selectUserId);
|
const userId = useSelector(selectUserId);
|
||||||
|
|
||||||
const fetchData = async (pagination, searchParam) => {
|
const fetchData = async (pagination, searchParam) => {
|
||||||
const data = await axiosInstance.get(`/approval/leader/${userId}`, {
|
const data = await axiosInstance.get(`/approval/${userId}`, {
|
||||||
params: {
|
params: {
|
||||||
page: pagination.current,
|
page: pagination.current,
|
||||||
size: pagination.pageSize,
|
size: pagination.pageSize,
|
||||||
@ -93,14 +93,22 @@ export default function LeaderMyApproval() {
|
|||||||
<Column
|
<Column
|
||||||
title="审批情况"
|
title="审批情况"
|
||||||
key="decision"
|
key="decision"
|
||||||
render={(_, { decision }) => {
|
render={(_, { decision, status }) => {
|
||||||
if (decision === 1) {
|
if (decision === 1) {
|
||||||
|
if (status === "APPROVED_ASSIST") {
|
||||||
|
return (
|
||||||
|
<Tag color="blue" key="decision">
|
||||||
|
通过,需要协助
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
return (
|
return (
|
||||||
<Tag color="green" key="decision">
|
<Tag color="green" key="decision">
|
||||||
通过
|
通过
|
||||||
</Tag>
|
</Tag>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (decision === 0) {
|
if (decision === 0) {
|
||||||
return (
|
return (
|
||||||
<Tag color="red" key="decision">
|
<Tag color="red" key="decision">
|
@ -2,8 +2,8 @@ import { Button, Col, Form, Input, message, Row } from "antd";
|
|||||||
import { useForm } from "antd/es/form/Form";
|
import { useForm } from "antd/es/form/Form";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import axiosInstance from "../api/axios";
|
import axiosInstance from "../../api/axios";
|
||||||
import { selectUserId } from "../features/auth/authSlice";
|
import { selectUserId } from "../../features/auth/authSlice";
|
||||||
|
|
||||||
export default function UserDetail() {
|
export default function UserDetail() {
|
||||||
const [form] = useForm();
|
const [form] = useForm();
|
@ -74,11 +74,29 @@ export default function MyReservation() {
|
|||||||
title="预约状态"
|
title="预约状态"
|
||||||
key="statusLabel"
|
key="statusLabel"
|
||||||
dataIndex="statusLabel"
|
dataIndex="statusLabel"
|
||||||
render={(_, { statusLabel }) => {
|
render={(_, record) => {
|
||||||
const color = statusLabel === "通过" ? "green" : "yellow";
|
if (record.statusLabel === "通过") {
|
||||||
return (
|
return (
|
||||||
<Tag color={color} key="statusLabel">
|
<Tag color="green" key="statusLabel">
|
||||||
{statusLabel}
|
通过
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
} else if (record.statusLabel === "不通过") {
|
||||||
|
return (
|
||||||
|
<Tag color="red" key="statusLabel">
|
||||||
|
不通过
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
} else if (record.statusLabel === "通过,需要协助实验") {
|
||||||
|
return (
|
||||||
|
<Tag color="blue" key="statusLabel">
|
||||||
|
通过,需要协助实验
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Tag color="yellow" key="statusLabel">
|
||||||
|
{record.statusLabel}
|
||||||
</Tag>
|
</Tag>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
@ -95,7 +95,6 @@ export default function Reserve() {
|
|||||||
key="action"
|
key="action"
|
||||||
render={(_, record) => (
|
render={(_, record) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<a>查看日历</a>
|
|
||||||
<a onClick={() => setSelectedDevice(record)}>预约</a>
|
<a onClick={() => setSelectedDevice(record)}>预约</a>
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
)}
|
||||||
|
@ -6,8 +6,10 @@ import LeaderMyApproval from "../pages/leader/MyApproval";
|
|||||||
import Login from "../pages/Login";
|
import Login from "../pages/Login";
|
||||||
import MyReservation from "../pages/user/MyReservation";
|
import MyReservation from "../pages/user/MyReservation";
|
||||||
import Reserve from "../pages/user/Reserve";
|
import Reserve from "../pages/user/Reserve";
|
||||||
import UserDetail from "../pages/UserDetail";
|
import UserDetail from "../pages/shared/UserDetail";
|
||||||
import ProtectedRoute from "./ProtectedRoute";
|
import ProtectedRoute from "./ProtectedRoute";
|
||||||
|
import Approval from "../pages/shared/Approval";
|
||||||
|
import MyApproval from "../pages/shared/MyApproval";
|
||||||
|
|
||||||
const router = createBrowserRouter([
|
const router = createBrowserRouter([
|
||||||
{
|
{
|
||||||
@ -37,26 +39,15 @@ const router = createBrowserRouter([
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "leader",
|
element: <ProtectedRoute allowedRoles={["LEADER", "DEVICE_ADMIN"]} />,
|
||||||
element: <ProtectedRoute allowedRoles={["LEADER"]} />,
|
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "approval",
|
path: "approval",
|
||||||
element: <LeaderApproval />,
|
element: <Approval />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "my-approval",
|
path: "my-approval",
|
||||||
element: <LeaderMyApproval />,
|
element: <MyApproval />,
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "device-admin",
|
|
||||||
element: <ProtectedRoute allowedRoles={["DEVICE_ADMIN"]} />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "approval",
|
|
||||||
element: <DeviceAdminApproval />,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user