feature: 上传组件添加下载功能
This commit is contained in:
@@ -17,6 +17,11 @@
|
||||
@click="onPreview(file)"
|
||||
>
|
||||
{{ file.name }}
|
||||
<template v-if="down">
|
||||
<span v-if="file.id !== ''" style="margin-left: 7px;">
|
||||
<i class="el-icon-download" title="下载" @click="onPreview(file, 'down')" />
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -104,7 +109,11 @@ export default {
|
||||
view: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
down: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
@@ -208,14 +217,22 @@ export default {
|
||||
this.$emit('update:names', names)
|
||||
},
|
||||
// 文件预览及下载
|
||||
onPreview (file) {
|
||||
onPreview (file, type) {
|
||||
let attId = ''
|
||||
if(file && file.id) {
|
||||
attId = file.id
|
||||
}else {
|
||||
attId = file.response.data.id
|
||||
}
|
||||
this.$preview(attId)
|
||||
if (type === 'down') {
|
||||
if (attId) {
|
||||
window.open('/api/att/attFile/downloadFileForSarNew?fileId=' + attId)
|
||||
} else {
|
||||
this.$message.warning('文件不存在,下载失败')
|
||||
}
|
||||
} else {
|
||||
this.$preview(attId)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user