|
|
|
|
@ -205,18 +205,18 @@
|
|
|
|
|
<icon name="el-icon-Close" :size="28" /> |
|
|
|
|
</button> |
|
|
|
|
<div class="btn-content"> |
|
|
|
|
<!-- <el-button @click="download" type="primary" plain>--> |
|
|
|
|
<!-- <template #icon>--> |
|
|
|
|
<!-- <icon name="el-icon-Download" :size="20" />--> |
|
|
|
|
<!-- </template>--> |
|
|
|
|
<!-- 下载文件--> |
|
|
|
|
<!-- </el-button>--> |
|
|
|
|
<!-- <el-button v-print="'#printTable'" type="primary" plain>--> |
|
|
|
|
<!-- <template #icon>--> |
|
|
|
|
<!-- <icon name="el-icon-Download" :size="20" />--> |
|
|
|
|
<!-- </template>--> |
|
|
|
|
<!-- 打印文件--> |
|
|
|
|
<!-- </el-button>--> |
|
|
|
|
<el-button @click="download" type="primary" plain> |
|
|
|
|
<template #icon> |
|
|
|
|
<icon name="el-icon-Download" :size="20" /> |
|
|
|
|
</template> |
|
|
|
|
下载文件 |
|
|
|
|
</el-button> |
|
|
|
|
<el-button type="primary" plain @click="handlePrintnew"> |
|
|
|
|
<template #icon> |
|
|
|
|
<icon name="el-icon-Printer" :size="20" /> |
|
|
|
|
</template> |
|
|
|
|
打印文件 |
|
|
|
|
</el-button> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
@ -257,6 +257,39 @@ let initialX = 0;
|
|
|
|
|
let initialY = 0; |
|
|
|
|
const fileRrror = ref(false); |
|
|
|
|
const tableDatas = ref([]) |
|
|
|
|
|
|
|
|
|
function canPrint(file) { |
|
|
|
|
if (!file?.fileName) return false |
|
|
|
|
const type = getFileType(file.fileName) |
|
|
|
|
return type === FileType.IMG || type === FileType.PDF |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function handlePrintnew() { |
|
|
|
|
const file = activeFile.value |
|
|
|
|
if (!file) return |
|
|
|
|
|
|
|
|
|
// 1️⃣ 不支持打印 |
|
|
|
|
if (!canPrint(file)) { |
|
|
|
|
ElMessage.warning('该文件格式不支持打印,请下载后打印') |
|
|
|
|
downloadFile(file) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2️⃣ 图片:直接打印当前预览区域 |
|
|
|
|
if (getFileType(file.fileName) === FileType.IMG) { |
|
|
|
|
window.print() |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3️⃣ PDF:新窗口打开再打印(最稳定) |
|
|
|
|
if (getFileType(file.fileName) === FileType.PDF) { |
|
|
|
|
const url = `${BASE_PATH}/file/stream/${file.filePath}` |
|
|
|
|
const win = window.open(url) |
|
|
|
|
win && win.print() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function filePreview(file) { |
|
|
|
|
preview.value = true; |
|
|
|
|
activeFile.value = file; |
|
|
|
|
@ -265,7 +298,7 @@ function filePreview(file) {
|
|
|
|
|
translateX.value = 0; |
|
|
|
|
translateY.value = 0; |
|
|
|
|
moveFlag = false; |
|
|
|
|
downloadFile(file) |
|
|
|
|
// downloadFile(file) |
|
|
|
|
// if (!file?.filePath) { |
|
|
|
|
// ElMessage?.warning?.('文件路径不存在,无法下载') |
|
|
|
|
// return |
|
|
|
|
|