Browse Source

2024-04-17

master
zelian_wu 2 years ago
parent
commit
48349b2ff6
  1. 34
      src/views/modules/test/file/testFile.vue

34
src/views/modules/test/file/testFile.vue

@ -88,27 +88,43 @@ export default {
}, },
previewFile(row){ 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())){ 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())){ 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())){ if (pdf.includes(row.fileType.toLowerCase())){
type = 'application/pdf'
type = 'application/pdf';
} }
downLoadQuotationFile(row).then(({data}) => { downLoadQuotationFile(row).then(({data}) => {
const blob = new Blob([data], { type: type }); const blob = new Blob([data], { type: type });
// URL // URL
const fileURL = URL.createObjectURL(blob); const fileURL = URL.createObjectURL(blob);
// //
const newTab = window.open(fileURL, '_blank'); const newTab = window.open(fileURL, '_blank');
})
});
}, },
downloadBtn(){ downloadBtn(){
if (this.selectionFile.length < 1){ if (this.selectionFile.length < 1){

Loading…
Cancel
Save