<template>
   <iframe :src="src" frameborder="0" width="100%" height="100%"></iframe>
</template>

<script>
   export default{
      name: 'Iframe',
      data(){
         return{
            src: ''
         }
      },
      watch:{
         '$route'(){
            this.getSrc();
         },
         'permissions_object':{
            deep: true,
            handler(data){
               this.getSrc();
            }
         }
      },
      created(){
         this.enter();
         this.getSrc();
      },
      beforeDestroy(){
         this.leave();
      },
      activated(){
         this.enter();
         this.getSrc();
      },
      deactivated(){
         this.leave();
      },
      methods:{
         enter(){
            const $d = $('.layout-content');
            if($d){
               $d.addClass('height');
            }
         },

         leave(){
            const $d = $('.layout-content');
            if($d){
               $d.removeClass('height');
            }
         },

         getSrc(){
            const mid = this.$route.query.mid;
            if(mid && mid in this.permissions_object){
               this.src = this.permissions_object[mid].path;
            }
         }
      }
   }
</script>
