修改时间范围组件,评查详情创建新的数据结构来适配新的返回格式

This commit is contained in:
2025-04-22 20:49:18 +08:00
parent cd2f060d87
commit 6261950356
14 changed files with 678 additions and 299 deletions
+20 -20
View File
@@ -67,11 +67,11 @@ interface FileContent {
interface FilePreviewProps {
fileContent: FileContent;
reviewPoints: ReviewPoint[];
activeReviewPointId: string | null;
activeReviewPointResultId: string | null;
targetPage?: number; // 新增目标页码参数
}
export function FilePreview({ fileContent, reviewPoints, activeReviewPointId, targetPage }: FilePreviewProps) {
export function FilePreview({ fileContent, reviewPoints, activeReviewPointResultId, targetPage }: FilePreviewProps) {
const [zoomLevel, setZoomLevel] = useState(100);
// const [highlightsVisible, setHighlightsVisible] = useState(true);
const contentRef = useRef<HTMLDivElement>(null);
@@ -119,7 +119,7 @@ export function FilePreview({ fileContent, reviewPoints, activeReviewPointId, ta
const prevTargetPageRef = useRef<number | undefined>(undefined);
useEffect(() => {
// 如果有目标页码,并且与上次不同或activeReviewPointId变化了,则执行跳转
if (targetPage && numPages && targetPage <= numPages && (targetPage !== prevTargetPageRef.current || activeReviewPointId)) {
if (targetPage && numPages && targetPage <= numPages && (targetPage !== prevTargetPageRef.current || activeReviewPointResultId)) {
prevTargetPageRef.current = targetPage;
let newTargetPage = targetPage;
try {
@@ -134,25 +134,25 @@ export function FilePreview({ fileContent, reviewPoints, activeReviewPointId, ta
const pageElement = document.getElementById(`page-${newTargetPage}`);
if (pageElement) {
console.log(`跳转到第${newTargetPage}页,对应评查点结果ID: ${activeReviewPointId}`);
console.log(`跳转到第${newTargetPage}页,对应评查点结果ID: ${activeReviewPointResultId}`);
pageElement.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
}, [targetPage, numPages, fileContent, activeReviewPointId]);
}, [targetPage, numPages, fileContent, activeReviewPointResultId]);
// 获取评查点对应的样式类
const getHighlightClass = (status: string) => {
switch (status) {
case 'warning':
return 'warning';
case 'error':
return 'error';
case 'success':
return 'success';
default:
return 'warning';
}
};
// const getHighlightClass = (status: string) => {
// switch (status) {
// case 'warning':
// return 'warning';
// case 'error':
// return 'error';
// case 'success':
// return 'success';
// default:
// return 'warning';
// }
// };
// 处理页码输入变化
const handlePageInputChange = (e: ChangeEvent<HTMLInputElement>) => {
@@ -231,9 +231,9 @@ export function FilePreview({ fileContent, reviewPoints, activeReviewPointId, ta
// 遍历每一页,生成对应的页面组件
for (let i = 1; i <= numPages; i++) {
// 查找该页面上的评查点,基于position.section匹配页面ID
const pageReviewPoints = reviewPoints.filter(point =>
point.position && point.position.section === `page-${i}`
);
// const pageReviewPoints = reviewPoints.filter(point =>
// point.position && point.position.section === `page-${i}`
// );
// 计算当前缩放级别下的页面容器样式
const zoomFactor = zoomLevel / 100;