<template>
  <div class="patent-table-list-view height_100" v-DivHeight="getDivHeight">
    <el-table :data="tableData" border style="width: 100%" header-row-class-name="custom-table-header"
      :maxHeight="tableHeight" @sort-change="sortChange">
      <el-table-column label="#" width="60" type="index" align="center">
        <template slot-scope="scope">
          <div v-if="refresh">
            <el-checkbox :label="scope.row.id" @change="changeSelect(scope.row)"
              :checked="patentNoList.filter(item => { return item == scope.row.patentNo || item == scope.row.appNo }).length > 0">
              <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
            </el-checkbox>
          </div>
          <div v-else>
            <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
          </div>
        </template>
      </el-table-column>

      <el-table-column v-for="item in column.filter(item => !item.ifHidden)"
        :render-header="$commonJS.renderHeaderMethods" :key="item.value" :prop="item.value" :label="item.name"
        sortable="custom" align="center">
        <template slot-scope="scope">
          <div v-if="['patentNo'].includes(item.value)">
            <el-popover placement="right-start" width="500" trigger="hover">
              <table class="patent-popover-table">
                <tr>
                  <td>
                    <div class="patent-abstract-image text-align_center">
                      <el-image :src="outside?scope.row.pictureGuid:$commonJS.checkViewer(scope.row.pictureGuid)"
                        :preview-src-list="[outside?scope.row.pictureGuid:$commonJS.checkViewer(scope.row.pictureGuid)]" style="vertical-align:middle;"
                        :style="{ width: scope.row.imgWidth ? scope.row.imgWidth : '100%', height: scope.row.imgHeight ? scope.row.imgHeight : '100%' }">
                        <div slot="error" class="image-slot">
                          <img src="https://www.patentstar.com.cn/img/Common/nopic.jpg" alt="" style="">
                        </div>
                      </el-image>
                    </div>
                  </td>
                  <td>
                    <p v-html="getView(scope.row, 'abstractStr')"></p>
                    <el-link v-if="projectId" type="primary" @click.native="handleChange(scope.row, 'abstractStr')">
                      <span v-if="!scope.row.change2">切换译文</span>
                      <span v-else>切换原文</span>
                    </el-link>
                  </td>
                </tr>
              </table>
              <el-link slot="reference" type="primary" @click="handleClick(scope.row, scope.$index)">
                <span v-html="getView(scope.row, item.value, item.type)"></span>
              </el-link>
            </el-popover>
          </div>
          <template v-else-if="item.value === 'title'">
            <span v-html="getView(scope.row, 'title')"></span>
            <br>
            <el-link v-if="projectId" type="primary" @click.native="handleChange(scope.row, 'title')">
              <span v-if="!scope.row.change">切换译文</span>
              <span v-else>切换原文</span>
            </el-link>
          </template>
          <template v-else-if="item.value === 'abstractStr'">
            <span v-html="getView(scope.row, 'abstractStr')"></span>
            <br>
            <el-link v-if="projectId" type="primary" @click.native="handleChange(scope.row, 'abstractStr')">
              <span v-if="!scope.row.change2">切换译文</span>
              <span v-else>切换原文</span>
            </el-link>
          </template>
          <!-- 法律状态 -->
          <template v-else-if="item.value === 'legalStatus'">
            <span v-html="getView(scope.row, 'legalStatus')"></span>
          </template>
          <!-- 专利状态 -->
          <template v-else-if="item.value === 'simpleStatus'">
            <span v-html="getView(scope.row, 'simpleStatus')"></span>
          </template>
          <!-- 专利类型 -->
          <template v-else-if="item.value === 'patentType'">
            <span v-html="getView(scope.row, 'patentType')"></span>
          </template>
          <div v-else v-html="getView(scope.row, item.value, item.type)"></div>
        </template>
      </el-table-column>

    </el-table>
  </div>
</template>

<script>
import { projectData, handleData } from '../mixins/index'
import { getTableHeight } from '@/views/components/mixins'
export default {
  mixins: [projectData, handleData, getTableHeight],
  components: {

  },
  data() {
    return {
    }
  },
  activated() {
  },
  computed: {

  },
  created() {

  },
  mounted() {

    // console.log(this.columnList);
  },
  methods: {

    // 排序
    sortChange({ column, prop, order }) {
      this.$emit('on-sort', { column, prop, order })
    },
  },
}
</script>

<style lang="scss">
.patent-popover-table {

  tbody,
  tr,
  td {
    height: 100%;
    vertical-align: top;
  }

  p {
    padding: 0 !important;
    margin: 0 !important;
  }

  .patent-abstract-image {
    padding: 10px;
    border: 1px solid #bcc2cc;
    border-radius: 4px;
    width: 120px;
    height: 150px;
    line-height: 150px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

.patent-table-list-view {
  .view-table {
    width: 100%;
  }

  .el-table .cell {
    white-space: pre-line !important;
  }

  .custom-field-cell {
    cursor: pointer;
  }
}</style>