<!-- 处理反馈 -->
<template>
  <div>
    <dialog-edit :appendToBody="true" :visible.sync="dialogVisible" :editModel="editModel" :form="forms" :title="batchTitle" :saveFlag="saveFlag" :formRules="rules" ref="dialogform">
      <div class="effectBatchPop">
        <div class="effectdiv" v-show="batchTabNum === '1'">
          <el-form-item v-if="editModel === 'A'" :label="$t('feedBackMain.feedbackFrequency')" label-width="110px" prop="freq">
              <feed-back-freq-select-list v-model="forms.freq" :queryParas="newForm" @selectChanged="myselectChanged"></feed-back-freq-select-list>
          </el-form-item>
          <div v-if="editModel !== 'IS'" :class="editModel === 'A' ? 'spanTextA' : 'spanTextB'"><span class="effectoutfontStyle">共{{batchkeyIdArray.length}}笔 目前正在落实第{{fix}}笔</span></div>
        </div>
        <el-tabs type="card" v-model="batchTabNum" @tab-click="batchTabClick()">
          <el-tab-pane v-for="item in batchTab" :key="item.index" :label="item.label" :name="item.index">
          </el-tab-pane>
        </el-tabs>
        <keep-alive>
          <component :is="component.filter(res => res.index === batchTabNum)[0].name" :editModel="editModel" :form.sync="dealForm" :key="batchTabNum"
            :fileForm="form"
            :ref="component.filter(res => res.index === batchTabNum)[0].name" :effectForm.sync="effectForm" :effApi="effApi"
            @saveStatus="getValue($event)" :assetInfoId="assetInfoId"></component>
        </keep-alive>
      </div>
        <template slot="footer">
            <!--提交-->
            <auth-button v-show="batchTabNum === '1'" :label="$t('common.submit')" type="primary" size="medium" @click="save('S')"></auth-button>
            <!--下一条-->
            <auth-button v-show="batchTabNum === '1' && editModel !== 'IS' && fix !== batchkeyIdArray.length" :label="$t('effectDealFeedBackMain.nextMemo')" type="primary" size="medium" @click="next('N')"></auth-button>
        </template>
    </dialog-edit>
  </div>
</template>

<script>
import BasePage from '@/pages/baseEditPage'
import * as format from '@/filters/index'
import { mapGetters } from 'vuex'
import effectDealFeedBackApi from '@/api/assetoutfeedback/effectDealFeedBack/effectDealFeedBackApi'
import feedBackFreqSelectList from '@/components/element/assetoutfeedback/feedBackFreqSelectList'
import processFeedback from '@/pages/assetoutfeedback/effectDealFeedBack/processFeedback'
import assetFileDownPop from '@/pages/assetoutfeedback/effectDealFeedBack/assetFileDownPop'
import baseAssetInfoPop from '@/pages/assetoutfeedback/effectDealFeedBack/baseAssetInfoPop'
import { DialogEdit, dymForm, authButton } from 'newepoch-components'
export default {
  extends: new BasePage(),
  components: { DialogEdit, dymForm, processFeedback, baseAssetInfoPop, assetFileDownPop, authButton, feedBackFreqSelectList },
  props: {
    form: {
      type: Object,
      default () {
        return {}
      }
    },
    popTitle: {
      type: String,
      default () {
        return ''
      }
    },
    editModel: {
      type: String,
      default () {
        return ''
      }
    },
    keyIdArray: {
      type: Array,
      default () {
        return []
      }
    },
    queryParamBatch: {
      type: Object,
      default () {
        return {}
      }
    },
    effApi: {
      type: Object,
      default () {
        return {}
      }
    },
    assetInfoId: {
      type: String,
      default () {
        return ''
      }
    }
  },
  data () {
    let $this = this
    return {
      forms: {
        freq: 1
      },
      batchkeyIdArray: [],
      newForm: {},
      saveStatus: false,
      saveFlag: false,
      batchTitle: '',
      dealForm: {
        notHandleQuestionDtoList: [],
        checked: ['1'],
        checkedAudit: ['1'],
        replyOutPostDto: {
          replyLawContent: '',
          uploadFilePostDtoList: []
        },
        relationHandlingQuestionDtoList: [],
        replyRelationPostDtoList: [],
        notImplementAssetInfoDto: {
          assetCode: '',
          projectCompanyName: '',
          suppliersName: '',
          questionList: []
        }
      },
      value: '',
      fix: 1,
      effectForm: {},
      // 校验规则
      rules: {
        freq: [
          {
            required: true,
            message: $this.$t('effectDealFeedBackMain.chooseFeedback'),
            trigger: 'change'
          },
          {
            required: true,
            message: $this.$t('effectDealFeedBackMain.chooseFeedback'),
            trigger: 'blur'
          }
        ]
      },
      component: [
        {
          index: '1',
          name: 'processFeedback'
        }, {
          index: '2',
          name: 'baseAssetInfoPop'
        }, {
          index: '3',
          name: 'assetFileDownPop'
        }
      ],
      batchTabNum: '1',
      batchTab: [{
        index: '1',
        label: $this.$t('effectDealFeedBackMain.handFeedback')
      }, {
        index: '2',
        label: $this.$t('feedBackMain.baseInfo')
      }, {
        index: '3',
        label: $this.$t('coordManageMain.dataDownload')
      }]
    }
  },
  computed: {
    ...mapGetters(['userId']),
    // 批量审核接口
    dealApi () {
      return effectDealFeedBackApi.getDealInfo
    }
  },
  mounted () {
    this.batchkeyIdArray = this.keyIdArray
    this.batchTitle = this.popTitle
    if (this.editModel === 'A') {
      this.newDataFullFit()
      let param = this.queryParamBatch
      param.feedbackFrequency = this.forms.freq
      this.frequence(param)
    } else {
      this.dataFullFit()
    }
  },
  methods: {
    frequence (param) {
      this.dealApi.getList(param).then(res => {
        if (res.data && res.data.length > 0) {
          this.batchkeyIdArray = res.data
          this.dataFullFit()
        } else {
          this.warning('没有该批次的数据')
          this.dealForm = {
            notHandleQuestionDtoList: [],
            checked: ['1'],
            checkedAudit: ['1'],
            replyOutPostDto: {
              replyLawContent: '',
              uploadFilePostDtoList: []
            },
            relationHandlingQuestionDtoList: [],
            replyRelationPostDtoList: [],
            notImplementAssetInfoDto: {
              assetCode: '',
              projectCompanyName: '',
              suppliersName: '',
              questionList: []
            }
          }
        }
      })
    },
    myselectChanged (val) {
      if (val !== '') {
        let param = this.queryParamBatch
        param.feedbackFrequency = val
        this.frequence(param)
      }
    },
    // 点击tab控制方法
    batchTabClick () {
      switch (this.batchTabNum) {
        case '1':
          this.batchTitle = this.popTitle
          break
        case '2':
          // 基础信息
          this.batchTitle = this.$i18n.messages[this.$i18n.locale].feedBackMain.baseInfo
          break
        case '3':
          // 资料下载
          this.batchTitle = this.$i18n.messages[this.$i18n.locale].coordManageMain.dataDownload
          break
      }
    },
    // 批量审核查询条件
    newDataFullFit () {
      this.effApi.getDefaultInfo(this.batchkeyIdArray[this.fix - 1]).then(res => {
        if (res.data) {
          if (this.editModel === 'A') {
            this.newForm = {
              projectId: res.data.notHandleQuestionDtoList[0].projectId,
              periods: res.data.notHandleQuestionDtoList[0].periods,
              auditFileType: res.data.notHandleQuestionDtoList[0].auditFileType
            }
          }
        }
      })
    },
    // 处理反馈数据填充
    dataFullFit (val) {
      this.effApi.getDefaultInfo(this.batchkeyIdArray[this.fix - 1]).then(res => {
        if (res.data) {
          // if (this.editModel === 'A') {
          //   this.newForm = {
          //     projectId: res.data.notHandleQuestionDtoList[0].projectId,
          //     periods: res.data.notHandleQuestionDtoList[0].periods,
          //     auditFileType: res.data.notHandleQuestionDtoList[0].auditFileType
          //   }
          // }
          // Object.assign(this.dealForm, { feedbackAssetKey: this.batchkeyIdArray[this.fix - 1].keyId })
          Object.assign(this.dealForm, res.data)
          Object.assign(this.dealForm, this.batchkeyIdArray[this.fix - 1])
          Object.assign(this.dealForm, { 'traceUserId': this.userId })

          // 审核
          if (this.editModel === 'A') {
            Object.assign(this.dealForm.notImplementAssetInfoDto, {
              suppliersStampWay: res.data.stampWay140,
              projectCompanyStampWay: res.data.stampWay150,
              assetCode: res.data.assetCode,
              projectCompanyName: res.data.projectCompanyName,
              suppliersName: res.data.suppliersName
            })
          }
          if (this.dealForm.notImplementAssetInfoDto && this.dealForm.notImplementAssetInfoDto.suppliersStampWay) {
            this.dealForm.notImplementAssetInfoDto.suppliersStampWay = format.formatDict(this.dealForm.notImplementAssetInfoDto.suppliersStampWay, 'ZD0081')
          }
          if (this.dealForm.notImplementAssetInfoDto && this.dealForm.notImplementAssetInfoDto.projectCompanyStampWay) {
            this.dealForm.notImplementAssetInfoDto.projectCompanyStampWay = format.formatDict(this.dealForm.notImplementAssetInfoDto.projectCompanyStampWay, 'ZD0081')
          }
          if (this.dealForm.notHandleQuestionDtoList && this.dealForm.notHandleQuestionDtoList.length > 0) {
            this.dealForm.notHandleQuestionDtoList.forEach(resSh => {
              if (resSh.relationDealStatus === '2') {
                this.$set(resSh, 'status', this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.noApproved)
              } else {
                this.$set(resSh, 'status', this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.noTerminated)
              }
            })
          }
          if (this.dealForm.notImplementAssetInfoDto.questionList && this.dealForm.notImplementAssetInfoDto.questionList.length > 0) {
            this.dealForm.notImplementAssetInfoDto.questionList.forEach(v => {
              this.$set(v, 'implementeStatus', this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.noImplemented)
              if (v.relationHandlingDtoList && v.relationHandlingDtoList.length > 0) {
                v.relationHandlingDtoList.forEach(vb => {
                  this.$set(vb, 'status', this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.noApproved)
                })
              }
            })
          }
          this.dealForm.notImplementAssetInfoDto.factoringMoney = format.thousandFilter(this.dealForm.notImplementAssetInfoDto.factoringMoney)
          if (this.dealForm.assetBasicInfoDto) {
            this.dealForm.assetBasicInfoDto.factoringMoney = format.thousandFilter(this.dealForm.assetBasicInfoDto.factoringMoney)
            this.dealForm.assetBasicInfoDto.dueDate = format.formatCheckDatetime(this.dealForm.assetBasicInfoDto.dueDate, 'yyyy-MM-dd')
            this.dealForm.assetBasicInfoDto.ifsUrgent = this.dealForm.assetBasicInfoDto.ifsUrgent === '0' ? this.$i18n.messages[this.$i18n.locale].common.no : this.$i18n.messages[this.$i18n.locale].common.yes
            this.dealForm.assetBasicInfoDto.relationEnterpiseFlag = this.dealForm.assetBasicInfoDto.relationEnterpiseFlag === '0' ? this.$i18n.messages[this.$i18n.locale].common.no : this.$i18n.messages[this.$i18n.locale].common.yes
            this.dealForm.assetBasicInfoDto.stampWay140 = format.formatDict(this.dealForm.assetBasicInfoDto.stampWay140, 'ZD0081')
            this.dealForm.assetBasicInfoDto.stampWay150 = format.formatDict(this.dealForm.assetBasicInfoDto.stampWay150, 'ZD0081')
            this.dealForm.assetBasicInfoDto.queryStatus = format.formatDict(this.dealForm.assetBasicInfoDto.queryStatus, 'QUERY_STATUS')
            this.dealForm.assetBasicInfoDto.registStatus = format.formatDict(this.dealForm.assetBasicInfoDto.registStatus, 'REGIST_STATUS')
            this.dealForm.assetBasicInfoDto.contractType = format.formatDict(this.dealForm.assetBasicInfoDto.contractType, 'ZD0107')
            this.dealForm.assetBasicInfoDto.nrcContractType = format.formatDict(this.dealForm.assetBasicInfoDto.nrcContractType, 'ZD0107')
            this.dealForm.assetBasicInfoDto.businessProcessStatus = format.formatDict(this.dealForm.assetBasicInfoDto.businessProcessStatus, 'SCRS0110')
            this.dealForm.assetBasicInfoDto.factoringRate = Number(this.dealForm.assetBasicInfoDto.factoringRate).toFixed(4)
          }
          if (this.$refs.processFeedback) {
            this.$refs.processFeedback.closeLs()
          }
          this.dealForm.checked = ['1']
        }
      })
    },
    // 提交
    save (val, callback) {
      if (this.$refs.processFeedback.$refs.effectFeedBack) {
        this.$refs.processFeedback.$refs.effectFeedBack.save('2', res => {
          if (res) {
            let fixChange = this.fix
            if (fixChange === this.batchkeyIdArray.length || val === 'S') {
              this.dialogVisible = false
              this.$emit('close', true)
            } else if (val === 'N') {
              callback && callback(res)
            }
          }
        })
      } else {
        this.$refs.dialogform.$refs.editForm.validate((valid) => {
          if (valid) {
            let param = {}
            let paramA = {}
            let params = {}
            if (this.editModel !== 'IS') {
              let arr = []
              param = this.dealForm
              Object.assign(param, { 'chargebackRiskFlag': this.dealForm.notImplementAssetInfoDto.chargebackRiskFlag })
              param.questionList = []
              this.dealForm.notImplementAssetInfoDto.questionList.forEach(res => {
                let arr = []
                if (res.replyRelationPostDtoList && res.replyRelationPostDtoList.length > 0) {
                  res.replyRelationPostDtoList.forEach(resq => {
                    if (resq.practicableSuggestion !== '' && resq.supplementNoFile !== '') {
                      let arrfile = []
                      resq.uploadFilePostDtoList.forEach(resf => {
                        if (resf.fileId !== '') {
                          arrfile.push(resf)
                        }
                      })
                      arr.push(resq)
                    }
                  })
                  res.replyRelationPostDtoList = arr
                }
                if (res.replyOutPostDto && res.replyOutPostDto.replyLawContent !== '') {
                  let reparrfile = []
                  res.replyOutPostDto.uploadFilePostDtoList.forEach(resf => {
                    if (resf.fileId !== '') {
                      reparrfile.push(resf)
                    }
                  })
                  res.replyOutPostDto.uploadFilePostDtoList = reparrfile
                }
              })
              this.dealForm.notImplementAssetInfoDto.questionList.forEach((res, i) => {
                if (this.editModel === 'A') {
                  res.relationQustionFlag = this.dealForm.notHandleQuestionDtoList[i].relationQustionFlag
                  res.relationDealStatus = this.dealForm.notHandleQuestionDtoList[i].relationDealStatus
                  res.status = this.dealForm.notHandleQuestionDtoList[i].status
                }
                if ((res.practicableResult === '1' && res.replyOutPostDto.replyLawContent !== '' && res.relationQustionFlag === '1') ||
                (res.practicableResult === '2' && res.replyRelationPostDtoList.length > 0 && res.relationQustionFlag === '1') ||
                (res.relationQuestionType && res.relationQustionNo && res.relationQustionNo !== '' && res.relationQustionFlag === '2') ||
                (res.relationHandlingDtoList && res.relationHandlingDtoList.length > 0) || (res.relationDealStatus === '1' && res.status === '已终止')) {
                  if (res.relationHandlingDtoList && res.relationHandlingDtoList.length > 0) {
                    res.relationHandlingTaskDto = {}
                    res.relationHandlingTaskDto.questionKeyId = res.relationHandlingDtoList[0].questionKeyId
                    res.relationHandlingTaskDto.relationHandlingDetailTaskDtoList = res.relationHandlingDtoList
                    res.relationHandlingTaskDto.relationHandlingDetailTaskDtoList.forEach(qres => { qres.keyId = qres.relationKeyId })
                  }
                  delete res.historyDealingsSuggestionDtoList
                  delete res.repulseSuggestionDtoList
                  param.questionList.push(res)
                  arr.push(i)
                }
              })
              if (param.questionList.length < 1) {
                this.warning('请先选择关联问题、落实或审核数据')
                return
              }
              if (this.editModel === 'A') {
                let i = 0
                paramA.daiCheckQuestionPostDtoList = []
                arr.forEach((res) => {
                  paramA.keyId = param.keyId
                  paramA.traceUserId = param.traceUserId
                  if (paramA.daiCheckQuestionPostDtoList.length === 0 || this.dealForm.notHandleQuestionDtoList[res].qstDetailKeyId !== paramA.daiCheckQuestionPostDtoList[i - 1].qstDetailKeyId) {
                    paramA.daiCheckQuestionPostDtoList.push(this.dealForm.notHandleQuestionDtoList[res])
                    param.questionList[i].keyId = paramA.daiCheckQuestionPostDtoList[i].handleInfoKeyId
                    paramA.daiCheckQuestionPostDtoList[i].checkButtonPostDtoList = []
                    paramA.daiCheckQuestionPostDtoList[i].keyId = paramA.daiCheckQuestionPostDtoList[i].qstDetailKeyId
                    paramA.daiCheckQuestionPostDtoList[i].checkButtonPostDtoList.push(param.questionList[i])
                    paramA.daiCheckQuestionPostDtoList[i].relationQuestionType = paramA.daiCheckQuestionPostDtoList[i].checkButtonPostDtoList[0].relationQuestionType
                    paramA.daiCheckQuestionPostDtoList[i].relationQustionNo = paramA.daiCheckQuestionPostDtoList[i].checkButtonPostDtoList[0].relationQustionNo
                    i++
                  } else {
                    param.questionList[i].keyId = this.dealForm.notHandleQuestionDtoList[res].handleInfoKeyId
                    paramA.daiCheckQuestionPostDtoList[i - 1].checkButtonPostDtoList.push(param.questionList[i])
                  }
                })
                param = paramA
              }
            } else {
              Object.assign(params, { 'chargebackRiskFlag': this.dealForm.notImplementAssetInfoDto.chargebackRiskFlag })
              Object.assign(params, { 'traceUserId': this.dealForm.traceUserId })
              Object.assign(params, { 'keyId': this.dealForm.keyId })
              params.daiImplQuestionPostDtoList = []
              params.daiCheckQuestionPostDtoList = []
              params.relationHandlingQuestionPostDtoList = []
              // 待落实
              this.dealForm.notImplementAssetInfoDto.questionList.forEach(res => {
                let arr = []
                if (res.replyRelationPostDtoList && res.replyRelationPostDtoList.length > 0) {
                  res.replyRelationPostDtoList.forEach(resq => {
                    if (resq.practicableSuggestion !== '' && resq.supplementNoFile !== '') {
                      let arrfile = []
                      resq.uploadFilePostDtoList.forEach(resf => {
                        if (resf.fileId !== '') {
                          arrfile.push(resf)
                        }
                      })
                      arr.push(resq)
                    }
                  })
                  res.replyRelationPostDtoList = arr
                }
                if (res.replyOutPostDto && res.replyOutPostDto.replyLawContent !== '') {
                  let reparrfile = []
                  res.replyOutPostDto.uploadFilePostDtoList.forEach(resf => {
                    if (resf.fileId !== '') {
                      reparrfile.push(resf)
                    }
                  })
                  res.replyOutPostDto.uploadFilePostDtoList = reparrfile
                }
              })
              this.dealForm.notImplementAssetInfoDto.questionList.forEach(res => {
                if ((res.practicableResult === '1' && res.replyOutPostDto.replyLawContent !== '' && res.relationQustionFlag === '1') ||
                (res.practicableResult === '2' && res.replyRelationPostDtoList.length > 0 && res.relationQustionFlag === '1') ||
                  (res.relationQuestionType && res.relationQustionNo && res.relationQustionNo !== '' && res.relationQustionFlag === '2') ||
                  (res.relationHandlingDtoList && res.relationHandlingDtoList.length > 0 && (res.relationHandlingDtoList.filter(resf => resf.relationFeedbackQustionNoFlag === '1').length !== 0 || res.relationHandlingDtoList.filter(resf => resf.status === '已审核').length !== 0))) {
                  if (res.relationHandlingDtoList && res.relationHandlingDtoList.length > 0) {
                    res.relationHandlingTaskDto = {}
                    res.relationHandlingTaskDto.questionKeyId = res.relationHandlingDtoList[0].questionKeyId
                    res.relationHandlingTaskDto.relationHandlingDetailTaskDtoList = res.relationHandlingDtoList
                    res.relationHandlingTaskDto.relationHandlingDetailTaskDtoList.forEach(qres => { qres.keyId = qres.relationKeyId })
                  }
                  delete res.historyDealingsSuggestionDtoList
                  delete res.repulseSuggestionDtoList
                  params.daiImplQuestionPostDtoList.push(res)
                }
              })
              // 待处理
              this.dealForm.notHandleQuestionDtoList.forEach(res => {
                let arr = []
                if (res.checkButtonPostDtoList && res.checkButtonPostDtoList[0].replyRelationPostDtoList && res.checkButtonPostDtoList[0].replyRelationPostDtoList.length > 0) {
                  res.checkButtonPostDtoList[0].replyRelationPostDtoList.forEach(resq => {
                    if (resq.practicableSuggestion !== '' && resq.supplementNoFile !== '') {
                      let arrfile = []
                      resq.uploadFilePostDtoList.forEach(resf => {
                        if (resf.fileId !== '') {
                          arrfile.push(resf)
                        }
                      })
                      arr.push(resq)
                    }
                  })
                  res.checkButtonPostDtoList[0].replyRelationPostDtoList = arr
                }
                if (res.checkButtonPostDtoList && res.checkButtonPostDtoList[0].replyOutPostDto && res.checkButtonPostDtoList[0].replyOutPostDto.replyLawContent !== '') {
                  let reparrfile = []
                  res.checkButtonPostDtoList[0].replyOutPostDto.uploadFilePostDtoList.forEach(resf => {
                    if (resf.fileId !== '') {
                      reparrfile.push(resf)
                    }
                  })
                  res.checkButtonPostDtoList[0].replyOutPostDto.uploadFilePostDtoList = reparrfile
                }
              })
              let i = 0
              this.dealForm.notHandleQuestionDtoList.forEach(res => {
                if ((res.checkButtonPostDtoList && res.checkButtonPostDtoList[0].practicableResult === '1' && res.checkButtonPostDtoList[0].replyOutPostDto.replyLawContent !== '' && res.relationQustionFlag === '1') ||
                (res.checkButtonPostDtoList && res.checkButtonPostDtoList[0].practicableResult === '2' && res.checkButtonPostDtoList[0].replyRelationPostDtoList.length > 0 && res.relationQustionFlag === '1') ||
                  (res.relationQuestionType && res.relationQustionNo && res.relationQustionNo !== '' && res.relationQustionFlag === '2') || (res.relationDealStatus === '1' && res.status === '已终止')) {
                  if (params.daiCheckQuestionPostDtoList.length === 0 || res.qstDetailKeyId !== params.daiCheckQuestionPostDtoList[i - 1].qstDetailKeyId) {
                    res.keyId = res.qstDetailKeyId
                    res.checkButtonPostDtoList[0].keyId = res.handleInfoKeyId
                    params.daiCheckQuestionPostDtoList.push(res)
                    i++
                  } else {
                    res.checkButtonPostDtoList[0].keyId = res.handleInfoKeyId
                    params.daiCheckQuestionPostDtoList[i - 1].checkButtonPostDtoList.push(res.checkButtonPostDtoList[0])
                  }
                }
              })
              // 相关方处理
              this.dealForm.relationHandlingQuestionDtoList.forEach(res => {
                let arr = []
                if (res.replyRelationPostDtoList && res.replyRelationPostDtoList.length > 0) {
                  res.replyRelationPostDtoList.forEach(resq => {
                    if (resq.practicableSuggestion !== '' && resq.supplementNoFile !== '') {
                      let arrfile = []
                      resq.uploadFilePostDtoList.forEach(resf => {
                        if (resf.fileId !== '') {
                          arrfile.push(resf)
                        }
                      })
                      arr.push(resq)
                    }
                  })
                  res.replyRelationPostDtoList = arr
                }
                if (res.replyOutPostDto && res.replyOutPostDto.replyLawContent !== '') {
                  let reparrfile = []
                  res.replyOutPostDto.uploadFilePostDtoList.forEach(resf => {
                    if (resf.fileId !== '') {
                      reparrfile.push(resf)
                    }
                  })
                  res.replyOutPostDto.uploadFilePostDtoList = reparrfile
                }
              })
              this.dealForm.relationHandlingQuestionDtoList.forEach(res => {
                if ((res.replyOutPostDto && res.practicableResult === '1' && res.replyOutPostDto.replyLawContent !== '' && res.relationQustionFlag === '1') ||
                (res.replyRelationPostDtoList && res.practicableResult === '2' && res.replyRelationPostDtoList.length > 0 && res.relationQustionFlag === '1') ||
                  (res.relationQuestionType && res.relationQustionNo && res.relationQustionNo !== '' && res.relationQustionFlag === '2')) {
                  res.keyId = res.qstDetailKeyId
                  res.keyIds = []
                  let check = []
                  if (res.relationQustionFlag === '2') {
                    check = this.dealForm.relationHandlingQuestionDtoList.filter(resq => resq.qstDetailKeyId === res.qstDetailKeyId)
                  } else {
                    check = this.dealForm.relationHandlingQuestionDtoList.filter(resq => resq.qstDetailKeyId === res.qstDetailKeyId).filter(rest => rest.checkboxFlag)
                  }
                  if (check.length > 0) {
                    check.forEach(resck => {
                      if (res.relationQustionFlag === '2') {
                        res.keyIds.push(resck.handleInfoKeyId)
                      } else {
                        if (resck.fdcheckbox && resck.fdcheckbox === '1') {
                          res.keyIds.push(resck.handleInfoKeyId)
                        }
                      }
                    })
                    if (res.keyIds.length > 0) {
                      params.relationHandlingQuestionPostDtoList.push(res)
                    }
                  } else {
                    res.keyIds.push(res.handleInfoKeyId)
                    params.relationHandlingQuestionPostDtoList.push(res)
                  }
                }
              })
              if (params.daiImplQuestionPostDtoList.length === 0 && params.daiCheckQuestionPostDtoList.length === 0 && params.relationHandlingQuestionPostDtoList.length === 0) {
                this.warning('请确认数据是否填写正确')
                return
              }
              param = params
            }
            let fixChange = this.fix
            this.assetpkgmgrFullScreenLoading()
            this.effApi.putDefaultUpdate(param).then(res => {
              this.assetpkgmgrFullScreenLoading().close()
              if (res.data) {
                this.success('更新成功')
                callback && callback(res.data)
                if (fixChange === this.batchkeyIdArray.length || val === 'S') {
                  this.dialogVisible = false
                  this.$emit('close', true)
                }
              } else {
                this.error('更新失败')
              }
            }).catch(res => {
              this.assetpkgmgrFullScreenLoading().close()
            })
          }
        })
      }
    },
    // 下一条
    next (val) {
      this.save(val, res => {
        if (res) {
          this.dealForm = {
            notHandleQuestionDtoList: [],
            checked: ['1'],
            replyOutPostDto: {
              replyLawContent: '',
              uploadFilePostDtoList: []
            },
            replyRelationPostDtoList: [],
            notImplementAssetInfoDto: {
              assetCode: '',
              projectCompanyName: '',
              suppliersName: '',
              questionList: []
            }
          }
          if (this.fix < this.batchkeyIdArray.length) {
            this.fix++
            this.dataFullFit()
            document.getElementsByClassName('el-dialog__body')[0].scrollTo(0, 0)
          }
        }
      })
    },
    // 进入该画面的tab切换
    tabNumChange (val) {
      if (val === '2') {
        // setTimeout(() => {
        this.$nextTick(() => {
          this.batchTabNum = val
        })

        // }, 30)
      } else {
        this.batchTabNum = val
      }
    },
    // 获取孙组件状态
    getValue (e) {
    }
  }
}
</script>

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