2025-06-30 10:22:35 +08:00
|
|
|
|
import { Button, Form, Input, 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";
|
|
|
|
|
|
2025-06-30 17:18:13 +08:00
|
|
|
|
export default function MyApproval() {
|
2025-06-30 10:22:35 +08:00
|
|
|
|
const [approvals, setApprovals] = useState([]);
|
|
|
|
|
const [form] = useForm();
|
|
|
|
|
const [pagination, setPagination] = useState({
|
|
|
|
|
current: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
total: 0,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const userId = useSelector(selectUserId);
|
|
|
|
|
|
|
|
|
|
const fetchData = async (pagination, searchParam) => {
|
2025-06-30 17:18:13 +08:00
|
|
|
|
const data = await axiosInstance.get(`/approval/${userId}`, {
|
2025-06-30 10:22:35 +08:00
|
|
|
|
params: {
|
|
|
|
|
page: pagination.current,
|
|
|
|
|
size: pagination.pageSize,
|
|
|
|
|
applicantName: searchParam?.applicantName,
|
|
|
|
|
deviceName: searchParam?.deviceName,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setApprovals(data.records);
|
|
|
|
|
setPagination({
|
|
|
|
|
...pagination,
|
|
|
|
|
total: data.total,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetchData(pagination);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const handlePageChange = async (pagination) => {
|
|
|
|
|
const values = await form.validateFields();
|
|
|
|
|
fetchData(pagination, values);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSearch = async () => {
|
|
|
|
|
const values = await form.validateFields();
|
2025-07-01 11:24:55 +08:00
|
|
|
|
const newPagination = {
|
|
|
|
|
...pagination,
|
|
|
|
|
current: 1,
|
|
|
|
|
};
|
|
|
|
|
setPagination(newPagination);
|
|
|
|
|
await fetchData(newPagination, values);
|
2025-06-30 10:22:35 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="p-2 pt-4">
|
|
|
|
|
<Form form={form} layout="inline" onFinish={handleSearch}>
|
|
|
|
|
<Form.Item name="applicantName">
|
|
|
|
|
<Input placeholder="请输入预约人姓名" allowClear />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item name="deviceName">
|
|
|
|
|
<Input placeholder="请输入设备名称" allowClear />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<Button type="primary" htmlType="submit">
|
|
|
|
|
搜索
|
|
|
|
|
</Button>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
<Table
|
|
|
|
|
dataSource={approvals}
|
|
|
|
|
pagination={pagination}
|
|
|
|
|
onChange={handlePageChange}
|
|
|
|
|
className="mt-4"
|
|
|
|
|
rowKey="approvalId"
|
|
|
|
|
>
|
|
|
|
|
<Column title="预约人" key="applicantName" dataIndex="applicantName" />
|
|
|
|
|
<Column
|
|
|
|
|
title="所属团队"
|
|
|
|
|
key="applicantTeam"
|
|
|
|
|
dataIndex="applicantTeam"
|
|
|
|
|
/>
|
|
|
|
|
<Column
|
|
|
|
|
title="联系方式"
|
|
|
|
|
key="applicantContact"
|
|
|
|
|
dataIndex="applicantContact"
|
|
|
|
|
/>
|
|
|
|
|
<Column title="预约设备" key="deviceName" dataIndex="deviceName" />
|
|
|
|
|
<Column title="开始时间" key="startTime" dataIndex="startTime" />
|
|
|
|
|
<Column title="结束时间" key="endTime" dataIndex="endTime" />
|
|
|
|
|
<Column
|
|
|
|
|
title="审批情况"
|
|
|
|
|
key="decision"
|
2025-06-30 17:18:13 +08:00
|
|
|
|
render={(_, { decision, status }) => {
|
2025-06-30 10:22:35 +08:00
|
|
|
|
if (decision === 1) {
|
2025-06-30 17:18:13 +08:00
|
|
|
|
if (status === "APPROVED_ASSIST") {
|
|
|
|
|
return (
|
|
|
|
|
<Tag color="blue" key="decision">
|
|
|
|
|
通过,需要协助
|
|
|
|
|
</Tag>
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<Tag color="green" key="decision">
|
|
|
|
|
通过
|
|
|
|
|
</Tag>
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-06-30 10:22:35 +08:00
|
|
|
|
}
|
|
|
|
|
if (decision === 0) {
|
|
|
|
|
return (
|
|
|
|
|
<Tag color="red" key="decision">
|
|
|
|
|
拒绝
|
|
|
|
|
</Tag>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<Tag color="grey" key="decision">
|
|
|
|
|
ERROR
|
|
|
|
|
</Tag>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Table>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|