IframeSrc.vue
2.45 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template>
<el-dialog
:visible.sync="iframeSrcDialog"
:close-on-click-modal="false"
width="80%"
:show-close="false"
top="52px"
>
<p class="arrow">
<el-button
icon="el-icon-download"
@click="download()"
style="download"
type="primary"
size="mini"
>下载</el-button
>
<span
style="float :right;padding-right:40px;font-size: 20px;color: rgb(223 227 234);cursor: pointer;"
@click="close"
><i style="font-size: 20px;" class="el-icon-close"></i
></span>
</p>
<iframe
:src="dataSrc"
style="height:100%;width:100%;border:0;"
align="middle"
></iframe>
</el-dialog>
</template>
<script>
import { Message } from "element-ui";
import req from "@/request.js";
export default {
name: "iframe-src",
props: ["iframeSrc", "fileRow"],
data() {
return {
iframeSrcDialog: false,
dataSrc: ''
};
},
watch: {
iframeSrc: function(newVal, oldVal) {
if(newVal){
let _this = this;
req.get(this.iframeSrc,'arraybuffer').then(response=>{
let type = response.headers['content-type'];
if(type){
_this.dataSrc = window.URL.createObjectURL(new Blob([response.data], { type: type }));
}else{
_this.dataSrc = window.URL.createObjectURL(new Blob([response.data]));
}
});
}
}
},
methods: {
handleOpen() {
this.iframeSrcDialog = true;
},
//关闭弹框
close() {
this.iframeSrcDialog = false;
},
//附件下载
download() {
req.download(
"${portal}/system/file/v1/downloadFile?fileId=" + this.fileRow.id
);
}
}
};
</script>
<style lang="scss" scoped>
.currentPage {
cursor: pointer;
color: #8c8e92;
}
.currentPage:hover {
color: #2761ff;
}
.arthis_.fileRow{
position: fixed;
top: 0px;
z-index: 2;
width: 100%;
background-color: #191919;
padding: 12px 0;
margin: 0;
text-align :center;
}
/deep/.el-dialog__body{
height: calc(100% - 52px);
color: #606266;
font-size: 14px;
padding:0;
padding-left:30px;
}
/deep/.el-dialog {
height: calc(100% - 52px);
position: relative;
margin: 0 auto 0;
background: #fff;
border-radius: 2px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
-webkit-box-sizing: border-box;
box-sizing: border-box;
width: 50%;
}
</style>