1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<template>
<div class="file_view">
<a-tag :color="enums.fileColor[getFileExtension(fileName).toLowerCase()]" class="file_name" :title=" fileName">{{ fileName }}</a-tag>
<a-button v-show="isOpen" shape="circle" size="small" icon="search" @click="FileView()" class="btn" />
<a-modal v-model="visibleFileView" :title="'[' + fileName + '] 文件查看'" width="1000px" :dialog-style="{ top: '10%' }" :footer="null" destroyOnClose>
<preview-file v-model="fileUrl" :fileName="fileName"></preview-file>
</a-modal>
<a class="ant-dropdown-link dlw" style="margin-left:6px" :href="fileUrl" :download="fileName">
<a-icon type="download" />
</a>
</div>
</template>
<script>
import { checkImageFileType, checkDocumentFileType, getFileExtension, enums } from "@/views/utils/common"
import previewFile from '@/views/components/common/previewFile'
export default {
name: 'documentView',
components: {
previewFile
},
data () {
return {
visibleFileView: false,
enums: enums,
};
},
props: {
fileUrl: {
type: String,
default () {
return null;
},
},
fileName: {
type: String,
default () {
return null;
},
},
imageArray: {
type: Array,
default () {
return []
}
}
},
computed: {
isOpen: function () {
return checkDocumentFileType(this.fileName)
}
},
methods: {
getFileExtension,
FileView () {
if (checkImageFileType(this.fileName)) {//文件为图片
this.$viewerApi({ images: this.imageArray })
} else {
if (checkDocumentFileType(this.fileName))
this.visibleFileView = true
}
},
}
};
</script>
<style scoped lang="less">
.file_view {
position: relative;
.file_name {
max-width: calc(100% - 55px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: inline-block;
vertical-align: bottom;
}
.btn {
position: absolute;
right: 26px;
}
.dlw {
position: absolute;
right: 10px;
}
}
</style>