fix: align rules list and review detail flows
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
* 右栏 · 详情面板
|
||||
* 包含 3 个选项卡(评查结果、抽取字段、文件信息)+ 底部操作栏
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import type { ReviewPoint, CharPosition } from '../ReviewPointsList';
|
||||
import { ReviewPointDetailCard } from './ReviewPointDetailCard';
|
||||
import { FileInfoPanel } from './FileInfoPanel';
|
||||
@@ -35,8 +34,8 @@ interface DetailPanelProps {
|
||||
reviewPoints: ReviewPoint[];
|
||||
fileInfo: FileInfoData;
|
||||
reviewInfo: ReviewInfoData;
|
||||
onReviewPointSelect: (id: string, page?: number, charPositions?: CharPosition[], value?: string) => void;
|
||||
onStatusChange: (id: string, editAuditStatusId: string | number, status: string, message: string) => void;
|
||||
onReviewPointSelect: (id: string | number, page?: number, charPositions?: CharPosition[], value?: string) => void;
|
||||
onStatusChange: (id: string | number, editAuditStatusId: string | number, status: string, message: string) => void;
|
||||
onConfirmResults: () => void;
|
||||
onDownload: () => void;
|
||||
auditStatus?: number;
|
||||
@@ -46,16 +45,36 @@ interface DetailPanelProps {
|
||||
showComparisonButton?: boolean;
|
||||
}
|
||||
|
||||
function ExtractedFieldsPanel({ reviewPoints, onFieldClick }: { reviewPoints: ReviewPoint[]; onFieldClick: (page: number) => void }) {
|
||||
const fields: Array<{ key: string; value: string; page?: number; pointName: string }> = [];
|
||||
type ExtractedFieldValue = {
|
||||
value?: unknown;
|
||||
page?: number | string;
|
||||
};
|
||||
|
||||
function ExtractedFieldsPanel({
|
||||
reviewPoints,
|
||||
onFieldClick,
|
||||
}: {
|
||||
reviewPoints: ReviewPoint[];
|
||||
onFieldClick: (pointId: string | number, page: number) => void;
|
||||
}) {
|
||||
const fields: Array<{ key: string; value: string; page?: number; pointName: string; pointId: string | number }> = [];
|
||||
|
||||
reviewPoints.forEach((p) => {
|
||||
if (p.content) {
|
||||
Object.entries(p.content).forEach(([key, data]) => {
|
||||
const val = (data as any)?.value;
|
||||
const page = (data as any)?.page;
|
||||
const text = typeof val === 'object' ? (val as any)?.text || JSON.stringify(val) : String(val || '');
|
||||
fields.push({ key, value: text, page: page ? Number(page) : undefined, pointName: p.pointName });
|
||||
const fieldData = (data && typeof data === 'object' ? data : {}) as ExtractedFieldValue & { text?: string };
|
||||
const val = fieldData.value;
|
||||
const page = fieldData.page;
|
||||
const text = typeof val === 'object' && val !== null
|
||||
? ('text' in (val as Record<string, unknown>) ? String((val as Record<string, unknown>).text || '') : JSON.stringify(val))
|
||||
: String(val || '');
|
||||
fields.push({
|
||||
key,
|
||||
value: text,
|
||||
page: page ? Number(page) : undefined,
|
||||
pointName: p.pointName,
|
||||
pointId: p.id,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -74,7 +93,7 @@ function ExtractedFieldsPanel({ reviewPoints, onFieldClick }: { reviewPoints: Re
|
||||
key={`${f.key}-${i}`}
|
||||
type="button"
|
||||
className={`w-full border border-slate-200 rounded-md text-left hover:bg-slate-50 transition p-2.5 ${f.page ? 'cursor-pointer' : 'cursor-default opacity-70'}`}
|
||||
onClick={() => f.page && onFieldClick(f.page)}
|
||||
onClick={() => f.page && onFieldClick(f.pointId, f.page)}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="text-[11px] text-slate-500 truncate font-medium">{f.key}</span>
|
||||
@@ -180,11 +199,8 @@ export function DetailPanel({
|
||||
{activeTab === 'fields' && (
|
||||
<ExtractedFieldsPanel
|
||||
reviewPoints={reviewPoints}
|
||||
onFieldClick={(page) => {
|
||||
// 通过 activeReviewPoint 的 id 跳转页面
|
||||
if (activeReviewPoint) {
|
||||
onReviewPointSelect(activeReviewPoint.id, page);
|
||||
}
|
||||
onFieldClick={(pointId, page) => {
|
||||
onReviewPointSelect(pointId, page);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user