export const piZhuContrastList = {
  data() {
    return {

    }
  },
  mounted() {
    this.getPiZhuContrastList(this.patentNo)
  },
  methods: {
    // 查询批注
    getPiZhuContrastList(val) {
      if (val) {
        var index = this.piZhuContrastList.findIndex(item => {
          item.patentNo == val
        })
        if (index != -1) {
          return false;
        }
      }
      let params = {
        patentNo: val ? val : this.patentNo,
        id: this.reportId,
        createFrom: this.reportId ? 2 : 0
      }
      this.$api.scratchWordsQuery(params).then(response => {
        if (response.code == 200) {
          if (this.piZhuContrastList.length > 0) {
            var a = this.piZhuContrastList.filter(item => {
              return item.patentNo != params.patentNo
            }).concat(response.data)
          } else {
            var a = response.data
          }
          this.$store.commit('SET_PATENT_PIZHU_CONTRAST', a)
        }
      })
    },
    //获取需要跳转的批注
    getBiaoZhu(val) {
      if (val.scratchField.indexOf('摘要') != -1) {
        this.activeMenu = 'PatentBasic'
      } else {
        this.activeMenu = this.menuList.find(item => {
          return val.scratchField.indexOf(item.label) != -1
        }).value
        if (val.scratchField.indexOf('译文') != -1) {
          this.activeName = '1'
        } else {
          this.activeName = '0'
        }
      }
      this.handleSelect(this.activeMenu)

      this.tiaozhuan(val.id, val)
    },
    tiaozhuan(id) {
      const href = `#${id}`
      const anchor = document.createElement('a');
      anchor.href = href;
      anchor.style.display = "none";
      document.body.appendChild(anchor);
      setTimeout(function () {
        anchor.click();
        document.body.removeChild(anchor);
      }, 66);
      return true;
    },
  },
}