infodialog.vue 3.38 KB
<template>
    <div class="info-dialog" v-if="infoDialogShow">
        <iframe :src="iframeSrc" ref="infoIframe" frameborder="0" class="info-iframe"></iframe>
    </div>
</template>

<script>
    import Vue from 'vue'
    export default {
        data () {
            return {
                infoDialogShow: false,
                iframeSrc: '',
                visiableTimer: null
            }
        },
        methods: {
            showInfo(info, isVisible, type) {
                this.infoDialogShow = true;
                window.infoDialogVm = this;
                if(arguments.length > 1) {
                    this.infoDialogShow = isVisible;
                    switch (type) {
                        case 'info':
                            this.iframeSrc = 'static/infoDialog.html';
                            break;
                        case 'picDetail':
                            this.iframeSrc = 'static/picDetailDialog.html';
                            break;
                        case 'paramSetting':
                            this.iframeSrc = 'static/paramSettingDialog.html';
                            break;
                        default:
                            break;
                    }
                } else if(arguments.length == 1) {
                    this.iframeSrc = 'static/infoDialog.html';
                } else {
                    return;
                }
                if(this.infoDialogShow) {
                    let self = this;
                    if(self && !self._isDestroyed) {
                        self.visiableTimer = setTimeout(() => {
                            try {
                                this.$refs.infoIframe.contentWindow.globalVm = this;
                            } catch (error) { }
                            if(type == undefined) {
                                try {
                                    if(this.$refs.infoIframe.contentWindow) {
                                        this.$refs.infoIframe.contentWindow.changeText(info, this);
                                    }
                                } catch (err) {
                                    this.infoDialogShow = false;
                                    eval("console.log('自定义弹窗changeText异常:', err.message)")
                                }
                            } else {
                                try {
                                    if(this.$refs.infoIframe.contentWindow) {
                                        this.$refs.infoIframe.contentWindow.filterType(info);
                                    }
                                } catch (err) {
                                    this.infoDialogShow = false;
                                    eval("console.log('自定义弹窗filterType异常:', err.message)");
                                }
                            }
                        }, 500);
                    }
                }
            },
            hide() {
                this.infoDialogShow = false;
                window.clearTimeout(this.visiableTimer);
            }
        }
    }
</script>

<style scoped>
    .info-dialog {
        width: 100%;
        height: 100%;
        position: relative;
        z-index: 99990;
    }
    .info-iframe {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        /* z-index: 99990; */
    }
</style>