diff --git a/src/views/modules/test/file/testFile.vue b/src/views/modules/test/file/testFile.vue index b12bad4..0a5925a 100644 --- a/src/views/modules/test/file/testFile.vue +++ b/src/views/modules/test/file/testFile.vue @@ -88,27 +88,43 @@ export default { }, previewFile(row){ // 预览文件 - let image = ['jpg', 'jpeg', 'png', 'gif', 'bmp'] - let type = '' + let image = ['jpg', 'jpeg', 'png', 'gif', 'bmp']; + let type = ''; if (image.includes(row.fileType.toLowerCase())){ - type = 'image/'+row.fileType + type = 'image/' + row.fileType; } - let office = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'] + let video = ['mp4', 'avi', 'mov', 'wmv', 'flv']; + if (video.includes(row.fileType.toLowerCase())){ + type = 'video/' + row.fileType; + } + + let txt = ['txt']; + if (txt.includes(row.fileType.toLowerCase())){ + type = 'text/plain'; + } + let office = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']; if (office.includes(row.fileType.toLowerCase())){ - // type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' - return + if (row.fileType.toLowerCase() === 'doc' || row.fileType.toLowerCase() === 'docx'){ + type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; + } else if (row.fileType.toLowerCase() === 'ppt' || row.fileType.toLowerCase() === 'pptx'){ + type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; + } else { + type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + } } - let pdf = ['pdf'] + + let pdf = ['pdf']; if (pdf.includes(row.fileType.toLowerCase())){ - type = 'application/pdf' + type = 'application/pdf'; } + downLoadQuotationFile(row).then(({data}) => { const blob = new Blob([data], { type: type }); // 创建URL来生成预览 const fileURL = URL.createObjectURL(blob); // 在新标签页中打开文件预览 const newTab = window.open(fileURL, '_blank'); - }) + }); }, downloadBtn(){ if (this.selectionFile.length < 1){