<template>
  <div class="height_100" v-DivHeight="getDivHeight">
    <el-table
      ref="table"
      :data="recordData"
      border
      :maxHeight="tableHeight"
      v-loading="loading"
      :header-cell-style="{'text-align':'center'}"
      style="min-width: 100%; overflow: auto"
    >
      <el-table-column
        prop="patentNo"
        label="对比文件"
        align="center"
        width="300px"
      >
        <template slot-scope="scope">
          <span>
            <el-link type="primary" @click="editContrast(scope.row)"
              >{{ scope.row.type == 0?scope.row.literatureNo:scope.rwo.name }}(D{{ scope.row.sysOrder }})</el-link
            >
          </span>
          <el-tag
            style="font-size: 12px; border-radius: 50%"
            v-if="scope.row.remark"
            >{{ scope.row.remark }}</el-tag
          >
          <span>
                <my-draggable :list="tableHeader" :check=" scope.row.id" @change="changeOrder" @update="updateOrder"></my-draggable>
            </span>
        </template>
      </el-table-column>
      <el-table-column
        prop="content"
        label="对比记录"
        min-width="300px"
      >
        <template slot-scope="scope">
          <div v-for="item in scope.row.recordList" :key="item.evidenceId">
            <p>
                <span>
                    <el-link style="color:red;margin-left:10px" @click="delContrast(item.evidenceId)">删除</el-link>
                </span>
                <span>【{{ item.fieldName }}】</span>
                <span v-if="item.common">
                    (解析过程：{{ item.common }})
                </span>
                {{ item.evidenceText}}
              <el-image
                ref="image"
                :preview-src-list="imgList"
                v-if="item.fileGuid"
                :src="$commonJS.checkViewer(item.fileGuid)"
                style="vertical-align: middle; width: 100px"
                @click="showImage($commonJS.checkViewer(item.fileGuid))"
              ></el-image
              >
              <span v-if="item.conclusion">
                    ({{ item.conclusion }})
                </span>
            </p>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="features"
        label="对应特征"
        align="center"
        min-width="300px"
      >
        <template slot-scope="scope">
          <div
            v-for="item in scope.row.recordList"
            :key="item.evidenceId"
          >
            <p>
              <span>
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="item.featureContent"
                  placement="top-start"
                >
                  <span>特征{{ item.featureSysOrder }}</span>
                </el-tooltip>
              </span>
              <span>
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="item.rightContent"
                  placement="top-start"
                >
                  <span>[{{ item.rightName }}]</span>
                </el-tooltip>
              </span>
            </p>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import mixins from './mixins'
export default {
  mixins:[mixins],
  components: {},
  props: {},
  data() {
    return {
        recordData:[]
    };
  },
  watch: {
    tableData(){
        if(val){
            this.getData()
        }
    }
  },
  computed: {},
  created() {},
  mounted() {
    if(this.tableData.length>0){
        this.getData()
    }
  },
  methods: {
    getData(){
        var data = {}
        for(var i = 0;i<this.tableHeader.length;i++){
            data[this.tableHeader[i].id] = this.tableHeader[i]
            data[this.tableHeader[i].id].recordList = []
        }
        for(var i = 0;i<this.tableData.length;i++){
            if(this.tableData[i].evidenceReasons && this.tableData[i].evidenceReasons.length>0){
                var evidenceReasons = this.tableData[i].evidenceReasons
                for(var j = 0;j<evidenceReasons.length;j++){
                    data[evidenceReasons[j].literatureId].recordList.push(
                        {
                            ...evidenceReasons[j],
                            rightName: this.tableData[i].rightName,
                            rightContent: this.tableData[i].rightContent,
                            rightSort: this.tableData[i].rightSort,
                            rightType: this.tableData[i].rightType,
                            featureContent: this.tableData[i].featureContent,
                            featureSysOrder: this.tableData[i].featureSysOrder,
                            featureName: this.tableData[i].featureName,
                            featureId:this.tableData[i].featureId,
                        }
                    )
                }
            }
        }
        this.recordData = Object.values(data)
    }
  },
};
</script>
<style lang="scss" scoped>
</style>