添加交叉评查任务的文档列表,评查详情的意见列表
This commit is contained in:
@@ -4,6 +4,7 @@ import { useLoaderData, useSearchParams, useNavigate, useFetcher } from "@remix-
|
||||
import { Button } from '~/components/ui/Button';
|
||||
import { Card } from '~/components/ui/Card';
|
||||
import { Tag } from '~/components/ui/Tag';
|
||||
import { DocumentListModal } from '~/components/cross-checking';
|
||||
|
||||
import crossCheckingStyles from "~/styles/pages/cross-checking_index.css?url";
|
||||
import { Table } from '~/components/ui/Table';
|
||||
@@ -14,12 +15,14 @@ import {
|
||||
getCrossCheckingTasks,
|
||||
getCrossCheckingStats,
|
||||
deleteCrossCheckingTask,
|
||||
getCrossCheckingTaskDetail,
|
||||
type CrossCheckingTask,
|
||||
type TaskListParams,
|
||||
CrossCheckingTaskStatus,
|
||||
CrossCheckingTaskType,
|
||||
CrossCheckingDocType
|
||||
} from '~/api/cross-checking/cross-files';
|
||||
import type { ReviewFileUI } from '~/api/evaluation_points/rules-files';
|
||||
|
||||
export const links = () => [
|
||||
{ rel: "stylesheet", href: crossCheckingStyles }
|
||||
@@ -168,6 +171,24 @@ export default function CrossCheckingIndex() {
|
||||
|
||||
// 状态管理
|
||||
const [isDeleting, setIsDeleting] = useState(false);
|
||||
const [modalState, setModalState] = useState<{
|
||||
isOpen: boolean;
|
||||
title: string;
|
||||
files: ReviewFileUI[];
|
||||
loading: boolean;
|
||||
// 分页相关状态
|
||||
currentPage: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
}>({
|
||||
isOpen: false,
|
||||
title: '',
|
||||
files: [],
|
||||
loading: false,
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
});
|
||||
|
||||
// 获取进度条样式类
|
||||
const getProgressClass = (progress: number) => {
|
||||
@@ -176,10 +197,101 @@ export default function CrossCheckingIndex() {
|
||||
return 'high';
|
||||
};
|
||||
|
||||
// 处理查看结果
|
||||
// const handleViewResult = (taskId: number, docIds: number[]) => {
|
||||
// // 根据taskId获取关联的
|
||||
// };
|
||||
// 处理查看结果 - 打开文档列表模态框
|
||||
const handleViewResult = async (taskId: number, documentIds: number[]) => {
|
||||
// 存储任务信息用于分页
|
||||
setCurrentTaskInfo({ taskId, documentIds });
|
||||
|
||||
// 打开模态框
|
||||
setModalState(prev => ({
|
||||
...prev,
|
||||
isOpen: true,
|
||||
currentPage: 1,
|
||||
pageSize: 10
|
||||
}));
|
||||
|
||||
// 加载第一页数据
|
||||
await loadModalData(taskId, documentIds, 1, 10);
|
||||
};
|
||||
|
||||
// 关闭模态框
|
||||
const handleCloseModal = () => {
|
||||
setModalState({
|
||||
isOpen: false,
|
||||
title: '',
|
||||
files: [],
|
||||
loading: false,
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
});
|
||||
setCurrentTaskInfo(null);
|
||||
};
|
||||
|
||||
// 处理文档查看 - 导航到评查详情页
|
||||
const handleViewFile = (fileId: string) => {
|
||||
navigate(`/cross-checking/result?id=${fileId}&previousRoute=crossChecking`);
|
||||
};
|
||||
|
||||
// 存储当前任务信息用于分页
|
||||
const [currentTaskInfo, setCurrentTaskInfo] = useState<{
|
||||
taskId: number;
|
||||
documentIds: number[];
|
||||
} | null>(null);
|
||||
|
||||
// 加载分页数据
|
||||
const loadModalData = async (taskId: number, documentIds: number[], page: number = 1, pageSize: number = 10) => {
|
||||
try {
|
||||
setModalState(prev => ({
|
||||
...prev,
|
||||
loading: true
|
||||
}));
|
||||
|
||||
// 调用支持分页的API,传递分页参数
|
||||
const response = await getCrossCheckingTaskDetail(taskId, documentIds, page, pageSize);
|
||||
|
||||
if (response.error) {
|
||||
throw new Error(response.error);
|
||||
}
|
||||
|
||||
const { task, files, total } = response.data!;
|
||||
|
||||
setModalState(prev => ({
|
||||
...prev,
|
||||
loading: false,
|
||||
title: `${task.taskName} - 文档列表`,
|
||||
files: files,
|
||||
total: total,
|
||||
currentPage: page,
|
||||
pageSize: pageSize
|
||||
}));
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取任务文档列表失败:', error);
|
||||
toastService.error(`获取任务文档列表失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
||||
|
||||
setModalState(prev => ({
|
||||
...prev,
|
||||
loading: false
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
// 处理模态框分页变化
|
||||
const handleModalPageChange = (page: number) => {
|
||||
if (currentTaskInfo) {
|
||||
loadModalData(currentTaskInfo.taskId, currentTaskInfo.documentIds, page, modalState.pageSize);
|
||||
}
|
||||
};
|
||||
|
||||
// 处理模态框每页大小变化
|
||||
const handleModalPageSizeChange = (size: number) => {
|
||||
if (currentTaskInfo) {
|
||||
loadModalData(currentTaskInfo.taskId, currentTaskInfo.documentIds, 1, size);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 渲染进度条
|
||||
const renderProgress = (progress: number) => (
|
||||
@@ -548,6 +660,21 @@ export default function CrossCheckingIndex() {
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* 文档列表模态框 */}
|
||||
<DocumentListModal
|
||||
isOpen={modalState.isOpen}
|
||||
onClose={handleCloseModal}
|
||||
title={modalState.title}
|
||||
files={modalState.files}
|
||||
onViewFile={handleViewFile}
|
||||
loading={modalState.loading}
|
||||
currentPage={modalState.currentPage}
|
||||
pageSize={modalState.pageSize}
|
||||
total={modalState.total}
|
||||
onPageChange={handleModalPageChange}
|
||||
onPageSizeChange={handleModalPageSizeChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ export default function CrossCheckingResult() {
|
||||
|
||||
// 添加前置路由
|
||||
if (loaderData.previousRoute) {
|
||||
if (loaderData.previousRoute === 'cross-checking') {
|
||||
if (loaderData.previousRoute === 'crossChecking') {
|
||||
items.unshift({ title: "交叉评查", to: "/cross-checking" });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user