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