This commit is contained in:
zhaoxiao
2021-09-24 08:55:10 +08:00
5 changed files with 377 additions and 11 deletions
+13 -1
View File
@@ -1,12 +1,17 @@
<template>
<!-- 父组件的文件id如果是异步获取的 需要加上v-if判断-->
<div style="display: inline-block"> <span @click="handlePreview(item)" class="color-blue" v-for="(item) of fileList" :key="item.id">{{ item.name +' ' }}</span></div>
<div style="display: inline-block">
<span v-for="(item) of fileList" :key="item.id">{{ item.name +' ' }}
<span class="m-l-4 color-blue" @click="handleDownLoad(item)">下载</span> <span class="m-l-4 color-blue" @click="handlePreview(item)">查看</span>
</span>
</div>
</template>
<script>
import Vue from 'vue'
import {ACCESS_TOKEN} from '@/store/mutation-types'
import {getFileInfo} from '@/api/api'
import {downloadFile} from '@api/manage'
// eslint-disable-next-line
const Base64 = require('js-base64').Base64
@@ -72,6 +77,10 @@ export default {
this.fileList = []
}
},
handleDownLoad(file){
console.log(file)
downloadFile(`sys/common/download/${file.id}`, file.name)
},
handlePreview(file) {
if (file && file.id) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
@@ -89,4 +98,7 @@ export default {
color: #069f99 !important;
cursor: pointer;
}
.m-l-4 {
margin-left: 4px;
}
</style>