 
<template>

    <div class="patent-articles" >
        <el-container v-loading="loading">
          <el-container >
            <el-header class="patent-articles-title">
              <div class="patent-articles-title-box">
                <div style="position:relative">
                   <div>
                  <span v-html="getViewDom(patent.patentNo)"></span>
                  <el-tag type="primary" effect="dark" size="mini" class="margin-left_10">{{ patent.simpleStatus }}</el-tag>
                  <el-tag :type="patentStatus2 == '0' ? 'info' : 'primary'" effect="dark" size="mini" class="margin-left_10"
                      style="cursor: pointer" @click="changeStatus(patentStatus2)">{{ patentStatus[patentStatus2]
                      }}</el-tag>
                </div>
                <div style="color: #6b6868; font-size: 15px;border-bottom: 1px solid #e6e6e6;padding-bottom: 5px;">
                  <span v-html="getViewDom2(patent, 'name')"></span>
                  <el-link type="primary" @click.native="handleChange(patent, 'name')" style="margin-left: 10px;margin-top: -3px;">
                    <span v-if="!patent.change">切换译文</span>
                    <span v-else>切换原文</span>
                  </el-link>
                </div>
                  <div style="position: absolute;right: 0;top:0;margin-top: 15px;">
                    <PatentMark :patentNo="patentNo" @biaozhu="getBiaoZhu"></PatentMark>
                  </div>
                </div>
               
                <div  style="  position: relative;">
                    <el-link v-for="item in menuList" :type="activeMenu === item.value ? 'primary' : undefined" v-if="!item.show" :disabled="item.value === 'PatentExport' ? !$permission('/workspace/details/exportDocument'): false " @click.native="handleSelect(item.value)">
                    {{ item.label }}
                    <span v-if="item.value == 'PatentImage'|| item.value=='PatentPDF'" @click.stop="ending(item.value)">
                      <el-popover
                        placement="right"
                        width="400"
                        trigger="click">
                        <el-radio v-for="(item, index) in positionList" :key="index" v-model="radio" @input="changePosition"  :label="item.value">{{item.label}}</el-radio>
                        <i class="el-icon-setting" slot="reference"></i>
                      </el-popover>
                    </span>
                    </el-link>
                  <el-link v-for="item in menuList2" :type="activeMenu === item.value ? 'primary' : undefined" :disabled="item.value === 'PatentExport' ? !$permission('/workspace/details/exportDocument'): false " @click.native="handleSelect(item.value)">{{ item.label }}</el-link>
                  <el-tooltip class="item" effect="dark"  :content="(showRight ? '隐藏' : '显示') + '右侧菜单'" placement="top" v-if="showcard==true">
                    <i :class="showRight ? 'el-icon-s-unfold' : 'el-icon-s-fold'" style="font-size: 25px;position: absolute; right: 10px; margin-top: 5px;color: #2f2f2f; cursor: pointer" @click="showRight = !showRight"></i>
                  </el-tooltip>
                </div>
              </div>
            </el-header>
            <el-main class="patent-articles-content" style="padding-left:30px">
              <div class="patent-articles-content-left1" :style="{ width: showRight ? 'calc(100% - 321px)' : 'calc(100% - 21px)' }">
                <div class="dom1 box1" v-dragControllerDiv1 style="display:flex;width:100%">
              <div class="component left1" style="width:100%;overflow-y:auto;overflow-x: hidden;padding-bottom:10px" :style="{height:height}">
                <component :is="componentName" :project-id="projectId" :patent="patent" :patentNo="[patent.patentNo]" :domId="patent.patentNo + '1'" :reportId="reportId" :patent-id="patentId" @refresh="getPatent(patent.patentNo)"></component>
              </div>
              <div class="resize2" title="收缩侧边栏" v-show="(radio == 2 || radio == 3) && activeMenu != activeMenu2"><p><span>˙</span><span>˙</span><span>˙</span></p></div>
              <div class="resize1" title="收缩侧边栏" v-show="(radio == 4 || radio == 5) && activeMenu != activeMenu2"><span>⋮</span></div>
            <div v-show="radio != 1 && activeMenu != activeMenu2" class="mid1" :style="{height:(radio == 4 || radio == 5)?height:'280px'}" style="width:450px;height:280px;border:1px solid #E4E7ED;margin:10px;overflow-y:auto;overflow-x: hidden;">
              <component :is="activeMenu2" :project-id="projectId" :patent="patent" :patent-id="patentId" :pdfType1="(patent.pdf && patent.pdf.length>0)?patent.pdf[0].type:2" :sign="true"></component>
            </div>
            </div>
                
              </div>
              <div class="patent-articles-content-right" v-if="showRight" :style="{height:height2}">
                <el-container>
                  <el-header v-if="showcard==true">
                    <div class="patent-articles-option">
                      <el-tabs v-model="activeOption" type="card">
                        <el-tab-pane label="标引" name="PatentField"></el-tab-pane>
                        <!-- <el-tab-pane label="高亮" name="PatentKeywordsHighlight"></el-tab-pane> -->
                        <!-- <el-tab-pane label="注释" name="PatentAnnotation" :disabled="!($permission('/workspace/details/notes') && $r(projectId,[1,2]))"></el-tab-pane> -->
                      </el-tabs>
                    </div>
                  </el-header>
                  <el-main>
                    <keep-alive>
                      <component :is="activeOption" @status="getStatus" :project-id="projectId" :patent-id="patentId" :reportId="reportId" :taskId="taskId" :patentNo1="patentNo"></component>
                        <component :is="activeOption" @status="getStatus" :project-id="projectId" :patent-id="patentId" :reportId="reportId" :taskId="taskId" :patentNo1="patentNo"></component>
                    </keep-alive>
                  </el-main>
                </el-container>
              </div>
            </el-main>
          </el-container>
        </el-container>
        <div class="content-main" style="padding-left:40px"></div>
      </div>
      
    
</template>
    
<script>

import { changeTranslation, patentKeywordsHighlight } from '@/views/workspace/folder/components/mixins'
import PatentList from '@/views/workspace/folder/articles/components/PatentList.vue'
import PatentField from '@/views/workspace/folder/articles/components/PatentField'
// import PatentAnnotation from './components/PatentAnnotation'
import PatentBasic from "@/views/workspace/folder/articles/components/PatentBasic"
import PatentPDF from "@/views/workspace/folder/articles/components/PatentPDF"
import PatentImage from "@/views/workspace/folder/articles/components/PatentImage"
import PatentRight from "@/views/workspace/folder/articles/components/PatentRight"
import PatentInstruction from "@/views/workspace/folder/articles/components/PatentInstruction"
import PatentFamily from "@/views/workspace/folder/articles/components/PatentFamily"
import PatentStatus from "@/views/workspace/folder/articles/components/PatentStatus"
import PatentMessage from './patentMessage'
// import PatentKeywordsHighlight from "@/views/components/common/PatentKeywordsHighlight"
import Examination from '@/views/workspace/folder/articles/components/history/examination.vue'
import File from '@/views/workspace/folder/articles/components/history/file.vue'
import Invalid from '@/views/workspace/folder/articles/components/history/invalid.vue'
import Litigation from '@/views/workspace/folder/articles/components/history/litigation.vue'
import Other from '@/views/workspace/folder/articles/components/history/other.vue'
import { getPatentCountry } from "@/utils";
// import Import from '@/views/components/import/index.vue'
import Features from '@/views/workspace/folder/articles/components/features.vue'
    
import Permit from '@/views/workspace/folder/articles/components/history/permit.vue'
import ProductManage from '@/views/product/components/product.vue'
import PatentWorth from '@/views/workspace/folder/articles/components/history/components/echarts/components/echarts.vue'

import { splitScreen1 } from '@/views/components/common/SplitScreen'

import HistoryOfInvalidEvidence from '@/views/workspace/folder/articles/components/history/HistoryOfInvalidEvidence.vue'
import InvalidEvidencePush from '@/views/workspace/folder/articles/components/history/InvalidEvidencePush.vue'

import PatentMark from '@/views/workspace/folder/articles/components/PatentMark.vue'
import {piZhuContrastList} from './mixins'
    export default {
      mixins: [patentKeywordsHighlight, changeTranslation,splitScreen1,piZhuContrastList],
      components: {
            PatentMessage,
            PatentList,
            PatentField,
            // PatentAnnotation,//右侧自定义字段中右侧注释部分
            // PatentKeywordsHighlight,
            PatentBasic,
            PatentPDF,
            PatentImage,
            PatentRight,
            PatentFamily,
            PatentStatus,
            PatentInstruction,
            // Import,
            Features,
            Examination,
            File,
            Invalid,
            Litigation,
            Other,
            Permit,
            ProductManage,
            PatentWorth,
            HistoryOfInvalidEvidence,
        InvalidEvidencePush,
        PatentMark,
      },
  props: ['reportId', 'patentMessage', 'patentNo','taskId',"patentStatus2A","switchValue"],
    
    data() {
        return {
      patentStatus: {
        '0': '未读',
        '1': '已读'
      },
      patentStatus2: '',
      showcard: true,
      fix: false,
      showRight: false,
      patentId: parseInt(this.$route.params.id || 0),
      projectId: parseInt(this.$route.query.id || 0),
      patent: {},
      activeMenu: 'PatentBasic',
      componentName: 'PatentBasic',
      activeOption: 'PatentField',
      loading: false,
      // patentNo:"",
      menuList: [
        {
          value: 'PatentBasic',
          label: '基础信息'
        },
        {
          value: 'PatentRight',
          label: '权利要求'
        },
        {
          value: 'PatentImage',
          label: '附图'
        },
        {
          value: 'PatentInstruction',
          label: '说明书文本'
        },
        {
          value: 'PatentFamily',
          label: '同族专利'
        },
        {
          value: 'PatentStatus',
          label: '法律状态'
        },
        {
          value: 'PatentPDF',
          label: '说明书'
        },
        // {
        //   value: 'PatentExport',
        //   label: '导出文档'
        // },
        {
          value:'Permit',
          show:this.$permission('/rms/patent/worth')?false:true,
          label:'许可历史'
        },
        {
          value:'ProductManage',
          show:this.$permission('/rms/product')?false:true,
          label:'商品化'
        },
        {
          value:'patentWorth',
          show:this.$permission('/rms/patent/worth')?false:true,
          label:'价值曲线'
        }
      ],
      menuList2: [
        {
          value: 'Examination',
          label: '审查历史'
        },
        // {
        //   value: 'File',
        //   label: '申请案卷'
        // },
        {
          value: 'Invalid',
          label: '被无效历史'
        },
        {
          value: 'HistoryOfInvalidEvidence',
          label: '作为无效证据使用历史'
        },
        {
          value: 'InvalidEvidencePush',
          label: '无效证据推荐'
        },
        {
          value: 'Litigation',
          label: '诉讼历史'
        },
        {
          value: 'Other',
          label: '其他参考资料'
        },
      ],
      
    }
  },
  created() {
  },
  watch: {
   
    patentNo(val) {
      this.getPatent(val)
    },
    patentStatus2(val) {
      let value = {
        patentNo: this.patentNo,
        patentStatus2:this.patentStatus2
      }
      this.$emit("patentStatusEmit",value)
    },
    patentStatus2A(val) {
      if (this.patentNo==val.patentNo) {
        this.patentStatus2=val.patentStatus2
      }
    },
    switchValue(val) {
      if (this.patentNo==val.patentNo) {
        if (val.value) {
          this.showcard=false
        } else {
          this.showcard=true
        }
      } else {
        this.showcard=true
      }
    },
    
  },
  mounted() {
    if(this.patentNo){
      this.getPatent(this.patentNo)
    }
  },
  methods: {
    changePageTitle() {
      document.title = `${this.patent.patentNo} ${this.patent.name || ''}`
    },
    async getPatent(patentNo) {
      this.loading = true
      const response = await this.$api.PatentByPatentNo({patentNo : patentNo})
      //console.log(response)
      this.patent = response.data
      if (this.taskId) {
        this.getPatentStatus()
      }
      const country = getPatentCountry(this.patent.patentNo)
      let change = false
      if (country !== 'CN') {
        change = true
      }
      this.$set(this.patent, 'change', change)
      this.$set(this.patent, 'change2', change)
      this.loading = false
      this.changePageTitle()
    },
    handleSelect2(index, path) {

    },
    handleSelect(index) {
      if (index === 'PatentExport') {
        const router = this.$router.resolve({
          path: '/export/patent',
          query: {
            id: this.projectId,
            patent: this.patent.id,
          }
        })
        window.open(router.href, '_blank');
        return false
      }
      if(index == this.activeMenu2){
        this.activeMenu2 = ''
        this.radio = 1
        this.changePosition(this.radio)
      }
      this.activeMenu = index
      this.componentName = index
    },
     //修改已读未读
    changeStatus(val) {
      if (val == '0') {
        var a = {
          taskID: this.taskId?this.taskId:this.taskId1,
          patentNo:this.patentNo,
        }
        this.$api.updatePatentStatus(a).then(response => {
          if (response.code == 200) {
            this.patentStatus2 = '1'
          }
        })
      }

    },
      //查询任务下专利状态
    getPatentStatus() {
      var a = {
        taskID: this.taskId?this.taskId:this.taskId1,
        patentNo:this.patentNo,
      }
      this.$api.getPatentStatus(a).then(response => {
        //console.log("patentMessage",response.data);
        if (response.code == 200) {
          this.patentStatus2 = response.data
        }
      })
    },
    //获取状态
    getStatus(val) {
      this.patentStatus2 = val
    },
  }
}
</script>
    
<style lang="scss">
    .content-main{
      width:80% !important ;
      background-color: skyblue !important;
    }
    .patent-articles {
      width: 100%;
      height: 100% !important;
      padding: 0 !important;
      .patent-articles-menu {
    
      }
      .el-menu-item.is-active {
        background: #ecf5ff !important;
        color: #409EFF!important;
      }
      .patent-articles-title {
        padding: 0 !important;
        height: 100px !important;
        .el-link {
          margin-right: 20px;
        }
        .patent-articles-title-box {
          font-size: 20px;
          width: 100%;
          text-align: center;
        }
      }
      .patent-articles-content {
        background: #fff;
        padding: 0;
        height: 100%;
        overflow: hidden;
        .patent-articles-content-left1 {
          float: left;
          height: 100%;
          overflow-y: auto;
          overflow-x: hidden;
          padding: 10px;
        }
        .patent-articles-content-right {
          width: 300px;
          border-left: 1px solid #e6e6e6;
          float: right;
          height: 100%;
          .el-header {
            height: 50px !important;
            position: relative !important;
          }
          .el-main {
            padding: 0 12px !important;
          }
          .el-container, .el-main {
            height: 100%;
          }
          .patent-articles-option {
            position: absolute;
            bottom: 0;
            height: 100%;
            left: 50px;
            .el-tabs {
              margin-top: 9px;
            }
            .el-tabs__header {
              margin-bottom: 0 !important;
            }
          }
        }
      }
    }
    </style>