/** * 评查点列表组件 * 显示评查结果统计和所有评查点列表 */ import { useState } from 'react'; // 评查点类型定义 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; }; } // 统计数据类型 interface Statistics { total: number; success: number; warning: number; error: number; score: number; } interface ReviewPointsListProps { reviewPoints: ReviewPoint[]; statistics: Statistics; activeReviewPointId: string | null; onReviewPointSelect: (id: string) => void; onStatusChange: (id: string, status: string) => void; } export function ReviewPointsList({ reviewPoints, statistics, activeReviewPointId, onReviewPointSelect, onStatusChange }: ReviewPointsListProps) { const [editingReviewPoint, setEditingReviewPoint] = useState(null); const [userInputText, setUserInputText] = useState(''); const [searchText, setSearchText] = useState(''); const [statusFilter, setStatusFilter] = useState(null); // 过滤评查点 const filteredReviewPoints = reviewPoints.filter(point => { const matchesSearch = searchText === '' || point.title.toLowerCase().includes(searchText.toLowerCase()) || point.location.toLowerCase().includes(searchText.toLowerCase()) || point.content.toLowerCase().includes(searchText.toLowerCase()); const matchesStatus = statusFilter === null || point.status === statusFilter; return matchesSearch && matchesStatus; }); // 处理点击"一键替换"按钮 const handleReplace = (reviewPointId: string) => { // 在实际应用中,这里应该调用API进行内容替换 // 模拟替换操作 alert(`将为评查点 ${reviewPointId} 执行一键替换操作`); // 更新评查点状态为成功 onStatusChange(reviewPointId, 'success'); }; // 处理评查点审核操作 const handleReviewAction = (reviewPointId: string, action: 'approve' | 'reject') => { // 更新评查点状态 onStatusChange(reviewPointId, action === 'approve' ? 'success' : 'error'); // 清除编辑状态 setEditingReviewPoint(null); setUserInputText(''); alert(`${action === 'approve' ? '通过' : '不通过'}了评查点 ${reviewPointId}`); }; // 显示评查点详情编辑界面 const handleEditReviewPoint = (reviewPointId: string) => { setEditingReviewPoint(reviewPointId); // 获取评查点的建议内容作为初始值 const reviewPoint = reviewPoints.find(point => point.id === reviewPointId); if (reviewPoint) { setUserInputText(reviewPoint.suggestion || ''); } }; // 渲染评查统计信息 const renderStatistics = () => { return (
{statistics.total}
总计
通过
警告
错误
); }; // 渲染搜索框 const renderSearchBar = () => { return (
setSearchText(e.target.value)} /> {searchText && ( )}
); }; // 渲染评查点状态标签 const renderStatusBadge = (status: string) => { switch (status) { case 'success': return ( 通过 ); case 'warning': return ( 警告 ); case 'error': return ( 不通过 ); case 'processing': return ( 处理中 ); default: return ( 警告 ); } }; // 渲染人工审核标记 const renderHumanReviewBadge = (reviewPoint: ReviewPoint) => { if (reviewPoint.needsHumanReview) { return ( 需人工 ); } return null; }; // 渲染人工审核注释 const renderHumanReviewNote = (reviewPoint: ReviewPoint) => { if (reviewPoint.needsHumanReview && reviewPoint.humanReviewNote) { return (
{reviewPoint.humanReviewNote} {reviewPoint.humanReviewBy && reviewPoint.humanReviewTime && (
审核人:{reviewPoint.humanReviewBy} | 时间:{reviewPoint.humanReviewTime}
)}
); } return null; }; // 渲染评查点内容与建议 const renderReviewPointContent = (reviewPoint: ReviewPoint) => { // 如果当前评查点不处于编辑状态,只显示简单信息 if (editingReviewPoint !== reviewPoint.id) { if (reviewPoint.status === 'success') { // 已通过的评查点只显示基本信息和人工审核注释 if (reviewPoint.needsHumanReview && reviewPoint.humanReviewNote) { return (

已处理

{reviewPoint.suggestion && (

{reviewPoint.suggestion}

)}
); } return null; } return (
当前值 {reviewPoint.status === 'error' ? '不符合规范' : '需优化'}

{reviewPoint.content || '(内容为空)'}

{reviewPoint.suggestion && (
建议修改为 符合规范
); }; // 渲染无匹配结果提示 const renderEmptyState = () => { return (

没有找到匹配的评查点

请尝试不同的搜索词或清除筛选条件

{(searchText || statusFilter) && ( )}
); }; return (
评查结果
{/* 评查统计 */} {renderStatistics()} {/* 搜索框 */} {renderSearchBar()} {/* 评查点列表 */}
{filteredReviewPoints.length > 0 ? ( filteredReviewPoints.map(reviewPoint => ( )) ) : ( renderEmptyState() )}
); }