<!-- 发补寄（批量） -->
<template>
  <div>
    <dialog-edit :appendToBody="appendToBody" :visible.sync="dialogVisible" :editModel="editModel" :form="supForm" :title="editModel === 'BIS'? $t('effectDealFeedBackMain.sendings'):(editModel === 'EIS'?$t('effectDealFeedBackMain.sendingDzz'):$t('effectDealFeedBackMain.sendingXz'))" :saveFlag="saveFlag">
      <div class="suppleDocBatchPop">
      <dym-form v-if="editModel === 'BIS'" :componentList="componentList" :formValue="supForm"></dym-form>
      <externalTransition v-if="editModel === 'BIS'" :isActive="false">
      </externalTransition>
      <data-table :sourceData.sync="firstTable" :loadCount="loadCount" :queryParas.sync="queryParas" :columns="editModel === 'EIS' ? firstSigleColumns:firstColumns" :api="editModel === 'EIS'? SupbEApi : SupbFApi" v-bind="{maxHeight:400, spanMethod:e => objectSpanMethod(firstTable, e)}">
        <template slot="fileOssids" slot-scope="scope">
          <btn-batch-download :disabled="scope.data.row.fileOssids.length === 0" size="small" :title="$t('common.downLoad')" :fileID="scope.data.row.fileOssids" :downloadFileName="scope.data.row.fileOssids.length > 1 ? $t('retrievalContentIndex.enclosure') + '.zip':null"></btn-batch-download>
        </template>
        <template slot="relationFileIds" slot-scope="scope">
          <btn-batch-download :disabled="scope.data.row.relationFileIds.length === 0" size="small" :title="$t('common.downLoad')" :fileID="scope.data.row.relationFileIds" :downloadFileName="scope.data.row.relationFileIds.length > 1 ? $t('retrievalContentIndex.enclosure') + '.zip':null"></btn-batch-download>
        </template>
        <!-- 鲜章 -->
        <template #replyLawContent="scope">
          <span-plus :index="scope.data.$index" :text="scope.data.row.replyLawContent"></span-plus>
        </template>
        <template #feedbackQuestionContent="scope">
          <span-plus :index="scope.data.$index" :text="scope.data.row.feedbackQuestionContent"></span-plus>
        </template>
        <!-- 电子章 -->
        <template #practicableSuggestion="scope">
          <span-plus :index="scope.data.$index" :text="scope.data.row.practicableSuggestion"></span-plus>
        </template>
        <template #relationResolution="scope">
          <span-plus :index="scope.data.$index" :text="scope.data.row.relationResolution"></span-plus>
        </template>
      </data-table>
      <!-- 发补寄文件列表 -->
      <data-table class="suppleFileList" :showPage="showPage" :sourceData.sync="secondTable" :columns="secondColumns" :showSelection="showSelection" @selectRowChange="selectRowChange" :row-class-name="rowClassName">
        <template slot="headButton">
          <!-- 标题 -->
          <div align="center" class="suppleFileList_title">{{$t('feedbackMaterialIndex.fileList')}}</div>
          <div align="right" class="suppleFileList_btn">
            <!-- 新增 -->
            <auth-button type="primary" icon="iconfont iconxinzeng" :size="'medium'" :label="$t('feedbackMaterialIndex.addT')" @click="addRowData()"></auth-button>
            <!-- 删除 -->
            <auth-button type="danger" icon="iconfont iconshanchu1" :size="'medium'" :label="$t('common.delete')" @click="deleteRowData()"></auth-button>
          </div>
        </template>
        <!-- 文件名称 -->
        <template slot="fileName" slot-scope="scope">
          <file-name-list v-model="scope.data.row.fileCode" :queryParas="supForm" @selectChanged="selectChanged(arguments, scope.data.row.id)"></file-name-list>
        </template>
        <!-- 需补原件份数 -->
        <template slot="electronicSealsFileCopies" slot-scope="scope">
          <file-copy-input v-model="scope.data.row.electronicSealsFileCopies"></file-copy-input>
        </template>
        <!-- 补寄意见/备注 -->
        <template slot="memo" slot-scope="scope">
          <el-input type="textarea" v-model="scope.data.row.memo" :placeholder="$t('effectDealFeedBackMain.lawChoose')" maxlength="250"></el-input>
        </template>
        <!-- 上传 -->
        <template slot="upload" slot-scope="scope">
          <btn-batch-upload :ref="'upload'+scope.data.row.id" :uploadApi="uploadApi" type="primary" :classType="true" :title="$t('common.upload')" :btnDisplay="true" @uploadSuccess="uploadSuccess(arguments,scope.data.row, scope.data.$index)"></btn-batch-upload>
        </template>
        <!-- 选择 -->
        <template slot="select" slot-scope="scope">
          <auth-button size="small" class="iconCircle" :ref="'select'+scope.data.row.id" :title="$t('common.select')" icon="iconfont iconxuanze" @click="selectDoc(scope.data.row)"></auth-button>
        </template>
        <!-- 归档文件下载 -->
        <template slot="archiveDownload" slot-scope="scope">
          <btn-download v-if="editModel === 'EIS'" size="small" :title="$t('common.downLoad')" :fileID="scope.data.row.UnsealedFileId" :disabled="!scope.data.row.UnsealedFileId || scope.data.row.UnsealedFileId === ''"></btn-download>
          <!-- <btn-download v-else size="small" :title="$t('common.downLoad')" :fileID="archiveDatafileDown(scope.data.row.fileCode)"></btn-download> -->
          <auth-button v-else :disabled="!scope.data.row.fileCode || scope.data.row.fileCode === ''" class="iconCircle" :title="$t('common.downLoad')" icon="iconfont iconxiazai" size="small"  @click="archiveDatafileDown(scope.data.row.fileCode)"></auth-button>
        </template>
        <!-- 补/替 -->
        <template slot="replacementFlag" slot-scope="scope">
          <el-radio-group v-model="scope.data.row.replacementFlag" :disabled="editModel === 'EIS' ? true : false">
            <el-radio label="1">{{$t('effectDealFeedBackMain.mend')}}</el-radio>
            <el-radio label="2">{{$t('effectDealFeedBackMain.replace')}}</el-radio>
          </el-radio-group>
        </template>
      </data-table>
      </div>
      <template slot="footer">
          <!--提交-->
          <auth-button :label="editModel === 'BIS' ? $t('common.submit') : $t('projectCompany.btnDone')" type="primary" size="medium" @click="submit('S')"></auth-button>
          <!--下一条-->
          <auth-button v-if="editModel === 'BIS' && keyIdArray.length !== fix" :label="$t('effectDealFeedBackMain.nextMemo')" type="primary" size="medium" @click="next('N')"></auth-button>
      </template>
    </dialog-edit>
    <supple-doc-fresh-sub v-if="suppleDocFreshVisible" :visible.sync="suppleDocFreshVisible" :selectId="selectId" :editModel="editModel" @selectData="selectData" :No="No"></supple-doc-fresh-sub>
  </div>
</template>

<script>
import { BATCH_UPLOAD_API } from '@/constant'
import * as format from '@/filters/index'
import fileApi from '@/api/fileApi.js'
import { downFile } from '@/utils/devUtils'
import effectDealFeedBackApi from '@/api/assetoutfeedback/effectDealFeedBack/effectDealFeedBackApi'
import suppleDocFreshSub from '@/pages/assetoutfeedback/effectDealFeedBack/suppleDocFreshSub'
import fileCopyInput from '@/pages/assetoutfeedback/effectDealFeedBack/effectDealFeedBackCom/fileCopyInput'
import externalTransition from '@/components/element/assetoutfeedback/externalTransition'
import fileNameList from '@/components/element/assetoutfeedback/fileNameList'
import BasePage from '@/pages/baseEditPage'
import btnBatchUpload from '@/components/element/assetoutfeedback/btnBatchUpload'
import { dymForm, DialogEdit, DataTable, btnBatchDownload, authButton, btnDownload, SpanPlus } from 'newepoch-components'
export default {
  components: { DialogEdit, DataTable, btnBatchDownload, dymForm, externalTransition, fileNameList, authButton, suppleDocFreshSub, btnBatchUpload, fileCopyInput, btnDownload, SpanPlus },
  extends: new BasePage(),
  props: {
    form: {
      type: Object,
      default () {
        return {}
      }
    },
    keyIdArray: {
      type: Array,
      default () {
        return []
      }
    },
    editModel: {
      type: String,
      default () {
        return ''
      }
    },
    rowData: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  computed: {
    // 操作发补寄
    SupbApi () {
      return effectDealFeedBackApi.getSupplementBatch
    },
    // 电子章
    SupbEApi () {
      return effectDealFeedBackApi.getSupplementElec
    },
    // 鲜章
    SupbFApi () {
      return effectDealFeedBackApi.getSupplementFresh
    },
    danganApi () {
      return effectDealFeedBackApi.getDanganData
    },
    effectForm: {
      get: function () {
        return this.form
      },
      set: function (value) {
        this.$emit('update:form', value)
      }
    }
  },
  data () {
    return {
      No: '',
      uploadApi: BATCH_UPLOAD_API,
      appendToBody: true,
      selectId: '',
      deleteData: [],
      supForm: {},
      queryParas: {
        pageIndex: 1,
        pageSize: 10,
        flag: '1'
      },
      fix: 1,
      loadCount: 0,
      saveFlag: false,
      suppleDocFreshVisible: false,
      showPage: false,
      showSelection: true,
      componentList: [
        {
          // 付款确认书编号
          value: 'assetCode',
          disabled: true,
          componentName: 'el-input',
          label: this.$i18n.messages[this.$i18n.locale].feedbackMaterialIndex.payCode,
          labelWidth: '125px',
          name: 'assetCode',
          placeholder: '',
          cols: [8, 8, 8, 8],
          prop: 'assetCode'
        }, {
          // 供应商盖章方式
          value: 'stampWay140',
          disabled: true,
          componentName: 'el-input',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.suppliersStampWay,
          labelWidth: '125px',
          name: 'stampWay140',
          placeholder: '',
          cols: [8, 8, 8, 8],
          prop: 'stampWay140'
        }, {
          // 项目公司章方式
          value: 'stampWay150',
          disabled: true,
          componentName: 'el-input',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.projectCompanyStampWay,
          labelWidth: '125px',
          name: 'stampWay150',
          placeholder: '',
          cols: [8, 8, 8, 8],
          prop: 'stampWay150'
        }
      ],
      firstTable: [],
      firstColumns: [
        {
          // 问题序号
          prop: 'qusetionNumber',
          align: 'center',
          width: '40px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackQustionNo
        }, {
          // 反馈次数
          prop: 'feedbackTimes',
          align: 'center',
          width: '40px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackTimes
        }, {
          // 律所意见
          prop: 'feedbackQuestionContent',
          align: 'left',
          slot: true,
          width: '160px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.replyLawContent
        }, {
          // 合规回复律所意见
          prop: 'replyLawContent',
          align: 'left',
          slot: true,
          width: '160px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackQuestionContent
        }, {
          // 相关附件
          prop: 'fileOssids',
          align: 'center',
          slot: true,
          width: '60px',
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.relatedAttachment
        }
      ],
      firstSigleColumns: [
        {
          // 反馈次数
          prop: 'feedbackTimes',
          align: 'center',
          width: '60px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackTimes
        }, {
          // 律所意见
          prop: 'feedbackQuestionContent',
          align: 'left',
          width: '120px',
          slot: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.replyLawContent
        }, {
          // 合规落实
          prop: 'practicableSuggestion',
          align: 'left',
          width: '120px',
          slot: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.practicableSuggeste
        }, {
          // 相关方
          prop: 'relationType',
          align: 'center',
          width: '60px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.relation,
          format (row) {
            return format.formatDict(row.relationType, 'AUDIT_OUT_RELATION_TYPE')
          }
        }, {
          // 相关方意见
          prop: 'relationResolution',
          align: 'left',
          width: '120px',
          slot: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.relationResolution
        }, {
          // 相关附件
          prop: 'relationFileIds',
          align: 'center',
          slot: true,
          width: '60px',
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.relatedAttachment
        }
      ],
      secondTable: [],
      secondColumns: [
        {
          // 文件名称
          prop: 'fileName',
          align: 'center',
          width: '120px',
          label: this.$i18n.messages[this.$i18n.locale].expressDataList.fileName,
          slot: true
        }, {
          // 需补原件份数
          prop: 'electronicSealsFileCopies',
          align: 'left',
          width: '50px',
          label: this.editModel === 'EIS' ? this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.SealsFileCopies : this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.electronicSealsFileCopies,
          slot: true
        }, {
          // 补寄意见/备注
          prop: 'memo',
          align: 'left',
          width: '160px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.memo,
          slot: true
        }, {
          // 上传
          prop: 'upload',
          align: 'center',
          width: '40px',
          label: this.$i18n.messages[this.$i18n.locale].common.upload,
          slot: true
        }, {
          // 选择
          prop: 'select',
          align: 'center',
          slot: true,
          width: '40px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.select
        }, {
          // 归档文件下载
          prop: 'archiveDownload',
          align: 'center',
          slot: true,
          width: '60px',
          label: this.editModel === 'EIS' ? this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.unsealedFileDown : this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.archiveDownload
        }, {
          // 补/替(归档的文件相比)
          prop: 'replacementFlag',
          align: 'center',
          slot: true,
          width: '60px',
          label: this.editModel === 'EIS' ? this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.replacementFlagShort : this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.replacementFlag
        }
      ]
    }
  },
  watch: {
    fix (newValue) {
      this.queryParas.feedbackAssetKey = this.keyIdArray[newValue - 1].keyId
      this.handleFilter()
    }
  },
  mounted () {
    this.dataFullFit()
    if (this.editModel === 'EIS') {
      // 电子章
      if (this.rowData.lawEditModel === 'A' && this.rowData.code === 'LS') {
        this.queryParas.keyId = this.form.notHandleQuestionDtoList[this.form.index].qstDetailKeyId
      } else if ((this.rowData.lawEditModel === 'IS' || this.rowData.lawEditModel === 'I') && this.rowData.code === 'LS') {
        this.queryParas.keyId = this.form.notImplementAssetInfoDto.questionList[this.form.index].keyId
      } else if (this.rowData.lawEditModel === 'IS' && this.rowData.code === 'XGF') {
        this.queryParas.keyId = this.form.relationHandlingQuestionDtoList[this.form.index].qstDetailKeyId
      } else if (this.rowData.lawEditModel === 'IS' && this.rowData.code === 'SH') {
        this.queryParas.keyId = this.form.notHandleQuestionDtoList[this.form.cindex].qstDetailKeyId
      } else if (this.rowData.code === 'SLS') {
        this.queryParas.keyId = this.form.notImplementAssetInfoDto.questionList[this.form.index].relationHandlingDtoList[this.form.aindex].questionKeyId
      }
      this.queryParas.relationType = this.rowData.relationType
      this.elecDataSave()
    } else {
      Object.assign(this.queryParas, { 'feedbackAssetKey': this.editModel === 'BIS' ? this.keyIdArray[this.fix - 1].keyId : this.form.fdbkKeyId })
    }
    // 电子章补寄数据缓存
    this.$nextTick(() => {
      this.handleFilter()
    })
  },
  methods: {
    // 电子章补寄数据缓存
    elecDataSave () {
      if (this.rowData.code === 'LS') {
        if (this.effectForm.notImplementAssetInfoDto.questionList[this.effectForm.index].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList) {
          this.secondTable = this.effectForm.notImplementAssetInfoDto.questionList[this.effectForm.index].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList
        }
      } else if (this.rowData.code === 'XGF') {
        if (this.effectForm.relationHandlingQuestionDtoList[this.effectForm.index].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList) {
          this.secondTable = this.effectForm.relationHandlingQuestionDtoList[this.effectForm.index].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList
        }
      } else if (this.rowData.code === 'SH') {
        if (this.effectForm.notHandleQuestionDtoList[this.effectForm.cindex].checkButtonPostDtoList[0].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList) {
          this.secondTable = this.effectForm.notHandleQuestionDtoList[this.effectForm.cindex].checkButtonPostDtoList[0].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList
        }
      } else if (this.rowData.code === 'SLS') {
        if (this.effectForm.notImplementAssetInfoDto.questionList[this.effectForm.index].relationHandlingDtoList[this.effectForm.aindex].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList) {
          this.secondTable = this.effectForm.notImplementAssetInfoDto.questionList[this.effectForm.index].relationHandlingDtoList[this.effectForm.aindex].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList
        }
      }
    },
    // 归档文件下载
    archiveDatafileDown (fileCode) {
      let params = {
        assetInfoIds: [this.supForm.assetInfoId],
        fileCodes: [fileCode],
        fileTypes: ['']
      }
      this.danganApi.getDefaultfile(params).then(res => {
        if (res.data && res.data.length > 0) {
          fileApi.file.download({ keyId: res.data[0].fileInfos[0].ossId }).then(res => {
            downFile(res)
          })
        } else {
          this.warning('没有可下载的归档文件')
        }
      })
      // this.danganApi.getDefaultfilePage({ fileCode: fileCode }).then(res => {
      //   console.log(2)
      // })
    },
    // 更新表数据
    handleFilter () {
      this.loadCount = this.loadCount + 1
    },
    // 处理反馈数据填充
    dataFullFit (callback) {
      let param = {}
      if (this.editModel === 'EIS') {
        if (this.rowData.lawEditModel === 'A' && this.rowData.code === 'LS') {
          Object.assign(param, { assetCode: this.form.assetCode })
        } else {
          Object.assign(param, { assetCode: this.form.notImplementAssetInfoDto.assetCode })
        }
      } else if (this.editModel === 'FIS') {
        Object.assign(param, { assetCode: this.form.assetCode })
      } else {
        param = this.keyIdArray[this.fix - 1]
      }
      this.SupbApi.getDefaultInfo(param).then(res => {
        if (res.data) {
          this.supForm = res.data
          this.supForm.editModel = this.editModel
          this.supForm.stampWay140 = format.formatDict(this.supForm.stampWay140, 'ZD0081')
          this.supForm.stampWay150 = format.formatDict(this.supForm.stampWay150, 'ZD0081')
          let flag = true
          callback && callback(flag)
        }
      })
    },
    // 下一条
    next (val) {
      this.submit(val, res => {
        if (res) {
          if (this.fix < this.keyIdArray.length) {
            this.fix++
            this.dataFullFit(res => {
              this.secondTable = []
            })
            document.getElementsByClassName('el-dialog__body')[0].scrollTo(0, 0)
          }
        }
      })
    },
    // 发补寄选择弹窗
    selectDoc (row) {
      this.No = row.id
      this.selectId = this.queryParas
      this.suppleDocFreshVisible = true
    },
    // 新增发补寄列表信息
    addRowData () {
      if (!this.handleSubmit()) {
        return
      }
      if (this.UtilJs.isEmpty(this.supForm)) {
        this.warning('没有可发补寄数据')
        return
      }
      this.secondTable.push({
        fileName: '',
        assetCode: this.supForm.assetCode,
        assetInfoId: this.supForm.assetInfoId,
        fileIdList: [],
        fileCode: '',
        targetType: '',
        elecFreshType: this.editModel === 'EIS' ? '1' : '2',
        electronicSealsFileCopies: 0,
        memo: '',
        replacementFlag: this.editModel === 'EIS' ? '2' : '1'
      })
    },
    // 发补寄列表行选择发生，触发事件
    selectRowChange (selection) {
      this.deleteData = selection
    },
    // 删除发补寄列表信息
    deleteRowData () {
      let k = 0
      if (this.deleteData.length > 0) {
        this.deleteData.forEach(res => {
          this.secondTable.splice(res.id - 1 - k, 1)
          k++
        })
      } else {
        this.warning('请选择需要删除的数据')
      }
    },
    // 判断提交
    handleSubmit () {
      let flag = true
      if (this.secondTable.length > 0) {
        this.secondTable.every(res => {
          if (res.fileCode === '') {
            this.warning('请选择文件名')
            flag = false
            return flag
          } else if (res.memo === '') {
            this.warning('请填写补足意见/备注')
            flag = false
            return flag
          } else if (res.fileIdList && res.fileIdList.length === 0) {
            this.warning('请选择上传或选择文件')
            flag = false
            return flag
          }
        })
      }
      return flag
    },
    // 提交表单
    submit (val, callback) {
      if (this.secondTable.length === 0) {
        this.warning('请添加发补寄文件')
        return
      }
      if (!this.handleSubmit()) {
        return
      }
      let fixChange = this.fix
      if (this.editModel === 'EIS') {
        if (this.rowData.code === 'LS') {
          this.effectForm.notImplementAssetInfoDto.questionList[this.effectForm.index].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList = this.secondTable
        } else if (this.rowData.code === 'XGF') {
          this.effectForm.relationHandlingQuestionDtoList[this.effectForm.index].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList = this.secondTable
        } else if (this.rowData.code === 'SH') {
          this.effectForm.notHandleQuestionDtoList[this.effectForm.cindex].checkButtonPostDtoList[0].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList = this.secondTable
        } else if (this.rowData.code === 'SLS') {
          this.effectForm.notImplementAssetInfoDto.questionList[this.effectForm.index].relationHandlingDtoList[this.effectForm.aindex].replyRelationPostDtoList.filter(item => item.id === this.rowData.id)[0].supplementFilePostDTOList = this.secondTable
        }
        this.$nextTick(() => {
          this.success('电子章补寄填写完成')
          this.dialogVisible = false
        })
      } else {
        this.assetpkgmgrFullScreenLoading()
        this.SupbApi.defaultSave(this.secondTable).then(res => {
          this.assetpkgmgrFullScreenLoading().close()
          if (res.data) {
            callback && callback(res.data)
            this.success('发补寄成功')
            if (val === 'S' || fixChange === this.keyIdArray.length) {
              this.dialogVisible = false
              this.$emit('close', true)
            }
          } else {
            this.error('发补寄失败')
          }
        }).catch(res => {
          this.assetpkgmgrFullScreenLoading().close()
        })
      }
    },
    // 文件下拉选择
    selectChanged () {
      if (arguments[0][2]) {
        this.secondTable.filter(item => item.id === arguments[1])[0].fileName = arguments[0][2].fileName
        this.secondTable.filter(item => item.id === arguments[1])[0].targetType = arguments[0][2].targetType
        this.secondTable.filter(item => item.id === arguments[1])[0].fileCode = arguments[0][2].fileCode
        this.secondTable.filter(item => item.id === arguments[1])[0].UnsealedFileId = arguments[0][2].UnsealedFileId
      } else {
        this.secondTable.filter(item => item.id === arguments[1])[0].fileName = ''
        this.secondTable.filter(item => item.id === arguments[1])[0].fileCode = ''
        this.secondTable.filter(item => item.id === arguments[1])[0].targetType = ''
        this.secondTable.filter(item => item.id === arguments[1])[0].UnsealedFileId = ''
      }
    },
    rowClassName ({ row, rowIndex }) {
      row.id = rowIndex + 1
    },
    // 上传文件成功
    uploadSuccess () {
      let curRef = 'select' + arguments[1].id
      this.$refs[curRef].disabled = true
      arguments[1].fileIdList = arguments[0][0].fileList
    },
    // 选择文件
    selectData (val, No) {
      let curRef = 'upload' + No
      this.$refs[curRef].disabled = true
      this.secondTable.filter(res => res.id === No)[No - 1].fileIdList = val
    },
    // 行合并
    objectSpanMethod (item, { row, column, rowIndex, columnIndex }) {
      let spanCount = 1
      if (columnIndex > -1 && columnIndex < 1) {
        if (rowIndex === 0 || item[rowIndex - 1].qusetionNumber !== row.qusetionNumber) {
          item.reduce((last, current) => {
            if (last.qusetionNumber === row.qusetionNumber && last.qusetionNumber === current.qusetionNumber) {
              spanCount++
            }
            return current
          })
          return {
            rowspan: spanCount,
            colspan: 1
          }
        }
        return {
          rowspan: 0,
          colspan: 0
        }
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  @import '~@/styles/assetoutfeedback/common.scss'
</style>
