<template>
  <div class="patent-articles-patent-right" @mouseup="mouseup" @mousemove="mousemove">
    <el-tabs v-model="name" >
      <el-tab-pane label="原文" name="0" :style="{height: height + 'px',overflowY: 'auto'}">
        <!-- <p class="common" v-for="(item, index) in patent.rights" :style="setStyle()" data-type="权利要求原文">
          <span v-if="item"  v-html="getViewDom(item.content,'权利要求原文'+(index+1))"></span>
        </p> -->
        <div v-html="getViewDom1(patent.rights,'权利要求原文','content')" :style="setStyle()" data-type="权利要求原文"></div>
      </el-tab-pane>
      <el-tab-pane label="译文" name="1" :style="{height: height + 'px',overflowY: 'auto'}" v-if="projectId">
        <!-- <p class="common" v-for="(item, index) in patent.rights" :style="setStyle()">
          <span v-if="item" v-html="getViewDom(item.contentOut)"></span>
        </p> -->
        <div v-html="getViewDom1(patent.rights,'权利要求译文','contentOut')" :style="setStyle()" data-type="权利要求译文"></div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { commonMixins,addContrast } from "./mixins"
import { patentKeywordsHighlight,changeTranslation } from "@/views/workspace/folder/components/mixins";
export default {
  mixins: [commonMixins,patentKeywordsHighlight,changeTranslation,addContrast],
  data() {
    return {
      height: null,
      fullHeight: document.documentElement.clientHeight,
      records: {
        original: [],
        translation: []
      }
    }
  },
  watch: {
    fullHeight() {
      this.refresh()
    },
    patentId() {
      this.initData()
    },
    patentNo(){
      if(!this.patentId){
         this.initData()
      }
     
    }
  },
  created() {
    window.addEventListener('resize', this.handleResize)
  },
  mounted() {
    this.handleResize()
    this.initData()
  },
  methods: {
    initData() {
      if(this.patent.rights){
        this.records.original = this.patent.rights.map(item => item.content)
        this.records.translation = this.patent.rights.map(item => item.contentOut)
      }else{
        if(!this.projectId){
          var params = {
            patentCell:1,
            patentNo:this.patent.publicNo,
            appNo:this.patent.applicationNo,
          }
          this.$api.getPatentPart(params).then(response=>{
            if(response.code == 200){
              this.$set(this.patent,'rights',response.data.rights)
            }
          })
        }
      }
      
    },
    handleResize(event) {
      this.fullHeight = document.documentElement.clientHeight
      this.height = this.fullHeight - 300
    },
  }
}
</script>

<style lang="scss">
.patent-articles-patent-right {
  margin-bottom: 20px;
  .common {
    // font-size: 14px;
    margin-top: 0;
    padding-right: 5px;
    word-break: break-all;
  }
  .title {
    font-weight: bold;
    border-bottom: 1px solid #e6e6e6;
    padding-bottom: 5px;
    margin-top: 0;
  }
}
</style>