Browse Source

文件浏览组件--点击预览的时候直接下载,去除下载文件、打印文件按钮

main
buaixuexideshitongxue 3 weeks ago
parent
commit
d77e4e8f67
  1. 34
      src/components/file/list.vue

34
src/components/file/list.vue

@ -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 v-print="'#printTable'" type="primary" plain>-->
<!-- <template #icon>-->
<!-- <icon name="el-icon-Download" :size="20" />-->
<!-- </template>-->
<!-- 打印文件-->
<!-- </el-button>-->
</div>
</div>
@ -265,6 +265,7 @@ function filePreview(file) {
translateX.value = 0;
translateY.value = 0;
moveFlag = false;
downloadFile(file)
// if (!file?.filePath) {
// ElMessage?.warning?.('')
// return
@ -309,6 +310,15 @@ function filePreview(file) {
// moveFlag = false;
}
function downloadFile(file) {
const a = document.createElement('a')
a.href = `${BASE_PATH}/file/stream/${file.filePath}`
a.download = file.fileName || ''
a.style.display = 'none'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
function remove(index) {
const files = [...props.files];

Loading…
Cancel
Save