IframePage.vue 1.52 KB
<template>
  <div class="h-full iframe-page">
    <iframe :src="iframeSrc" style="border: 0;width: 100%;height: 99%" :key="iframeSrc" v-if="iframeSrc" allowFullscreen>
    </iframe>
    <div v-else/>
  </div>
</template>

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

export default {
  props: {
    src: String
  },
  data() {
    return {
      iframeSrc: ''
    }
  },
  // computed:{
  //   stat(){
  //     return this.$route.params.stat
  //   }
  // },
  beforeUnmount() {
    this.iframeSrc = ''
  },
  watch: {
    src: {
      handler() {
        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 {
        debugger
        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
    }
  }
}
</script>

<style lang="less" scoped>

</style>