<template>
  <div class="app-container">
    <!--预览-->
    <el-dialog title="预览" width="80%" :visible="IsPreview?true:false"  @close="closeHandle" append-to-body>
      <div style="height:100vh;">
        <iframe :src="IsPreview" style="display: block;width: 100%;height: 100%;"></iframe>
      </div>
    </el-dialog>
  </div>
</template>
<script>

export default {
  name: "preview",

  props: {
    parArray:{
      type: Array
    },

  },
  watch:{
    parArray(a){
      if(a){
        this.onClickOpenPreview();
      }
    }
  },
  data() {
    return {
      // 预览数据
      IsPreview:false, // 控制预览弹窗字段
    };
  },
  created() {

    // this.getList();
  },
  methods: {

    // 打开预览
    onClickOpenPreview: function () {

      const url = this.parArray[0];
      if (!url) {
        this.$modal.msgSuccess("文件不存在");
      }
      if (url.indexOf('pdf')!=-1) {
        this.IsPreview=url

      }else{
        var str = "https://view.officeapps.live.com/op/view.aspx?src=";

        // if( checkRoleExclusionAdmin(['member_user','sub_member_user']) && this.parArray[1]<10  ){
        //     str = "https://view.officeapps.live.com/op/embed.aspx?src=" ;
        // }
        this.IsPreview=str+url;
      }
    },
    closeHandle(){
      this.IsPreview=''
      this.$emit('watchChild','0');
      this.$emit('close')
    },
  }
};
</script>
