fixed
This commit is contained in:
+102
-45
@@ -25,10 +25,12 @@
|
||||
* @author 中国烟草AI合同及卷宗审核系统开发团队
|
||||
*/
|
||||
|
||||
import { type MetaFunction } from "@remix-run/node";
|
||||
import { type MetaFunction, type LoaderFunctionArgs } from "@remix-run/node";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useNavigate } from "@remix-run/react";
|
||||
import { useNavigate, useLoaderData } from "@remix-run/react";
|
||||
import {getDocument} from "~/api/files/documents";
|
||||
import reviewsStyles from "~/styles/reviews.css?url";
|
||||
import { getReviewPoints } from "~/api/evaluation_points/reviews";
|
||||
|
||||
// 导入评查详情页面组件
|
||||
import {
|
||||
@@ -40,23 +42,21 @@ import {
|
||||
FileDetails
|
||||
} from "~/components/reviews";
|
||||
|
||||
// 定义评查点类型
|
||||
interface ReviewPoint {
|
||||
id: string;
|
||||
title: string;
|
||||
location: string;
|
||||
status: string;
|
||||
content: string;
|
||||
suggestion: string;
|
||||
needsHumanReview?: boolean;
|
||||
humanReviewNote?: string;
|
||||
humanReviewBy?: string;
|
||||
humanReviewTime?: string;
|
||||
position?: {
|
||||
section: string;
|
||||
index: number;
|
||||
};
|
||||
}
|
||||
// 从ReviewPointsList组件中导入ReviewPoint类型
|
||||
import { type ReviewPoint } from '~/components/reviews';
|
||||
|
||||
/**
|
||||
* 文件信息组件
|
||||
* 显示文件名称、状态信息以及操作按钮(下载原文件、导出评查报告、确认评查结果)
|
||||
*/
|
||||
// 格式化文件大小
|
||||
const formatFileSize = (bytes: number) => {
|
||||
if (bytes === 0) return "0 Bytes";
|
||||
const k = 1024;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
||||
};
|
||||
|
||||
// 定义统计数据类型
|
||||
interface Statistics {
|
||||
@@ -76,6 +76,7 @@ interface FileInfo {
|
||||
pageCount: number;
|
||||
uploadTime: string;
|
||||
uploadUser: string;
|
||||
auditStatus: number;
|
||||
}
|
||||
|
||||
// 定义合同信息类型
|
||||
@@ -166,30 +167,79 @@ export const handle = {
|
||||
breadcrumb: "评查详情"
|
||||
};
|
||||
|
||||
export async function loader({ request }: LoaderFunctionArgs) {
|
||||
try {
|
||||
const url = new URL(request.url);
|
||||
const id = url.searchParams.get('id') || undefined;
|
||||
// console.log("id-------",id);
|
||||
if (!id) {
|
||||
return Response.json({ error: '评查ID不能为空' }, { status: 400 });
|
||||
}
|
||||
|
||||
const documentData = await getDocument(id);
|
||||
if (documentData.error) {
|
||||
console.error("获取文档数据错误:", documentData.error);
|
||||
return Response.json({ error: documentData.error }, { status: documentData.status || 500 });
|
||||
}
|
||||
const reviewData = await getReviewPoints(id);
|
||||
|
||||
console.log("reviewData-------",reviewData);
|
||||
if (reviewData.error) {
|
||||
console.error("获取评查点数据错误:", reviewData.error);
|
||||
return Response.json({ error: reviewData.error }, { status: reviewData.status || 500 });
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
document: documentData.data,
|
||||
reviewPoints: reviewData.data,
|
||||
statistics: reviewData.stats
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取评查数据失败:', error);
|
||||
return Response.json({ error: '获取评查数据失败' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export default function ReviewDetails() {
|
||||
const navigate = useNavigate();
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const { document, reviewPoints, statistics } = useLoaderData<typeof loader>();
|
||||
const [isLoading, setIsLoading] = useState(false); // 已经通过loader加载了数据,不需要再显示加载状态
|
||||
const [activeTab, setActiveTab] = useState<string>('preview'); // 'preview', 'analysis', 'fileinfo'
|
||||
const [reviewData, setReviewData] = useState<ReviewData | null>(null);
|
||||
const [activeReviewPointId, setActiveReviewPointId] = useState<string | null>(null);
|
||||
|
||||
// 模拟获取评查数据
|
||||
useEffect(() => {
|
||||
// 模拟API请求延迟
|
||||
const timer = setTimeout(() => {
|
||||
// 模拟评查数据
|
||||
const mockData = getMockReviewData();
|
||||
setReviewData(mockData);
|
||||
setIsLoading(false);
|
||||
|
||||
// 默认选中第一个评查点
|
||||
if (mockData.reviewPoints.length > 0) {
|
||||
setActiveReviewPointId(mockData.reviewPoints[0].id);
|
||||
}
|
||||
}, 800);
|
||||
if (!document) return;
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
// 构建文件信息对象
|
||||
const fileInfo = {
|
||||
fileName: document.name || "未知文件名",
|
||||
contractNumber: document.documentNumber || "未知编号",
|
||||
fileSize: document.size ? formatFileSize(document.size) : "未知大小",
|
||||
fileFormat: document.fileType ? document.fileType.toUpperCase() : "未知格式",
|
||||
pageCount: document.pageCount || 0,
|
||||
uploadTime: document.uploadTime || "未知时间",
|
||||
uploadUser: document.uploadUser || "未知用户",
|
||||
auditStatus: document.auditStatus || 0,
|
||||
};
|
||||
|
||||
// 创建包含真实文档数据的评查数据对象
|
||||
const reviewDataObj: ReviewData = {
|
||||
// 使用真实文件信息
|
||||
fileInfo: fileInfo,
|
||||
// 其他字段暂时使用默认值
|
||||
contractInfo: getMockReviewData().contractInfo,
|
||||
reviewInfo: getMockReviewData().reviewInfo,
|
||||
statistics: statistics,
|
||||
fileContent: getMockReviewData().fileContent,
|
||||
reviewPoints: reviewPoints,
|
||||
aiAnalysis: getMockReviewData().aiAnalysis,
|
||||
};
|
||||
|
||||
setReviewData(reviewDataObj);
|
||||
setIsLoading(false);
|
||||
}, [document, reviewPoints, statistics]);
|
||||
|
||||
const handleTabChange = (tabKey: string) => {
|
||||
setActiveTab(tabKey);
|
||||
@@ -317,7 +367,8 @@ function getMockReviewData(): ReviewData {
|
||||
fileFormat: "DOCX",
|
||||
pageCount: 5,
|
||||
uploadTime: "2023-10-25 14:30:45",
|
||||
uploadUser: "张三"
|
||||
uploadUser: "张三",
|
||||
auditStatus: 0
|
||||
},
|
||||
contractInfo: {
|
||||
contractType: "销售合同",
|
||||
@@ -383,36 +434,40 @@ function getMockReviewData(): ReviewData {
|
||||
{
|
||||
id: "1",
|
||||
title: "付款条件描述不明确",
|
||||
location: "付款条款清晰性",
|
||||
groupName: "付款条款清晰性",
|
||||
// location: "交货与付款条款",
|
||||
status: "error",
|
||||
content: "乙方应在收到货物之日起5个工作日内支付合同款项,甲方应在收到乙方全部付款后开具增值税专用发票,乙方应在收到发票后支付剩余款项。",
|
||||
suggestion: "乙方应在收到货物验收合格之日起5个工作日内支付合同总额的70%,甲方收到该部分款项后3个工作日内向乙方开具等额增值税专用发票;乙方应在收到发票之日起5个工作日内支付剩余30%款项。",
|
||||
position: { section: "交货与付款", index: 2 }
|
||||
position: { section: "交货与付款", index: 2 },
|
||||
result: false
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
title: "违约责任条款缺失",
|
||||
location: "合同权利义务对等性",
|
||||
groupName: "合同权利义务对等性",
|
||||
status: "warning",
|
||||
content: "如合同发生纠纷,双方应协商解决。",
|
||||
suggestion: "如合同发生纠纷,双方应友好协商解决;协商不成的,任何一方均有权向甲方所在地人民法院提起诉讼。任何一方未能履行本合同约定义务,应向守约方支付合同总金额的10%作为违约金;给对方造成损失的,还应赔偿由此产生的全部损失。",
|
||||
position: { section: "争议解决", index: 0 }
|
||||
position: { section: "争议解决", index: 0 },
|
||||
result: false
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
title: "签章不完整",
|
||||
location: "合同签署规范性",
|
||||
groupName: "合同签署规范性",
|
||||
status: "warning",
|
||||
content: "乙方(盖章):YY贸易有限公司\n代表人签字:李YY\n日期:2023年10月20日",
|
||||
suggestion: "需要联系甲方补充公章",
|
||||
needsHumanReview: true,
|
||||
humanReviewNote: "需要联系甲方补充公章",
|
||||
position: { section: "签章", index: 0 }
|
||||
position: { section: "签章", index: 0 },
|
||||
result: false
|
||||
},
|
||||
{
|
||||
id: "9",
|
||||
title: "交货方式描述模糊",
|
||||
location: "履行条款明确性",
|
||||
groupName: "履行条款明确性",
|
||||
status: "success",
|
||||
content: "3.4 运输方式:陆运,运费由甲方承担。",
|
||||
suggestion: "建议补充具体的运输方式和时间",
|
||||
@@ -420,16 +475,18 @@ function getMockReviewData(): ReviewData {
|
||||
humanReviewNote: "经核实,该交货方式虽然描述不够详细,但符合行业惯例且双方已经多次合作,不会造成实际履行障碍。",
|
||||
humanReviewBy: "王法务",
|
||||
humanReviewTime: "2023-11-05 14:30:22",
|
||||
position: { section: "交货与付款", index: 4 }
|
||||
position: { section: "交货与付款", index: 4 },
|
||||
result: true
|
||||
},
|
||||
{
|
||||
id: "10",
|
||||
title: "法律适用条款缺失",
|
||||
location: "争议解决条款完整性",
|
||||
groupName: "争议解决条款完整性",
|
||||
status: "error",
|
||||
content: "",
|
||||
suggestion: "第十三条 法律适用\n本合同的订立、效力、解释、履行及争议的解决均适用中华人民共和国法律。因本合同引起的或与本合同有关的任何争议,双方应友好协商解决。协商不成的,提交甲方所在地人民法院诉讼解决。",
|
||||
position: { section: "缺失", index: 0 }
|
||||
position: { section: "缺失", index: 0 },
|
||||
result: false
|
||||
}
|
||||
],
|
||||
aiAnalysis: {
|
||||
|
||||
Reference in New Issue
Block a user