更新文件上传功能,支持PDF和Word格式的文件验证,修改相关提示信息,优化文件选择器的接受格式。
This commit is contained in:
+24
-12
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user