/** * 文件详情组件 * 显示文件基本信息、合同信息和评查信息 */ import { ReactNode } from 'react'; // 文件基本信息 interface FileInfo { fileName: string; contractNumber: string; fileSize: string; fileFormat: string; pageCount: number; uploadTime: string; uploadUser: string; fileType: string; } // 合同信息 interface ContractInfo { contractType: string; signDate: string; parties: { partyA: string; partyB: string; }; amount: string; period: string; } // 评查信息 interface ReviewInfo { reviewTime: string; reviewModel: string; ruleGroup: string; result: string; issueCount: number; } interface FileDetailsProps { fileInfo: FileInfo; contractInfo: ContractInfo; reviewInfo: ReviewInfo; } export function FileDetails({ fileInfo, contractInfo, reviewInfo }: FileDetailsProps) { // 情况状态对应的标签 const controlContractShow = false const renderResultBadge = (result: string) => { switch (result) { case 'success': return ( 通过 ); case 'warning': return ( 警告 ); case 'error': return ( 不通过 ); default: return ( 警告 ); } }; // 渲染信息区块 const renderInfoSection = (title: string, icon: string, color: string, children: ReactNode) => { // 根据color参数返回对应的具体类名 const getBgClass = (colorName: string) => { switch(colorName) { case 'blue': return 'bg-blue-50'; case 'green': return 'bg-green-50'; case 'purple': return 'bg-purple-50'; default: return 'bg-gray-50'; } }; const getTextClass = (colorName: string) => { switch(colorName) { case 'blue': return 'text-blue-500'; case 'green': return 'text-green-500'; case 'purple': return 'text-purple-500'; default: return 'text-gray-500'; } }; const getTextTitleClass = (colorName: string) => { switch(colorName) { case 'blue': return 'text-blue-700'; case 'green': return 'text-green-700'; case 'purple': return 'text-purple-700'; default: return 'text-gray-700'; } }; return (

{title}

{children}
); }; // 渲染信息行 const renderInfoRow = (label: string, value: string | ReactNode) => { return (
{label}:
{value}
); }; return (
{/* 文件基本信息 */} {renderInfoSection('文件基本信息', 'ri-file-info-line', 'blue', (
{renderInfoRow('文件名称', fileInfo.fileName)} {renderInfoRow(fileInfo.fileType != "1" ? '卷宗编号' : '合同编号', fileInfo.contractNumber)} {renderInfoRow('文件大小', fileInfo.fileSize)} {renderInfoRow('文件格式', fileInfo.fileFormat)} {renderInfoRow('页数', `${fileInfo.pageCount}页`)} {renderInfoRow('上传时间', fileInfo.uploadTime)} {/* {renderInfoRow('上传用户', fileInfo.uploadUser)} */}
))} {/* 合同信息 */} { controlContractShow && ( renderInfoSection('合同信息', 'ri-file-paper-2-line', 'green', (
{renderInfoRow('合同类型', contractInfo.contractType)} {renderInfoRow('签约日期', contractInfo.signDate)} {renderInfoRow('合同当事人', (
甲方:{contractInfo.parties.partyA}
乙方:{contractInfo.parties.partyB}
))} {renderInfoRow('合同金额', contractInfo.amount)} {renderInfoRow('履行期限', contractInfo.period)}
)) )} {/* 评查信息 */} {renderInfoSection('评查信息', 'ri-search-eye-line', 'purple', ( <>
{renderInfoRow('评查时间', reviewInfo.reviewTime)} {renderInfoRow('评查模型', reviewInfo.reviewModel)} {renderInfoRow('评查规则组', reviewInfo.ruleGroup)} {renderInfoRow('评查结果', (
{renderResultBadge(reviewInfo.result)} {reviewInfo.issueCount > 0 && (共发现{reviewInfo.issueCount}个问题)}
))}
))}
); }