IframePage.vue 2.43 KB
<template>
    <div class='h-full iframe-page'>
        <div class='p-3 text-black text-center shrink-0 doc-nav-bar'>
            <span @click='onBack' class='text-12 back-bt'>
                <doc-icon type='doc-left2' />
            </span>
            <span style='min-height: .16rem;display: inline-block'>{{ pageTitle }}</span>
        </div>
        <iframe :src='iframeSrc' style='border: 0;width: 100%;height: calc(99% - 50px)' :key='iframeSrc' v-if='iframeSrc'
                allowFullscreen>
        </iframe>
        <div v-else />
    </div>
</template>

<script>
// import {getCateInfoByMenuId} from "@/views/statScreen/config";

export default {
    props: {
        src: String,
        pageTitle: String
    },
    data() {
        return {
            iframeSrc: ''
        }
    },
/*    computed: {
        pageTitle() {
            return this.$route.query.pageTitle || ''
        }
    },*/
    beforeUnmount() {
        this.iframeSrc = ''
    },
    watch: {
        src: {
            handler() {
                debugger
                this.load()
            },
            immediate: true
        }
    },

    methods: {
        load() {
            // let menuList = this.$store.state.menu || []
            // let rou = this.$route.fullPath
            // let result = menuList.filter(item => item.frontActionUrl == rou)[0]
            // let menuId = result.id
            // let lobId = result.lobId
            // if (lobId && lobId!='0'){
            //   getCateInfoByMenuId(menuId).then(res => {
            //     this.openIframe(res.data.treeCode, menuId);
            //   });
            // }else {
            this.iframeSrc = `${this.src}`
            // }
        },
        openIframe(treeCode, menuId) {
            let res = ''
            res = `${this.src}${this.src?.includes('?') ? '&' : '?'}source=MB&menuId=${menuId}`
            if (treeCode) {
                res = `${this.src}${this.src?.includes('?') ? '&' : '?'}treeCode=${treeCode}&unitTreeCode=${treeCode}&source=MB&menuId=${menuId}`
            }
            this.iframeSrc = res
        },
        onBack() {
            this.$router.back()
        }
    }
}
</script>

<style lang='less' scoped>
// 顶部导航栏
.doc-nav-bar {
    position: relative;
    border-bottom: 1px solid #3C3C435C;
    font-size: 18px;
    font-weight: 600;

    .back-bt {
        position: absolute;
        left: .16rem;
        top: 50%;
        transform: translateY(-50%);
    }
}

</style>