//文件预览
handleView(file) {
this.fileType = this.getFileType(file.filePath)
if(this.fileType === "pdf" || this.fileType === "picture") {
window.open(this.$util.baseUrl + "/api/preview?path=/" + file.filePath);
} else {
window.open(this.$util.baseUrl + "/api/downloadFile?path=/" + file.filePath)
}
},
//判断文件类型
getFileType (url) {
let pdfReg = /^.+(\.pdf)$/
let txtReg = /^.+(\.txt)$/
let wordReg = /^.+(\.doc|\.docx)$/
let excelReg = /^.+(\.xls|\.xlsx)$/
let jpgReg = /^.+(\.png|\.jpg|\.jpeg|\.bmp)$/
if (pdfReg.test(url)) {
return 'pdf'
}
if (txtReg.test(url)) {
return 'txt'
}
if (wordReg.test(url)) {
return 'word'
}
if (excelReg.test(url)) {
return 'excel'
}
if (jpgReg.test(url)) {
return 'picture'
}
},