From 31146a7b6bfd78368e5be74c8d7a13d6480c31e7 Mon Sep 17 00:00:00 2001 From: BenjaminNH <1249376374@qq.com> Date: Mon, 21 Jul 2025 21:24:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E4=BF=AE=E6=94=B9=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/shared/MyApproval.jsx | 74 +++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/src/pages/shared/MyApproval.jsx b/src/pages/shared/MyApproval.jsx index 6ae629b..7e2acec 100644 --- a/src/pages/shared/MyApproval.jsx +++ b/src/pages/shared/MyApproval.jsx @@ -1,10 +1,11 @@ -import { Button, Form, Input, Table, Tag } from "antd"; +import { Button, DatePicker, Form, Input, message, Table, Tag } from "antd"; import { useForm } from "antd/es/form/Form"; 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 { selectUserId, selectUserRole } from "../../features/auth/authSlice"; +import dayjs from "dayjs"; export default function MyApproval() { const [approvals, setApprovals] = useState([]); @@ -14,8 +15,11 @@ export default function MyApproval() { pageSize: 10, total: 0, }); + const [editingRow, setEditingRow] = useState(null); + const [tempEndTime, setTempEndTime] = useState(null); const userId = useSelector(selectUserId); + const userRole = useSelector(selectUserRole); const fetchData = async (pagination, searchParam) => { const data = await axiosInstance.get(`/approval/${userId}`, { @@ -53,6 +57,20 @@ export default function MyApproval() { await fetchData(newPagination, values); }; + const handleSubmit = async (record) => { + try { + await axiosInstance.post(`/reservation/endTime/${record.reservationId}`, { + endTime: dayjs(tempEndTime).format("YYYY-MM-DD"), + }); + const values = await form.validateFields(); + await fetchData(pagination, values); + setEditingRow(null); + message.success("修改成功"); + } catch (error) { + message.error("修改失败"); + } + }; + return (
@@ -88,7 +106,57 @@ export default function MyApproval() { /> - + { + const isEditable = + record.decision === 1 && userRole.includes("DEVICE_ADMIN"); + + if (editingRow === record.approvalId) { + return ( +
+ setTempEndTime(date)} + disabledDate={(current) => + current && + current.isBefore(dayjs(record.startTime), "day") + } + size="small" + /> + + +
+ ); + } + + return isEditable ? ( + + {record.endTime} + + + ) : ( + {record.endTime} + ); + }} + />