From 3c8c4e739112b50aad02b82d732102523949e961 Mon Sep 17 00:00:00 2001 From: Wren Date: Fri, 12 Sep 2025 11:09:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81PDF?= =?UTF-8?q?=E5=92=8CWord=E6=A0=BC=E5=BC=8F=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=80=89=E6=8B=A9=E5=99=A8=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=97=E6=A0=BC=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/files.upload.tsx | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/app/routes/files.upload.tsx b/app/routes/files.upload.tsx index d53a4ee..ce7d8f0 100644 --- a/app/routes/files.upload.tsx +++ b/app/routes/files.upload.tsx @@ -695,12 +695,18 @@ export default function FilesUpload() { } if (files.length > 0) { - // 验证文件类型,只允许PDF文件 + // 验证文件类型,支持PDF和Word const validFiles: File[] = []; let hasInvalidFiles = false; Array.from(files).forEach(file => { - if (file.type === 'application/pdf' || file.name.toLowerCase().endsWith('.pdf')) { + const fileName = file.name.toLowerCase(); + const isValidType = + file.type === 'application/pdf' || fileName.endsWith('.pdf') || + file.type === 'application/msword' || fileName.endsWith('.doc') || + file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || fileName.endsWith('.docx'); + + if (isValidType) { validFiles.push(file); } else { hasInvalidFiles = true; @@ -711,7 +717,7 @@ export default function FilesUpload() { if (hasInvalidFiles) { // 显示错误提示 console.error('【调试-handleContractMainFilesSelected】存在无效的文件类型'); - messageService.error('只能上传PDF格式的文件', { + messageService.error('只支持PDF、Word格式的文件', { title: '文件类型错误', confirmText: '确定', cancelText: '', @@ -746,12 +752,18 @@ export default function FilesUpload() { } if (files.length > 0) { - // 验证文件类型,只允许PDF文件 + // 验证文件类型,支持PDF和Word const validFiles: File[] = []; let hasInvalidFiles = false; Array.from(files).forEach(file => { - if (file.type === 'application/pdf' || file.name.toLowerCase().endsWith('.pdf')) { + const fileName = file.name.toLowerCase(); + const isValidType = + file.type === 'application/pdf' || fileName.endsWith('.pdf') || + file.type === 'application/msword' || fileName.endsWith('.doc') || + file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || fileName.endsWith('.docx'); + + if (isValidType) { validFiles.push(file); } else { hasInvalidFiles = true; @@ -762,7 +774,7 @@ export default function FilesUpload() { if (hasInvalidFiles) { // 显示错误提示 console.error('【调试-handleContractAttachmentFilesSelected】存在无效的文件类型'); - messageService.error('只能上传PDF格式的文件', { + messageService.error('只支持PDF、Word格式的文件', { title: '文件类型错误', confirmText: '确定', cancelText: '', @@ -903,7 +915,7 @@ export default function FilesUpload() { attachmentMergeMode, true, // isReprocess attachmentRemark || undefined, - loaderData.userInfo?.token + loaderData.userInfo?.token as string | undefined ); if (result.error) { @@ -973,7 +985,7 @@ export default function FilesUpload() { templateFile, selectedDocumentId, undefined, // comparisonId - loaderData.userInfo?.token + loaderData.userInfo?.token as string | undefined ); if (result.error) { @@ -2082,8 +2094,8 @@ export default function FilesUpload() { onFilesSelected={handleContractMainFilesSelected} ref={contractMainFileRef} multiple={false} - accept=".pdf" - tipText="请上传合同主文件,格式:PDF" + accept=".pdf,.doc,.docx" + tipText="请上传合同主文件,格式:PDF/Word" mainText="上传合同主文件" buttonText="选择主文件" icon="ri-file-text-line" @@ -2102,8 +2114,8 @@ export default function FilesUpload() { onFilesSelected={handleContractAttachmentFilesSelected} ref={contractAttachmentFileRef} multiple={false} - accept=".pdf" - tipText="请上传合同附件,格式:PDF" + accept=".pdf,.doc,.docx" + tipText="请上传合同附件,格式:PDF/Word" mainText="上传合同附件" buttonText="选择附件" icon="ri-file-copy-line"