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
<template>
<div class="file_doc_v">
<div>
<a class="ant-dropdown-link dlw" style="width: calc(100% - 4px);margin-left:6px;display: block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" :href="fileUrl" :download="fileName">
<a-tag :color="enums.fileColor[getFileExtension(fileName).toLowerCase()]" class="file_name" :title=" fileName" style="cursor: pointer;">{{ fileName }}</a-tag>
</a>
</div>
<a-button v-show="isOpen" shape="circle" size="small" icon="search" @click="FileView()" class="btn" style="margin: 0 2px;" />
<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>
</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_doc_v {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
> div:nth-child(1) {
max-width: calc(100% - 20px);
}
.ant-tag-blue {
background: none !important;
}
.ant-tag {
display: inline !important;
border:0 !important;
font-size: 14px;
}
}
</style>