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
| <template>
| <a-modal
| title="预览图片"
| :footer="null"
| :width="900"
| :visible="visible"
| @cancel="handleCancel"
| >
| <a-spin :spinning="divLoading">
| <div style="text-align: center">
| <img :src="src" style="max-width: 99%">
| </div>
| </a-spin>
| </a-modal>
| </template>
| <script>
| import { sysFileInfoPreview } from '@/api/modular/system/fileManage'
| export default {
| data () {
| return {
| visible: false,
| src: '',
| divLoading: false
| }
| },
| methods: {
| /**
| * 初始化
| */
| preview (record) {
| this.visible = true
| this.divLoading = true
| this.sysFileInfoPreview(record)
| },
| /**
| * 获取图片并转为链接
| */
| sysFileInfoPreview (record) {
| sysFileInfoPreview({ id: record.id }).then((res) => {
| this.divLoading = false
| this.downloadfile(res)
| }).catch((err) => {
| this.divLoading = false
| this.$message.error('预览错误:' + err.message)
| })
| },
| /**
| * 转图片类型
| */
| downloadfile (res) {
| const blob = new Blob([res])
| this.src = window.URL.createObjectURL(blob)
| },
| handleCancel () {
| this.src = ''
| this.visible = false
| }
| }
| }
| </script>
|
|