<template>
  <div class="height_100">
    <el-container>
        <el-header style="height: auto;">
        <div style="width:100%">
          <div style="display:flex;justify-content: space-between;padding:0 10px;">
            <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>
                <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">
            <myIframe id="checkIframe" :src="url" height="100%" frameborder="0" width="100%"></myIframe>
        </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:{
        
    },
    projectId:{

    },
    signPatentNo:{

    },
  },
  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(){
        if(Object.keys(this.evidence).length>0){
          var guid = this.evidence.literatureNo
          this.url = this.$commonJS.checkGuid(guid,this.evidence.systemFile.type)
        }
    },
    load(){
        var that = this
        this.$nextTick(()=>{
            var a = document.getElementById('checkIframe')
            a.onload = function() {
                that.loading = true
            };
            if(a.contentDocument && a.contentDocument.readyState &&a.contentDocument.readyState == 'complete'){
                that.loading = false
            }
        })
    },
    addContrast(){
      var a = {}
        // a.patentNo = currentSelectObj.patentNo//专利号
        a.signPatentNo = this.signPatentNo//标的专利号
        a.text = ''//选中的文本
        a.projectId = this.projectId//项目Id
        a.column = ''//选中文本所在栏位
        a.position = ''//选中文本开始位置
        a.id = null//对比记录Id
        a.remark = null//备注
        a.markType = 2//高亮类型
        a.markColor = '#ff0000'//高亮颜色
        a.permissionType = 1//高亮权限
        // a.color = this.currentSelectObj.color
        a.createFrom = this.outside ? 0 : this.projectType//来源0默认(专利)1专题库2报告
        a.literatureId = this.evidence ? this.evidence.id : null
        a.patentTitle=this.evidence.name

        this.$store.commit("SET_PATENT_INDEX", a)
        this.$refs.contrast.open()
    }
  },
};
</script>
<style lang="scss" scoped>
</style>