|
|
|
@ -231,6 +231,7 @@ import "@vue-office/docx/lib/index.css"; |
|
|
|
import "@vue-office/excel/lib/index.css"; |
|
|
|
import "@vue-office/excel/lib/index.css"; |
|
|
|
import VueOfficeDocx from "@vue-office/docx"; |
|
|
|
import VueOfficeDocx from "@vue-office/docx"; |
|
|
|
import VueOfficeExcel from "@vue-office/excel"; |
|
|
|
import VueOfficeExcel from "@vue-office/excel"; |
|
|
|
|
|
|
|
import {ElMessage} from "element-plus"; |
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
const props = defineProps({ |
|
|
|
files: { |
|
|
|
files: { |
|
|
|
@ -257,9 +258,43 @@ let initialY = 0; |
|
|
|
const fileRrror = ref(false); |
|
|
|
const fileRrror = ref(false); |
|
|
|
const tableDatas = ref([]) |
|
|
|
const tableDatas = ref([]) |
|
|
|
function filePreview(file) { |
|
|
|
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 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
preview.value = true; |
|
|
|
// 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; |
|
|
|
activeFile.value = file; |
|
|
|
|
|
|
|
console.log(activeFile.value) |
|
|
|
|
|
|
|
preview.value = true; |
|
|
|
rotate.value = 0; |
|
|
|
rotate.value = 0; |
|
|
|
scale.value = 1; |
|
|
|
scale.value = 1; |
|
|
|
translateX.value = 0; |
|
|
|
translateX.value = 0; |
|
|
|
|