widgetHtmlSlider.vue
3.99 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<template>
<div :style="style">
<el-carousel arrow="always" height="100%" class="carousel" :direction="carouselStyle.direction"
:indicator-position="carouselStyle.indicatorPosition" :interval="carouselStyle.interval"
:type="carouselStyle.type" :key="carouselKey">
<el-carousel-item v-for="(url, index) in carouselStyle.htmlurlList" :key="index">
<iframe class="carousel-img" :src="url" alt="" />
</el-carousel-item>
</el-carousel>
</div>
</template>
<script>
import Vue from 'vue'
import iframeResize from 'iframe-resizer/js/iframeResizer'
Vue.use(iframeResize)
export default {
name: 'WidgetHtmlSlider',
components: {},
props: {
value: Object,
ispreview: Boolean
},
data() {
return {
options: {},
carouselKey: 0, // 重新渲染组件用
};
},
mounted () {
// 内嵌iframe时
//iframeResize.iframeResizer({log: true,}, this.$refs.iframe);
this.changeFrameHeight();
},
computed: {
transStyle() {
return this.objToOne(this.options);
},
style() {
const autoLayer = this.transStyle.autoLayer;
//整屏显示
if(autoLayer){
return {
position: "absolute",
height: document.body.clientHeight+ "px",
width: document.body.clientWidth+ "px",
left: 0 + "px",
top: 0 + "px",
background:""
};
}else{
return {
position: this.ispreview ? "absolute" : "static",
background: background,
width: this.transStyle.width + "px",
height: this.transStyle.height + "px",
left: this.transStyle.left + "px",
top: this.transStyle.top + "px",
right: this.transStyle.right + "px",
};
}
},
carouselStyle() {
// console.log(this.transStyle.imageAdress,"1111");
return {
//imageList: this.isBlank(this.transStyle.imageAdress)?[]:this.transStyle.imageAdress.split(","),
htmlurlList: ['http://localhost:8888/#/bigscreen/viewer?reportCode=BI_YS001_1680838448088_1684993969021'],
//htmlurlList: [],
//['http://localhost:8888/#/bigscreen/viewer?reportCode=dev_1_1680589693462','http://localhost:8888/#/bigscreen/viewer?reportCode=BI_YS001_1680838448088_1684993969021','http://localhost:8888/#/bigscreen/viewer?reportCode=BI_YS001_1680838448088'],
direction: !this.transStyle.tabType ? this.transStyle.tabDirection : 'horizontal',
indicatorPosition: this.transStyle.tabSelector,
interval: this.transStyle.tabTime,
type: this.transStyle.tabType
}
}
},
watch: {
value: {
handler(val) {
this.options = val;
},
deep: true
},
carouselStyle: {
handler(newValue, oldValue) {
if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
this.carouselKey++;
}
},
},
},
created() {
this.options = this.value;
},
methods: {
dianji() {
//设置后就是id==con_lf_top_div 的容器全屏
let case1 = document.getElementById("iframeId");
if (this.fullscreen) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
} else {
if (case1.requestFullscreen) {
case1.requestFullscreen();
} else if (case1.webkitRequestFullScreen) {
case1.webkitRequestFullScreen();
} else if (case1.mozRequestFullScreen) {
case1.mozRequestFullScreen();
} else if (case1.msRequestFullscreen) {
// IE11
case1.msRequestFullscreen();
}
}
},
},
}
</script>
<style scoped lang="scss">
.carousel {
width: 100%;
height: 100%;
}
.carousel-img {
width: 100%;
height: 100%;
}
</style>