| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <template>
- <!-- 状态详情 -->
- <div>
- <div
- v-if="showFrame"
- class="frame-window"
- >
- <div class="frame-window-title">
- {{ title }}
- <img
- class="close-btn"
- src="/static/assets/client-base-v4/image/close.png"
- @click="close"
- />
- </div>
- <div class="frame-window-content">
- <iframe
- id="ifr_diagnose"
- :src="frameSrc"
- class="frame-window-content-iframe"
- />
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- components: {
- },
- props: [],
- emits: ['close'],
- data: function () {
- return {
- title: null,
- frameSrc: null,
- showFrame: false,
- };
- },
- mounted: function(){
- var _self = this;
- window.addEventListener('message', this.onMessage);
- },
- beforeUnmount : function() {
- // 在组件生命周期结束的时候销毁。
- window.removeEventListener('message', this.onMessage, false);
- },
- methods: {
- /**
- * 打开一个网址
- * @param src 待打开的网址
- * @param title 标题
- */
- open: function (src, title) {
- this.title = title;
- this.frameSrc = src;
- this.showFrame = true;
- },
- close: function () {
- this.showFrame = false;
- this.$emit('close');
- },
- onMessage: function(e){
- var _self = this;
- if(e.data.cmd === 'close'){
- _self.close();
- }
- },
- },
- };
- </script>
- <style scoped>
- .frame-window {
- position: fixed;
- top: 50px;
- right: 50px;
- bottom: 50px;
- left: 50px;
- }
- .frame-window .frame-window-title {
- position: fixed;
- top: 0px;
- right: 0px;
- left: 0px;
- height: 30px;
- background: #f1f1f1;
- padding-left: 5px;
- padding-top: 5px;
- font-size: 16px;
- font-weight: bold;
- }
- .frame-window .frame-window-title .close-btn {
- position: fixed;
- top: 0px;
- right: 0px;
- width: 30px;
- height: 30px;
- cursor: pointer;
- }
- .frame-window .frame-window-content {
- position: fixed;
- top: 30px;
- right: 0px;
- bottom: 0px;
- left: 0px;
- }
- .frame-window-content-iframe {
- width: 100%;
- height: 100%;
- }
- </style>
|