import { getTableHeight } from '@/views/components/mixins'
import myDraggable from '@/views/report/InvalidResponse/components/draggable/index.vue'
export default {
    mixins:[getTableHeight],
    components:{
        myDraggable
    },
    props:{
        //表格数据
        tableData:{
            default:()=>{
                return []
            }
        },
        //显示类型0：全部展示；1：主权要展示
        showType:{
            default:0
        },
        //表头
        tableHeader:{
            default:()=>{
                return []
            }
        },
        loading:{
            default:false
        },
        projectId:{
            default:0
        },
        reportType:{
            default:''
        },
        patentNo:{
            default:''
        }
    },
    watch:{
       
    },
    data() {
        return {
            mergeObj: {},
            mergeArr: ['rightName'],
            imgList:[]
        }
    },
    mounted() {
        
    },
    methods: {
        tableRowClassName({ row, rowIndex }){},
        //查看图片
        showImage(url){
            this.imgList=[url]
            this.$refs.image.showViewer = true
        },
        getSpanArr(data) {
            this.mergeArr.forEach((key, index1) => {
              let count = 0;
              this.mergeObj[key] = [];
              data.forEach((item, index) => {
      
                if (index === 0) {
                  this.mergeObj[key].push(1);
                } else {
                  if (item[key] === data[index - 1][key]&& item[key] !== 'explainText' ) {
                    this.mergeObj[key][count] += 1;
                    this.mergeObj[key].push(0);
                  } else {
                    count = index;
                    this.mergeObj[key].push(1);
                  }
                }
              })
            })
          },
          objectSpanMethod({ row, column, rowIndex, columnIndex }) {
            if (this.mergeArr.indexOf(column.property) !== -1) {
                if (this.mergeObj[column.property][rowIndex]) {
                
                return [this.mergeObj[column.property][rowIndex], 1]
              } else {
                return [0, 0];
              }
            }
          },
          changeOrder(now,old){
            this.$emit('changeOrder',now,old)
          },
          updateOrder(now,old){
            this.$emit('updateOrder',now,old)
          },
          delContrast(id){
            var ids = [id]
            this.$confirm('确认删除该数据吗？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$api.removeCompareRecord(ids).then(response => {
                    this.$emit('update',true)
                }).catch(error => {
                })
            })
        },
        editContrast(row){
            this.$s.setSession('search', {})
            this.$router.push(
                {
                  path: '/patentDetails/' + row.literatureNo,
                  query: {
                    projectId: this.projectId,
                    reportType:this.reportType,
                    evidenceType:row.type,
                    evidence:JSON.stringify(row),
                    signPatentNo:this.patentNo
                  }
                }
              )
        }
    },
}