|
|
|
|
@ -258,48 +258,55 @@ let initialY = 0;
|
|
|
|
|
const fileRrror = ref(false); |
|
|
|
|
const tableDatas = ref([]) |
|
|
|
|
function filePreview(file) { |
|
|
|
|
if (!file?.filePath) { |
|
|
|
|
ElMessage?.warning?.('文件路径不存在,无法下载') |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
const url = `${BASE_PATH}/file/stream/${file.filePath}` |
|
|
|
|
const type = getFileType(file.fileName) |
|
|
|
|
// 1. PDF:新窗口打开 |
|
|
|
|
if (type === FileType.PDF) { |
|
|
|
|
window.open(url, '_blank') |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
// 2. Word / Excel:直接下载(不打开窗口) |
|
|
|
|
if ( |
|
|
|
|
type === FileType.WORD || |
|
|
|
|
type === FileType.EXCEL |
|
|
|
|
) { |
|
|
|
|
const a = document.createElement('a') |
|
|
|
|
a.href = url |
|
|
|
|
a.download = file.fileName || '' |
|
|
|
|
document.body.appendChild(a) |
|
|
|
|
a.click() |
|
|
|
|
document.body.removeChild(a) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3. 其他类型:默认直接下载 |
|
|
|
|
const a = document.createElement('a') |
|
|
|
|
a.href = url |
|
|
|
|
a.download = file.fileName || '' |
|
|
|
|
document.body.appendChild(a) |
|
|
|
|
a.click() |
|
|
|
|
document.body.removeChild(a) |
|
|
|
|
|
|
|
|
|
activeIndex.value = index; |
|
|
|
|
activeFile.value = file; |
|
|
|
|
console.log(activeFile.value) |
|
|
|
|
preview.value = true; |
|
|
|
|
activeFile.value = file; |
|
|
|
|
rotate.value = 0; |
|
|
|
|
scale.value = 1; |
|
|
|
|
translateX.value = 0; |
|
|
|
|
translateY.value = 0; |
|
|
|
|
moveFlag = false; |
|
|
|
|
// if (!file?.filePath) { |
|
|
|
|
// ElMessage?.warning?.('文件路径不存在,无法下载') |
|
|
|
|
// return |
|
|
|
|
// } |
|
|
|
|
// const url = `${BASE_PATH}/file/stream/${file.filePath}` |
|
|
|
|
// const type = getFileType(file.fileName) |
|
|
|
|
// // 1. PDF:新窗口打开 |
|
|
|
|
// if (type === FileType.PDF) { |
|
|
|
|
// window.open(url, '_blank') |
|
|
|
|
// return |
|
|
|
|
// } |
|
|
|
|
// // 2. Word / Excel:直接下载(不打开窗口) |
|
|
|
|
// if ( |
|
|
|
|
// type === FileType.WORD || |
|
|
|
|
// type === FileType.EXCEL |
|
|
|
|
// ) { |
|
|
|
|
// const a = document.createElement('a') |
|
|
|
|
// a.href = url |
|
|
|
|
// a.download = file.fileName || '' |
|
|
|
|
// document.body.appendChild(a) |
|
|
|
|
// a.click() |
|
|
|
|
// document.body.removeChild(a) |
|
|
|
|
// return |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// // 3. 其他类型:默认直接下载 |
|
|
|
|
// const a = document.createElement('a') |
|
|
|
|
// a.href = url |
|
|
|
|
// a.download = file.fileName || '' |
|
|
|
|
// document.body.appendChild(a) |
|
|
|
|
// a.click() |
|
|
|
|
// document.body.removeChild(a) |
|
|
|
|
// |
|
|
|
|
// activeIndex.value = index; |
|
|
|
|
// activeFile.value = file; |
|
|
|
|
// console.log(activeFile.value) |
|
|
|
|
// preview.value = true; |
|
|
|
|
// rotate.value = 0; |
|
|
|
|
// scale.value = 1; |
|
|
|
|
// translateX.value = 0; |
|
|
|
|
// translateY.value = 0; |
|
|
|
|
// moveFlag = false; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|