<!-- * @Description: 右半屏 1411,各专项大屏 * @Author: 王晓颖 * @Date: 2021-01-20 11:20:11 --> <template> <div ref="container" class="container"> <!--头--> <header-right ref="header"/> <!--内容--> <div ref="body" class="body"> <img :src="frameImg" class="frame-img"/> <div class="frame-div"> <!--<img :src="currentScreen" style="z-index:1002;width:100%;height:100%"/>--> <iframe :src="currentScreen" scrolling="no" frameborder="0"></iframe> </div> </div> </div> </template> <script> import HeaderRight from './components/headerRight' import {fetchAllScreens} from '@/api/doubleScreen' import {mapState} from 'vuex' export default { name: 'RightScreen', components: {HeaderRight}, data () { return { frameImg: require('@/assets/images/1411/frame.png'), // 边框图片 defaultScreen: null, screenList: [] } }, computed: { ...mapState(['doubleScreen']), currentScreen () { const currentScreenName = this.doubleScreen const length = this.screenList.length for (let i = 0; i < length; i++) { if (this.screenList[i].name === currentScreenName) { return this.screenList[i].url } } return this.defaultScreen } }, watch: { doubleScreen (val) { const screenList = this.screenList const length = screenList.length for (let i = 0; i < length; i++) { if (screenList[i].name === val) { // this.$message.info(screenList[i].url) if (screenList[i].url) { window.open(screenList[i].url, '_blank') } } } } }, created () { this.getAllScreen() }, mounted () { const that = this // this.calSize() window.onload = () => { that.calSize() } window.onresize = () => { that.calSize() } }, methods: { // 获取所有大屏 getAllScreen () { fetchAllScreens().then(response => { if (response.code === 200) { this.screenList = response.data } }) }, // 计算屏幕各元素大小 calSize () { // const height = document.body.clientHeight const height = this.$refs.container.offsetHeight const headerHeight = this.$refs.header.$el.clientHeight const bodyHeight = height - headerHeight this.$refs.body.style.height = bodyHeight + 'px' console.log('calSize:' + bodyHeight) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> @media screen and (max-width: 3000px) { .container{ height: 100%; width:100%; } } @media screen and (min-width: 3000px) { .container{ height: 1080px; width:1920px; } } .container{ top:0px !important; background: url("../../assets/images/background/background-left.png") no-repeat; -webkit-background-size: 100% 100%; background-size: 100% 100%; background-color: black; /*display: flex;*/ /*justify-content: space-between;*/ /*flex-direction: column;*/ } .body{ /*flex:1;*/ position:relative; height:calc(100% - 0.6rem); width:100%; .frame-img{ position: absolute; z-index:999; width:96%; height:94%; top:50%; left:50%; transform: translate(-51%,-50%); } .frame-div{ position: absolute; z-index:1000; width:96%; height:94%; top:50%; left:50%; transform: translate(-51%,-50%); padding:0.061rem 0.061rem; iframe{ position:relative; width:100%; height:100%; } } } </style>