<template>
  <div class="height_100">
    <el-container>
        <el-header style="height: auto;">
        <div style="width:100%">
          <div>
            <div style="text-align: start;padding-left: 10px;position: relative;">
                <img src="@/assets/visual/fixed.png" width="20px" height="20px" v-if="fix === true && value == true" @click="qx" style="" />
                <img src="@/assets/visual/unfixed.png" width="20px" height="20px" v-if="fix === false && value == true"  @click="gd" style="" />
            </div>
            <div style="text-align:center">
                <span>
                    {{ evidence.name }}
                </span>
            </div>
            <div>
                <div v-if="reportType == 1 || reportType == 2">
                    <el-button type="primary" size="small" @click="addContrast">添加对比记录</el-button>
                </div>
            </div>
          </div>
        </div>
      </el-header>
      <el-main>
        <div class="height_100" style="width:100%" v-loading="loading">
            <iframe id="checkIframe" :src="url" frameborder="0" width="100%"></iframe>
        </div>
      </el-main>
    </el-container>
    <contrast ref="contrast"></contrast>
  </div>
</template>

<script>
import contrast from '@/views/components/dialog/menuDialog/contrast.vue'
export default {
  components: {
    contrast
  },
  props: {
    evidence:{
        default:()=>{
            return {}
        }
    },
    reportType:{
        
    }
  },
  data() {
    return {
        url:'',
        loading:false,
        fix:false,
        value: false,
    };
  },
  watch: {
    evidence(val){
        if(val){
            this.getUrl()
            this.load()
        }
    }
  },
  computed: {},
  created() {},
  mounted() {
    if(this.evidence){
        this.getUrl()
        this.load()
    }
  },
  methods: {
    getUrl(){
        let http = this.$c.staticURL
        var guid = this.evidence.literatureNo
        var url = this.$commonJS.checkViewer(guid)
        this.url = `http://${http}:8012/onlinePreview?url=` + btoa(encodeURIComponent(url + '&fullfilename=test.' + this.evidence.systemFile.type))
    },
    load(){
        var that = this
        this.$nextTick(()=>{
            var a = document.getElementById('checkIframe')
            a.onload = function() {
                that.loading = true
            };
            if(a.contentDocument.readyState == 'complete'){
                that.loading = false
            }
        })
    },
    addContrast(){
        this.$refs.contrast.open()
    }
  },
};
</script>
<style lang="scss" scoped>
</style>