<template>
    <!-- 标的专利详情 -->
    <!-- 获取专利号，通过专利号调用拆分权要的接口返回对应数据 -->
    <div style="padding:20px;">
      <div class="claims-imput-import">
        <div class="demo-input-suffix" v-if="show">
          标的专利号：<el-link type="primary"  @click="toPatentDetails(patentNo)">{{patentNo}}</el-link>
        </div>
      </div>
      <!-- table -->
      <div>
        <!-- table按钮部分 -->
        <div style="margin-top:20px;display:flex;justify-content:space-between">
          <el-button-group :style="{visibility:show&&typeFto!=1?'visible':'hidden'}">
              <el-button @click="merge" :disabled="row.length>0?false:true">合并</el-button>
              <el-button @click="split" :disabled="row.length>0?false:true">拆分</el-button>
          </el-button-group>
          <div>
            <el-select v-if="typeFto!=1"  placeholder="请选择拆分类型" v-model="splitType1" @change="splitTypeSelect($event)" >
              <el-option label="仅拆主权要" value="0"></el-option>
              <el-option label="全部拆分" value="1"></el-option>
            </el-select>
            <el-select v-if="typeFto!=1" placeholder="请选择拆分符号" v-model="splitBy1" style="margin-left: 10px;" @change="splitBySelect($event)">
                <el-option label="逗号拆分" value="0"></el-option>
                <el-option label="分号拆分" value="1"></el-option>
                <el-option label="逗号和分号拆分" value="2"></el-option>
            </el-select>
            <el-select placeholder="请选择显示类型" v-model="Type" style="margin-left: 10px;" @change="TypeSelect($event)" >
                <el-option label="仅显示主权要" value="1"></el-option>
                <el-option label="全部显示" value="0"></el-option>
            </el-select>
          </div>
          
          <div>
            <el-button @click="keepSendCollaboration" type="primary" style="margin-right: 10px;" v-if="this.coordination && this.FeaturesNumber==0">完成协同</el-button>
            <el-button @click="keep" type="primary" style="float: right;" :loading="this.loadings">保存</el-button>
          </div>
        </div>
        <!-- 表格部分 -->
        <el-table
          :data="tableData"
          border
          ref="table"
          :span-method="objectSpanMethod"
          v-loading="loading"
          :height="tableHeight"
          style="min-width: 100%; margin-top: 20px;overflow:auto">

          <el-table-column prop="pRightName" label="权要"  align="center"  width="200px">
            <template slot-scope="scope">  
              <el-tooltip class="item" effect="dark" :content="scope.row.pContent" placement="top">
                <!-- <span>{{scope.row.pContent}}</span> -->
                <span>{{scope.row.pRightName}}</span>
              </el-tooltip>     
            </template>
          </el-table-column>
  
          <el-table-column prop="content" label="特征" align="center" width="300px">
            <template slot-scope="scope" >
              <!-- <el-checkbox-group v-if="coordinationA||taskWorkRemakA==0" v-model="checkList" >
                  <el-checkbox :label="scope.row.id" disabled @change="getFunInfo(scope.row)" style="display: flex; align-items: center;">
                    <el-input type="textarea" style="width:250px" autosize v-model="scope.row.content"> {{scope.row.content}}</el-input>
                  </el-checkbox>
               </el-checkbox-group> -->
               <p v-if="typeFto==1" style="width:100%;outline: #dcdfe6;" 
                v-html="scope.row.content" >
              </p>
              <el-checkbox-group v-else v-model="checkList" >
                  <el-checkbox :label="scope.row.id" @change="getFunInfo(scope.row,scope)" style="display: flex; align-items: center;">
                    <el-input type="textarea" style="width:250px" autosize v-model="scope.row.content"> {{scope.row.content}}</el-input>
                  </el-checkbox>
               </el-checkbox-group>
            </template>
          </el-table-column>
          
          <el-table-column  prop="explainText" align="center" label="解释(可粘贴图片)" min-width="300px">
            <template slot-scope="scope">   
              <!-- <div>
                  <el-input type="textarea" style="width:100%" autosize v-model="scope.row.explainText"> {{scope.row.explainText}}</el-input>
              </div> -->
              <p v-if="typeFto==1" style="width:100%;outline: #dcdfe6;" 
                v-html="scope.row.explainText" >
              </p>
              <div v-else style="width:100%;outline: #dcdfe6;border:1px solid #DCDFE6;border-radius:5px" id="preview" contenteditable="true" 
                v-html="scope.row.explainText"  @input="saveValue($event.target.innerHTML)"  @click="saveValue($event.target.innerHTML)"
                @blur="getValue(scope.row,'explainText')"  v-on:paste="handlePaste($event,scope.row,'explainText')">
                <!-- {{scope.row.explainText}} -->
              </div>
            </template>
          </el-table-column>
          <el-table-column  prop="targetDescription" align="center" label="标的说明(可粘贴图片)" min-width="300px">
            <template slot-scope="scope">   
              <!-- <div>
                  <el-input type="textarea" style="width:100%" autosize v-model="scope.row.explainText"> {{scope.row.explainText}}</el-input>
              </div> -->
              <div style="width:100%;outline: #dcdfe6;border:1px solid #DCDFE6;border-radius:5px" id="preview" contenteditable="true" 
                v-html="scope.row.targetDescription"  @input="saveValue($event.target.innerHTML)"  @click="saveValue($event.target.innerHTML)"
                @blur="getValue(scope.row,'targetDescription')"  v-on:paste="handlePaste($event,scope.row,'targetDescription')">
                <!-- {{scope.row.explainText}} -->
              </div>
            </template>
          </el-table-column>
         
          <el-table-column prop="compareResult" align="center" label="比对结果" width="300px">
            <template slot-scope="scope">
              <el-select v-model="scope.row.compareResult" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </template>
          </el-table-column>
         
          <el-table-column  prop="compareDescription" align="center" label="比对说明(可粘贴图片)" min-width="300px">
            <template slot-scope="scope">   
              <div  style="width:100%;outline: #dcdfe6;border:1px solid #DCDFE6;border-radius:5px" id="preview" contenteditable="true" 
                v-html="scope.row.compareDescription"  @input="saveValue($event.target.innerHTML)"  @click="saveValue($event.target.innerHTML)"
                @blur="getValue(scope.row,'compareDescription')"  v-on:paste="handlePaste($event,scope.row,'compareDescription')">
              </div>
            </template>
          </el-table-column>
          <el-table-column v-if="this.taskWorkRemakA==0"  prop="targetDescription2" align="center" label="协同标的说明(可粘贴图片)" min-width="300px">
            <template slot-scope="scope">   
              <!-- <div>
                  <el-input type="textarea" style="width:100%" autosize v-model="scope.row.explainText"> {{scope.row.explainText}}</el-input>
              </div> -->
              <div v-html="scope.row.targetDescription2"  >
                <!-- {{scope.row.explainText}} -->
              </div>
            </template>
          </el-table-column>
          <el-table-column v-if="this.taskWorkRemakA==0" prop="compareResult2" align="center" label="协同比对结果" width="300px">
            <template slot-scope="scope">
              <div v-if="scope.row">
                  <span v-if="scope.row.hasOwnProperty('compareResult2') && scope.row.compareResult2.toString()!=''">{{ options.filter(item=>item.value==scope.row.compareResult2)[0].label }}</span> 
               </div>
              <!-- <el-select v-model="scope.row.compareResult2" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select> -->
            </template>
          </el-table-column>
          <el-table-column v-if="this.taskWorkRemakA==0"  prop="compareDescription2" align="center" label="协同比对说明(可粘贴图片)" min-width="300px">
            <template slot-scope="scope"> 
              <div v-html="scope.row.compareDescription2">  </div>
            </template>
          </el-table-column>
          <el-table-column v-if="this.taskWorkRemakA==0" label="操作" min-width="120"  align="center" >
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" size="small">一键修改</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
</template>
  
      
<script>
  import {explain} from '../../../components/mixins'
  import { PatentDetails } from '@/views/components/common/mixins';
  export default {
  props: ['isshow', 'patentNo', "reportId", 'taskId', "coordination","FeaturesNumber","type","taskWorkRemak"],
    mixins:[explain,PatentDetails],
    components: {
    },
    data() {
      return {
        tableHeight:null,
        typeFto: this.type,
        coordinationsss:1,
        show: true,
        checkList: [],
        tableData1: [],
        tableData: [],
        mergeObj: {},
        row: [],//选中特征push到row中
        mergeArr: [ 'pRightName'],//解释
        // patentNo:"",//专利号
        splitType1:"0",//拆分类型0仅拆主权要，1全部拆分
        splitBy1: "2",//拆分符号0 ','，1';',2','和';'
        Type: "1",//下拉框
        typeArr:[1],//显示权要还是全部显示
        loading: false,
        loadings: false,
        delArr: [],
        keepSure:true,//保存标识
        patentNo1:this.patentNo,
        keepArr:[],
        coordinationA:this.coordination,
        taskWorkRemakA: this.taskWorkRemak,
        // isKeepB:this.isKeepA,
        options: [
          {
            value: 1,
            label: '相同'
          }, {
            value: 3,
            label: '等同'
          },{
            value: 0,
            label: '不相同'
          }, {
            value: 2,
            label: '待确定'
          }
        ],
      }
    },
    watch:{
      tableData(){
        console.log(1)
            this.$nextTick(() => {
                this.setHeight()
            })
        },
      patentNo(val){
        this.patentNo1 = val
        if (this.typeFto==1) {
          this.queryCompareMessage()
        } else {
          this.getSplitMessage()
        }
      },
      // isKeepA(val) {
      //   console.log(val); 
      //   // if (val==1) {
      //     this.keep()
      //   // }
      // }
    },
    // computed: {
    //   isKeepB() {
    //     return JSON.parse(JSON.stringify(this.isKeepB))
    //   }
    // },
    mounted() {
      this.show = this.isshow == false ? this.isshow : this.show
      console.log(this.coordinationA, this.taskWorkRemakA);
      if (this.typeFto==1) {
        this.queryCompareMessage()
      } else {
        this.getSplitMessage()
      }
      
    },
    methods: {
      setHeight() {
            const offsetTop = window.innerHeight - this.$refs.table.$el.offsetTop - 40
            const body = document.querySelector('.el-table__body')
            if (!body) {
                return false
            }
            const offsetBodyHeight = body.offsetHeight
            if (this.tableData.length && offsetBodyHeight < offsetTop) {
                this.tableHeight = offsetBodyHeight + 75
            } else if (!this.tableData.length) {
                this.tableHeight = null
            } else {
                this.tableHeight = offsetTop
            }
        },
      //获取拆分信息
      async getSplitMessage(){
        var a = {
          patentNo:this.patentNo1,
          taskId:this.taskId?this.taskId:null,
          reportId:this.taskId?null:this.reportId,
        }
        await this.$api.getSplitMessage(a).then(response=>{
          if(response.code == 200){
            if(Object.keys(response.data).length!=0){
              this.splitType1 = response.data.splitType.toString()
              this.splitBy1 = response.data.splitBy.toString()
              this.queryCompareMessage()
            }else{
              this.splitType1 = "0"
              this.splitBy1 = "2"
              this.splitPatentRight()
            }
            
          }
        })
      },
      //选中特征
      getFunInfo(row,scope) {
        console.log("row",row)
        // this.$emit('getfeatures', row)
        let Index=this.row.findIndex(item => {return item.id==row.id })
        if (Index<0) {
          row.$index = scope.$index
          this.row.push(row)
        } else {
          this.row.splice(Index,1)
        }
        console.log("getFunInfo",this.row);
      },
      //合并
      merge() {
        var sign = this.row[0].rightId
        var allow = true
        this.row.forEach(item => {
          if(item.rightId!=sign){
            allow = false
            return false
          }
        });
        if(!allow){
          this.$alert('不能合并不同权要的特征','提示',{
            confirmButtonText: '确定',
            type:'warning',
            callback: action => {
            }
          })
          return false;
        }
        this.keepSure=false
        var str = ''
        var strText=""
        var targetDescription = ''
        if (this.row != []) {
          console.log(this.row);//explainText
          let row = this.row.sort((aId, bId) => {
              return aId.$index-bId.$index; 
            })
            row.sort((aId, bId) => {
            if(aId.$index - bId.$index!=1){
              allow = false
            }
          })
          if(!allow){
            this.$alert('只能合并相邻的特征','提示',{
              confirmButtonText: '确定',
              type:'warning',
              callback: action => {
              }
            })
            return false;
          }
          for (var i = 0; i < this.row.length; i++) {
            if (i < row.length - 1) {
              str = str + row[i].content + (row[i].content==''?'':' ，')
              strText = strText + row[i].explainText + (row[i].explainText==''?'':'，')
              targetDescription = targetDescription + row[i].targetDescription + (row[i].targetDescription==''?'':'，')
              let Index = this.tableData1.findIndex(item => { return item.id == row[i].id })
              this.tableData1.splice(Index, 1)
            } else if (i == row.length - 1) {
              str = str + row[i].content
              targetDescription = targetDescription + row[i].targetDescription
              strText = strText + row[i].explainText
            }
          }
        }
        var a = this.tableData1.findIndex(item => {
          return item.id==this.row[this.row.length-1].id
        })
        this.tableData1[a].content = str
        this.tableData1[a].explainText = strText
        this.tableData1[a].targetDescription = targetDescription
        this.tableData1[a].compareDescription = ''
        this.tableData1[a].compareResult = ''
        this.$forceUpdate()
        this.TypeSelect(this.Type)//调用显示权要
        this.row = []
        this.checkList=[]
      },
      //拆分
      split() {
        if (this.row.length > 1) {
          this.$alert('不能同时拆分多条特征','提示',{
            confirmButtonText: '确定',
            type:'warning',
            callback: action => {
            }
          })
          return false
        }
        //只对勾选的进行拆分
        this.keepSure=false
        this.checkList = []//
        this.row.forEach(ele=>{
        var Index = this.tableData1.findIndex(item => {
          return item.id==ele.id
        })
        var a = Math.floor((Math.random()*9999)+1000);
        let tab = {
          pSignPatentNo: ele.pSignPatentNo,
          pPatentId: ele.pPatentId,
          pContent: ele.pContent,
          pRightName: ele.pRightName,
          pType: ele.pType,
          pSort: ele.pSort,
          pReportId: ele.pReportId,
          pContentOut: ele.pContentOut,
          targetDescription:'',
          compareDescription:'',
          compareResult :'',
          id:ele.id+"a"+ele.$index+a,
          signPatentNo: ele.signPatentNo,
              contentOut:"" ,
              content: "",
              rightId: ele.rightId,
              isFinal: ele.isFinal,
              reportId: ele.reportId,
              explainText: "",
              
              rightName: ele.rightName,
              rightType: ele.rightType,
              splitBy: ele.splitBy,
        }
        // console.log(tab)
        this.tableData1.splice(Index+1,0,tab)
      }) 
        this.TypeSelect(this.Type)//调用显示权要
        this.row = []
        console.log(this.row);
      },
      //获取每个元素所需合并的行数
      getSpanArr(data) {
        this.row = []
        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 }) {
        // column.property=“id”  
        if (this.mergeArr.indexOf(column.property) !== -1) {
          if (this.mergeObj[column.property][rowIndex]) {
            console.log("@@",this.mergeObj[column.property][rowIndex]);
            return [this.mergeObj[column.property][rowIndex], 1]
          } else {
            return [0, 0];
          }
        }
      },

      //查询对比记录
       queryCompareMessage() {//patentRightVos
        console.log(this.reportId,this.taskWorkRemakA,this.coordination);
        this.loading=true
        if(this.taskId){
          var PatentRight = {
            patentNo: this.patentNo,
            // reportId:null,
            reportId:this.taskWorkRemakA==0?this.reportId:null,
            taskId: this.taskWorkRemakA==0?null:this.taskId,
          }
        }else{
          var PatentRight = {
            patentNo: this.patentNo,
            reportId:this.reportId,
            taskId:null,
          }
        }
        
        //协同对比调用querySynery
        if (this.typeFto==1) {
          if (this.coordination || this.taskWorkRemakA != 0) {
            console.log(111111, this.coordination,this.taskWorkRemakA);
            this.$api.querySynery(PatentRight).then(res => {
              if (res.code == 200) {
                this.CompareMessage(res)
              }
              // console.log("@@",this.tableData1);
            })
          } else {
            this.$api.queryAllCompareMessage(PatentRight).then(res => {
              console.log(2222, this.taskWorkRemakA);
              if (res.code == 200) {
                this.CompareMessage(res)
              }
            // console.log("@@",this.tableData1);
            })
          }
        } else {
          this.$api.queryCompareMessage(PatentRight).then(res => {
            console.log(3333,this.coordination);
            if (res.code == 200) {
              this.CompareMessage(res)
            }
          // console.log("@@",this.tableData1);
          })
        }
        
        // if (this.coordination) {
        //   console.log(111111,this.coordination);
        //   this.$api.querySynery(PatentRight).then(res => {
        //     if (res.code == 200) {
        //       this.CompareMessage(res)
        //     }
        //   // console.log("@@",this.tableData1);
        //   })
        // }else if (this.typeFto==1&&this.taskWorkRemakA!=0) {
        //   console.log(111111,this.coordination);
        //   this.$api.querySynery(PatentRight).then(res => {
        //     if (res.code == 200) {
        //       this.CompareMessage(res)
        //     }
        //   // console.log("@@",this.tableData1);
        //   })
        // }
        // else if (this.taskWorkRemakA == 0) {
        //   this.$api.queryAllCompareMessage(PatentRight).then(res => {
        //     console.log(2222, this.taskWorkRemakA);
        //     if (res.code == 200) {
        //       this.CompareMessage(res)
        //     }
        //   // console.log("@@",this.tableData1);
        //   })
          
        // }else {//queryCompareMessage
        //    this.$api.queryCompareMessage(PatentRight).then(res => {
        //     console.log(3333,this.coordination);
        //     if (res.code == 200) {
        //       this.CompareMessage(res)
        //     }
        //   // console.log("@@",this.tableData1);
        //   })
        // }
      },
      //查询对比记录数据处理
      CompareMessage(res) {
        this.tableData1 = [];
        for (let i = 0; i < res.data.patentRightVos.length; i++) {
          // if (res.data.patentRightVos[i].features.length>0) {
          for (let m = 0; m < res.data.patentRightVos[i].compareMessageVOS.length; m++) {
            res.data.patentRightVos[i].compareMessageVOS[m].pSignPatentNo = res.data.patentRightVos[i].signPatentNo
            res.data.patentRightVos[i].compareMessageVOS[m].pPatentId = res.data.patentRightVos[i].patentId
            res.data.patentRightVos[i].compareMessageVOS[m].pContent = res.data.patentRightVos[i].content
            res.data.patentRightVos[i].compareMessageVOS[m].pType = res.data.patentRightVos[i].type
            res.data.patentRightVos[i].compareMessageVOS[m].pSort = res.data.patentRightVos[i].sort
            res.data.patentRightVos[i].compareMessageVOS[m].pReportId = res.data.patentRightVos[i].reportId
            res.data.patentRightVos[i].compareMessageVOS[m].pRightName = res.data.patentRightVos[i].RightName
            res.data.patentRightVos[i].compareMessageVOS[m].pContentOut = res.data.patentRightVos[i].contentOut
            // res.data.patentRightVos[i].compareMessageVOS[m].CMid = res.data.patentRightVos[i].CMid
            let a = ['explainText', 'targetDescription', 'compareDescription', 'compareResult']
            a.forEach(item => {
              if (!res.data.patentRightVos[i].compareMessageVOS[m].hasOwnProperty(item)) {//hasOwnProperty判断属性是否存在
                if (item == 'explainText') {
                  res.data.patentRightVos[i].compareMessageVOS[m][item] = res.data.patentRightVos[i].compareMessageVOS[m].contentOut
                } else {
                  res.data.patentRightVos[i].compareMessageVOS[m][item] = ''
                }
              } else {
                if (res.data.patentRightVos[i].compareMessageVOS[m][item] == "") {//属性存在等于空
                  if (item == 'explainText') {
                    res.data.patentRightVos[i].compareMessageVOS[m][item] = res.data.patentRightVos[i].compareMessageVOS[m].contentOut
                  }
                }
              }
            })

            this.tableData1.push(res.data.patentRightVos[i].compareMessageVOS[m])
          }
        }
        this.$forceUpdate()
        console.log(this.tableData1)
        this.TypeSelect(this.Type)//调用显示权要
        // this.getSpanArr(this.tableData)
        this.loading = false
      },

      //拆分权要
      splitPatentRight() {//patentRightVos
        this.loading=true
        let PatentRight = {
          patentNo: this.patentNo,
          splitType: this.splitType1,
          splitBy: this.splitBy1,
          taskId: this.taskId?this.taskId:null,
          ReportId:this.reportId
        }
        this.$api.splitPatentRight(PatentRight).then(res => {
          if (res.code == 200) {
            this.tableData1 = [];
            for (let i = 0; i < res.data.patentRightVos.length; i++){
              // if (res.data.patentRightVos[i].features.length>0) {
                for (let m = 0; m < res.data.patentRightVos[i].features.length; m++){
                  res.data.patentRightVos[i].features[m].pSignPatentNo=res.data.patentRightVos[i].signPatentNo
                  res.data.patentRightVos[i].features[m].pPatentId=res.data.patentRightVos[i].patentId
                  res.data.patentRightVos[i].features[m].pContent=res.data.patentRightVos[i].content
                  res.data.patentRightVos[i].features[m].pType=res.data.patentRightVos[i].type
                  res.data.patentRightVos[i].features[m].pSort=res.data.patentRightVos[i].sort
                  res.data.patentRightVos[i].features[m].pReportId=res.data.patentRightVos[i].reportId
                  res.data.patentRightVos[i].features[m].pRightName=res.data.patentRightVos[i].RightName
                  res.data.patentRightVos[i].features[m].pContentOut = res.data.patentRightVos[i].contentOut
                  let a = ['explainText','targetDescription','compareDescription','compareResult']
                  a.forEach(item=>{
                    if (!res.data.patentRightVos[i].features[m].hasOwnProperty(item)) {//hasOwnProperty判断属性是否存在
                      if(item == 'explainText'){
                        res.data.patentRightVos[i].features[m][item]=res.data.patentRightVos[i].features[m].contentOut
                      }else{
                        res.data.patentRightVos[i].features[m][item]=''
                      }
                    } else {
                      if (res.data.patentRightVos[i].features[m][item]=="") {//属性存在等于空
                        if(item == 'explainText'){
                          res.data.patentRightVos[i].features[m][item]=res.data.patentRightVos[i].features[m].contentOut
                        }
                      }
                    }
                  })
                  
                  this.tableData1.push(res.data.patentRightVos[i].features[m])
                }
            }
            this.$forceUpdate()
            console.log(this.tableData1)
            this.TypeSelect(this.Type)//调用显示权要
            // this.getSpanArr(this.tableData)
            this.loading=false
          }
          // console.log("@@",this.tableData1);
        })
      },
  
      // 条件选择下拉框
      splitTypeSelect(event) {//拆主权要
        this.splitType1 = event;
        this.splitPatentRight()
      },
      splitBySelect(event) {//按符号拆分
        console.log(event);
        this.splitBy1 = event;
        this.splitPatentRight();
      },
      TypeSelect(event) {//显示
        this.typeArr = [];
        if (event==1) {
          this.typeArr.push(1);
        } else {
          this.typeArr.push(1, 0);
        }
        // console.log("@@",this.tableData);
        // console.log("@@",this.tableData1);
        this.tableData = this.tableData1.filter(item => {
           return this.typeArr.includes(item.pType)
        })
        // console.log("tableData",this.tableData);
        this.getSpanArr(this.tableData)
      },
     
      //保存
      keep() {
        console.log(this.tableData1);
        this.loadings = true
        this.$emit("isRead",0)
        if (this.coordination || (this.typeFto==1&&this.taskWorkRemakA!=0) ) {
          console.log(1111, this.coordination,this.typeFto);
          var keepAddSynerys = {
            patentNo:this.patentNo1,
            taskId: this.taskId,
            compareMessageList: [],
          }
          for (let i = 0; i < this.tableData1.length; i++) {
            keepAddSynerys.compareMessageList.push(
              {
                featureId: this.tableData1[i].id,
                targetDescription: this.tableData1[i].targetDescription ? this.tableData1[i].targetDescription : "",
                compareDescription: this.tableData1[i].compareDescription ? this.tableData1[i].compareDescription : "",
                compareResult: this.tableData1[i].compareResult,
              }
            )
          }
          console.log( this.tableData1[0].compareResult,keepAddSynerys);
          this.$api.addSynery(keepAddSynerys).then(res => {
            if (res.code == 200) {
              this.keepOk()
            }
          })

        }else if (this.taskWorkRemakA==0) {
          console.log(2222, this.taskWorkRemakA,this.tableData1);
          let keepUpdate=[]
          for (let i = 0; i < this.tableData1.length; i++) {
            keepUpdate.push(
              {
                featureId: this.tableData1[i].id,
                targetDescription: this.tableData1[i].targetDescription ? this.tableData1[i].targetDescription : "",
                compareDescription: this.tableData1[i].compareDescription ? this.tableData1[i].compareDescription : "",
                compareResult: this.tableData1[i].compareResult,

              }
            )
          }
          // console.log(keepAddSynerys);
          this.$api.updateCompareMessage(keepUpdate).then(res => {
            if (res.code == 200) {
              this.keepOk()
            }
          })
          
        }else {
          console.log(3333, this.coordination);
          var keepArr = [];
          console.log(this.tableData1);
          for (let i = 0; i < this.tableData1.length; i++) {
            console.log(1, this.tableData1[i].compareResult);
            keepArr.push(
              {
                taskId: this.taskId?this.taskId:null,
                signPatentNo: this.tableData1[i].signPatentNo,
                contentOut: this.tableData1[i].contentOut,
                content: this.tableData1[i].content,
                rightId: this.tableData1[i].rightId,
                isFinal: this.tableData1[i].isFinal,
                reportId: this.tableData1[i].reportId,
                rightName: this.tableData1[i].rightName,
                rightType: this.tableData1[i].rightType,
                splitBy: this.tableData1[i].splitBy,
                explainText: this.tableData1[i].explainText ? this.tableData1[i].explainText : "",
                targetDescription: this.tableData1[i].targetDescription ? this.tableData1[i].targetDescription : "",
                compareDescription: this.tableData1[i].compareDescription ? this.tableData1[i].compareDescription : "",
                compareResult: this.tableData1[i].compareResult.toString() != "" ? this.tableData1[i].compareResult : "",
              }
            )
          }
          console.log(keepArr);

          this.$api.addCompareMessage(keepArr).then(res => {
            console.log(res);
            if (res.code == 200) {
              this.keepOk()
            }

          })
        }

      },
      //保存成功处理
      keepOk() {
        this.keepSure = true;
        this.$message({
          message: '保存成功',
          type: 'success'
        });
        this.loadings=false
        this.queryCompareMessage()
      },
      // 点击完成协同按钮邮件发送完成通知
      keepSendCollaboration() {
        this.$confirm('确认协同任务完成并发送邮件通知, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.$api.taskFinish({id:this.taskId}).then((res) => {
                this.$message.success("任务完成，邮件已发送成功")
              })
            }).catch(() => {
              this.$message.info("已取消，请您继续进行协同任务")         
        });
      },
      // 一键修改
      handleClick(row) {
        // console.log(this.tableData1,row);
        // let a=this.tableData1.findIndex(item => {
        //   return item.id==row.id
        // })
        row.targetDescription=row.targetDescription2
        row.compareDescription=row.compareDescription2
        row.compareResult = row.compareResult2
        this.$message.success("修改成功,请进行保存")
      },
    },
  }
   
  
  </script>
    
<style lang="less">
  .claims-imput-import{
    display: flex;
    justify-content: space-between;
  }
  .spanImprot{
    color: #42A5F5;
    cursor :pointer;
  }
  .spanImprot:hover{
      cursor :pointer;
      color: red;
      text-decoration:underline;
  }
    </style>