<!--落实意见复核/反馈意见复核-->
<template>
  <div>
    <dialog-edit :visible.sync="dialogVisible"
                 :autoSave="false"
                 :autoClose="false"
                 :editModel="editModel"
                 :form="submitForm"
                 :footerBtnShow="false"
                 :title="dialogTitle">
        <el-tabs v-model="activeName" type="card" class="myeltab" @tab-click="tabClick">
            <el-tab-pane v-for="item in tabList" :key="item.index" :name="item.index">
                <span slot="label">{{item.label}}</span>
            </el-tab-pane>
        </el-tabs>
        <!-- <keep-alive> -->
        <div style="margin-top:20px">
            <search-form :formValue.sync="queryParas"
                         searchPerms="search"
                         resetPerms="reset"
                         @clearParam="clearParam"
                         :isShowSearchBtn="false"
                         @handleFilter="handleFilter"
                         :isShowFoldBtn="false"
                         :componentList="slide()">
                         <template slot="beforeBtnArea">
                           <auth-button size="medium" type="primary" label="查询" :menuCode="menuCode" icon="iconfont iconycchaxun" style="'margin-right: -4px" @click="handleFilter" :loading="loading"></auth-button>
                         </template>
            </search-form>
        </div>
        <!-- <keep-alive> -->
            <div v-for="item in dataTables" :key="item.keyId">
              <deal-audit-review-content-sub :title="'第'+item.feedbackFrequency+'批  付款确认书编号:'+item.assetCode"
                                            :tableData="item.qstDetailDTOList"
                                            :formValue="item"
                                            :reviewType="reviewType"
                                            :queryParas="queryParas"
                                            :form="projectInfoChange"
                                            @showHistoryDialog="showHistoryDialog"
                                            @showMarkDialog="showMarkDialog"
                                            @showPopDialog="showPopDialog"></deal-audit-review-content-sub>

            </div>
        <!-- </keep-alive> -->
        <template slot="footer">
          <authButton :label="$t('common.save')" type="primary" size="medium" @click="onSaved" ></authButton>
          <authButton :label="$t('common.submit')" type="primary" size="medium" @click="onSubmit"></authButton>
        </template>
    </dialog-edit>
    <deal-audit-review-his-pop :visible.sync="historyVisible" v-if="historyVisible" :editModel="newEditModel" :form="hisForm"></deal-audit-review-his-pop>
    <asset-flag-mgr-pop :visible.sync="flagVisible" v-if="flagVisible" :editModel="newEditModel" :form="flagForm"></asset-flag-mgr-pop>
  </div>
</template>
<script>
import { DialogEdit, searchForm, DataTable, authButton, SelectDictionary } from 'newepoch-components'
import BasePage from '@/pages/baseEditPage'
import dealAuditReviewContentSub from '@/pages//assetoutfeedback/coordManage/dealAuditReviewContentSub'
import dealAuditReviewHisPop from '@/pages/assetoutfeedback/coordManage/dealAuditReviewHisPop'
import assetFlagMgrPop from '@/pages/assetoutfeedback/coordManage/assetFlagMgrPop'
import fileSelectList from '@/components/element/assetoutfeedback/fileSelectList'
import traceUserSelectList from '@/components/element/assetoutfeedback/traceUserSelectList'
import feedBackFreqSelectList from '@/components/element/assetoutfeedback/feedBackFreqSelectList'
import coordManageApi from '@/api/assetoutfeedback/coordManage/coordManageApi'
import * as format from '@/filters/index'
export default {
  name: 'dealAuditReviewPop',
  extends: new BasePage(),
  components: {
    DialogEdit,
    searchForm,
    DataTable,
    authButton,
    SelectDictionary,
    dealAuditReviewContentSub,
    dealAuditReviewHisPop,
    assetFlagMgrPop,
    fileSelectList,
    traceUserSelectList,
    feedBackFreqSelectList
  },
  props: {
    editModel: {
      type: [String],
      default () {
        return 'V'
      }
    },
    projectInfoChange: {
      type: [Object],
      default () {
        return {}
      }
    },
    dialogTitle: {
      type: [String],
      default () {
        return ''
      }
    },
    form: {
      type: [Object],
      default () {
        return {}
      }
    },
    reviewType: {
      type: [String],
      default () {
        return ''
      }
    },
    stampType: {
      type: [String],
      default () {
        return ''
      }
    }
  },
  data () {
    return {
      activeName: '0', // 选定tab
      historyVisible: false, // 履历弹窗
      flagVisible: false, // 资产标志管理弹窗
      newEditModel: '',
      auditFiletype: '',
      queryParas: {},
      flagForm: {},
      hisForm: {},
      loading: false,
      flag: 0,
      tabList: [
        {
          index: '0',
          label: this.$t('coordManageMain.sampleFile'),
          component: 'el-input'
        },
        {
          index: '1',
          label: this.$t('coordManageMain.authFile'),
          component: 'el-input'
        },
        {
          index: '2',
          label: this.$t('coordManageMain.otherFile'),
          component: 'el-input'
        }
      ],
      componentList: [
        {
          // 项目
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.project,
          disabled: true,
          value: 'projectName',
          labelWidth: '100px',
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 期数
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.periods,
          disabled: true,
          value: 'periods',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          labelWidth: '100px',
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 批次
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.feedbackFrequency,
          disabled: false,
          value: 'feedbackFrequency',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          labelWidth: '100px',
          clearable: true,
          queryName: ['projectId', 'periods', 'auditFileType'],
          queryValue: ['projectId', 'periods', 'auditFileType'],
          componentName: feedBackFreqSelectList
        },
        {
          // 合规人员
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.traceUser,
          disabled: false,
          value: 'traceUserId',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          labelWidth: '100px',
          clearable: true,
          queryName: ['projectId', 'periods'],
          queryValue: ['projectId', 'periods'],
          componentName: traceUserSelectList
        },
        {
          // 来源
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.resource,
          disabled: false,
          value: 'feedbackResource',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          labelWidth: '100px',
          clearable: true,
          componentName: SelectDictionary,
          dictTypeCode: 'AUDIT_OUT_FEEDBACK_RESOURCE'
        },
        {
          // 文件类型
          label: this.$i18n.messages[this.$i18n.locale].coordManageMain.fileType,
          disabled: false,
          value: 'auditFileType',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          labelWidth: '100px',
          attrs: { 'fileQueryType': '2' },
          clearable: true,
          exclude: this.fileParas,
          componentName: fileSelectList
        }
      ],
      submitForm: {},
      dataTables: [],
      submitDatas: [], // 保存
      fileParas: {}
    }
  },
  mounted () {
    this.getFileParas()
    this.$set(this.queryParas, 'auditFileType', '1001')
    this.loadData()
  },
  computed: {
    reviewListApi () {
      return coordManageApi.reviewList
    },
    reviewUpdateApi () {
      return coordManageApi.reviewUpdate
    },
    tpUpdateApi () {
      return coordManageApi.tpUpdate
    },
    xgfApi () {
      return coordManageApi.relatedPerson
    },
    dzApi () {
      return coordManageApi.dzName
    }
  },
  methods: {
    handleFilter () {
      for (const key in this.queryParas) {
        if (this.queryParas[key] === '') {
          delete this.queryParas[key]
        }
      }
      this.loadData()
    },
    // 根据电子章分类获取数据
    loadfileType () {
      if (this.activeName === '0') {
        this.$set(this.queryParas, 'auditFileType', '1001')
      }
      if (this.activeName === '1' && this.stampType === '1') { // 电子章只有一种确权文件
        this.$set(this.queryParas, 'auditFileType', '2001')
      }
    },
    clearParam () {
      this.queryParas = {
        projectId: this.projectInfoChange.projectId,
        projectName: this.projectInfoChange.projectName,
        periods: this.projectInfoChange.periods
      }
      if (this.activeName === '0') { // 抽样文件不清空文件类型
        this.queryParas.auditFileType = '1001'
      } else if (this.activeName === '1' && this.stampType === '1') { // 电子章确权文件不清空文件类型
        this.queryParas.auditFileType = '2001'
      }
    },
    // 切换tab
    tabClick () {
      this.queryParas.auditFileType = ''
      this.loadfileType()
      if (!this.UtilJs.isEmpty(this.queryParas.auditFileType)) {
        this.loadData()
      } else {
        this.dataTables = []
      }
    },
    slide () {
      let length = this.componentList.length
      if (this.activeName === '0') {
        return this.componentList.slice(0, length - 1)
      } else if (this.activeName === '2') {
        this.$set(this.componentList[length - 1].attrs, 'fileQueryType', '3')
        return this.componentList
      } else if (this.activeName === '1') {
        if (this.stampType === '1') { // 电子章时不显示文件类型
          return this.componentList.slice(0, length - 1)
        } else if (this.stampType === '2') {
          this.$set(this.componentList[length - 1].attrs, 'fileQueryType', '2')
          this.$set(this.componentList[length - 1].attrs, 'stampWay', '2')
          return this.componentList
        } else { // 没有获取到盖章方式
          this.warning('没有获取到盖章方式')
          return this.componentList.slice(0, length - 1)
        }
      }
    },
    // 获取相关方负责人
    getXgfName (list, item) {
      item.dzName = []
      item.xgfName = {}
      this.xgfApi.getXgfInfo({ assetInfoId: '2006041921201460001' || list.assetInfoId }).then(res => {
        if (res.success && res.data.length > 0) {
          item.xgfName = res.data[0]
        }
      })
      this.dzApi.getList({ productId: this.projectInfoChange.projectId, specialPlanPeriodsId: this.projectInfoChange.periods }).then(res => {
        if (res.success && res.data && res.data.coordinators) {
          if (res.data.coordinators.length > 0) {
            item.dzName = res.data.coordinators.filter(it => {
              if (it.coordinatorType === '4') {
                return true
              }
            })
          }
        }
      })
    },
    // 页面数据加载
    loadData () {
      let factorReviewConditionDTO = {
        reviewType: this.reviewType
        // feedbackResource: this.projectInfo.feedbackResource
      }
      Object.assign(factorReviewConditionDTO, this.queryParas)
      if (factorReviewConditionDTO.auditFileType && factorReviewConditionDTO.auditFileType !== '') {
        this.loading = true
        this.reviewListApi.getList(factorReviewConditionDTO).then(res => {
          this.loading = false
          if (res.success) {
            res.data.forEach(list => {
              list.accountsReceivable = format.thousandFilter(list.accountsReceivable, 2) // 金额格式化
              if (list.qstDetailDTOList && list.qstDetailDTOList.length > 0) {
                list.qstDetailDTOList.forEach(item => {
                  let effectReview = {}
                  let supplementNoFile = {}
                  let traceAttach0 = []
                  item.oldInfo = {// 原始复核信息
                    backTraceReason: item.coordReviewDTO.backTraceReason,
                    effectReview: {},
                    relatedType: [],
                    supplementNoFile: {},
                    traceAttach0: [],
                    traceAttach1: [],
                    traceAttach2: [],
                    traceAttach3: [],
                    traceAttach4: [],
                    traceAttach5: [],
                    relationChargeUser1: {}, // 相关方负责人
                    relationChargeUser2: {},
                    relationChargeUser4: {},
                    relationChargeUser5: {}
                  }
                  item.tempInfo = {// 暂存复核信息
                    backTraceReason: item.coordReviewDTO.backTraceReason,
                    effectReview: {},
                    relatedType: [],
                    supplementNoFile: {},
                    traceAttach0: [],
                    traceAttach1: [],
                    traceAttach2: [],
                    traceAttach3: [],
                    traceAttach4: [],
                    traceAttach5: [],
                    relationChargeUser1: {}, // 相关方负责人
                    relationChargeUser2: {},
                    relationChargeUser4: {},
                    relationChargeUser5: {}
                  }
                  this.getXgfName(list, item.tempInfo)
                  // 暂存
                  if (item.relationHandleTempDTO) { // 相关方
                    item.relationHandleTempDTO.forEach(info => {
                      item.tempInfo.relatedType.push(info.relationType) // 相关方checkbox
                      item.tempInfo.effectReview = this.getEffectReview(info.relationType, effectReview, info.practicableSuggestion)// 合规落实意见
                      supplementNoFile = this.getSupplementNoFile(info.relationType, supplementNoFile, info.supplementNoFile)// 未补回资料
                      if (info.relationType !== '3') { // 相关方负责人信息
                        item.tempInfo['relationChargeUser' + info.relationType] = { relationChargeUserId: info.relationChargeUserId, relationChargeUserName: info.relationChargeUserName }
                      }
                      item.oldInfo['traceAttach' + info.relationType] = []
                      info.explainFileInfos.forEach(fileItem => {
                        item.tempInfo['traceAttach' + info.relationType].push({ fileId: fileItem.instructionFileId, fileName: fileItem.instructionFileName })
                      })
                    })
                  } else if (item.replyContentTempDTO) { // 提交律所
                    item.tempInfo.relatedType.push('0')
                    item.tempInfo.effectReview['practicableSuggestion0'] = item.replyContentTempDTO.replyLawContent // 合规落实意见
                    if (item.replyContentTempDTO.replyFileInfos.length > 0) {
                      item.replyContentTempDTO.replyFileInfos.forEach(fileItem => {
                        traceAttach0.push({ fileId: fileItem.fileOssid, fileName: fileItem.relationType })
                      })
                    }
                  }
                  item.tempInfo.supplementNoFile = supplementNoFile
                  item.tempInfo.traceAttach0 = traceAttach0
                  item.tempInfo.uploadTraceAttach0 = []
                  item.tempInfo.uploadTraceAttach1 = []
                  item.tempInfo.uploadTraceAttach2 = []
                  item.tempInfo.uploadTraceAttach3 = []
                  item.tempInfo.uploadTraceAttach4 = []
                  item.tempInfo.uploadTraceAttach5 = []

                  if (item.relationHandleDTO || item.replyContentDTO) { // 非暂存
                    if (item.relationHandleDTO) { // 相关方
                      item.relationHandleDTO.forEach(info => {
                        item.oldInfo.relatedType.push(info.relationType) // 相关方checkbox
                        item.oldInfo.effectReview = this.getEffectReview(info.relationType, effectReview, info.practicableSuggestion)// 合规落实意见
                        supplementNoFile = this.getSupplementNoFile(info.relationType, supplementNoFile, info.supplementNoFile)// 未补回资料
                        if (info.relationType !== '3') { // 相关方负责人信息
                          item.oldInfo['relationChargeUser' + info.relationType] = { relationChargeUserId: info.relationChargeUserId, relationChargeUserName: info.relationChargeUserName }
                        }
                        item.oldInfo['traceAttach' + info.relationType] = []
                        info.explainFileInfos.forEach(fileItem => {
                          item.oldInfo['traceAttach' + info.relationType].push({ fileId: fileItem.instructionFileId, fileName: fileItem.instructionFileName })
                        })
                      })
                    } else if (item.replyContentDTO) { // 提交律所
                      item.oldInfo.relatedType.push('0')
                      item.oldInfo.effectReview['practicableSuggestion0'] = item.replyContentDTO.replyLawContent // 合规落实意见
                      if (item.replyContentDTO.replyFileInfos.length > 0) {
                        item.replyContentDTO.replyFileInfos.forEach(fileItem => {
                          traceAttach0.push({ fileId: fileItem.fileOssid, fileName: fileItem.relationType })
                        })
                      }
                    }
                    item.oldInfo.supplementNoFile = supplementNoFile
                    item.oldInfo.traceAttach0 = traceAttach0
                    item.oldInfo.uploadTraceAttach0 = []
                    item.oldInfo.uploadTraceAttach1 = []
                    item.oldInfo.uploadTraceAttach2 = []
                    item.oldInfo.uploadTraceAttach3 = []
                    item.oldInfo.uploadTraceAttach4 = []
                    item.oldInfo.uploadTraceAttach5 = []
                  }
                })
              }
            })
            this.dataTables = res.data
          }
        }).catch(res => {
          this.loading = false
        })
      } else {
        this.warning('请选择文件类型')
      }
    },
    getSupplementNoFile (type, data, val) {
      if (type === '1') {
        data['supplementNoFile1'] = val
      } else if (type === '2') {
        data['supplementNoFile2'] = val
      } else if (type === '3') {
        data['supplementNoFile3'] = val
      } else if (type === '4') {
        data['supplementNoFile4'] = val
      } else if (type === '5') {
        data['supplementNoFile5'] = val
      }
      return data
    },
    getEffectReview (type, data, val) {
      if (type === '1') {
        data['practicableSuggestion1'] = val
      } else if (type === '2') {
        data['practicableSuggestion2'] = val
      } else if (type === '3') {
        data['practicableSuggestion3'] = val
      } else if (type === '4') {
        data['practicableSuggestion4'] = val
      } else if (type === '5') {
        data['practicableSuggestion5'] = val
      }
      return data
    },
    getFileParas () {
      let auditFileType = ''
      if (this.activeName === '0') {
        auditFileType = '1'
      } else if (this.activeName === '1') {
        auditFileType = '2'
      } else {
        auditFileType = '3'
      }
      this.queryParas = this.UtilJs.cloneDeep(this.projectInfoChange)
      this.$set(this.queryParas, 'feedbackResource', this.form.feedbackResource)
      this.fileParas = { auditFileType: auditFileType }
      Object.assign(this.fileParas, this.projectInfoChange)
    },
    // 保存的数据
    saveData (val) {
      let subData = []
      let flag = true
      val.forEach((item) => {
        let data = []
        let modifyPracticableResult = ''
        let relationHandleDTO = [] // 提交相关方
        let replyContentDTO = [] // 提交律所
        let backTraceReason = ''
        if (item.coordReviewDTO.reviewResult === '3') { // 直接修改
          if (!this.UtilJs.isEmpty(item.tempInfo.backTraceReason)) {
            backTraceReason = item.tempInfo.backTraceReason
          } else {
            flag = false
          }
          if (item.tempInfo.relatedType.includes('0')) { // 提交律所
            modifyPracticableResult = '1'
            replyContentDTO = {
              replyLawContent: item.tempInfo.effectReview.practicableSuggestion0,
              replyFileInfos: item.tempInfo.uploadTraceAttach0 ? item.tempInfo.uploadTraceAttach0 : []
            }
          } else { // 提交相关方
            modifyPracticableResult = '2'
            item.tempInfo.relatedType.forEach(value => {
              let val = []
              val = {
                practicableSuggestion: item.tempInfo.effectReview['practicableSuggestion' + value],
                relationType: value,
                supplementNoFile: item.tempInfo.supplementNoFile['supplementNoFile' + value],
                explainFileInfos: item.tempInfo['uploadTraceAttach' + value] ? item.tempInfo['uploadTraceAttach' + value] : []
              }
              let xgfUser = {}
              if (value === '1' && item.tempInfo.xgfName) {
                xgfUser = {
                  relationChargeUserId: item.tempInfo.xgfName.customerAccountId,
                  relationChargeUserName: item.tempInfo.xgfName.customerAccountName
                }
              }
              if (value === '2' && item.tempInfo.xgfName) {
                xgfUser = {
                  relationChargeUserId: item.tempInfo.xgfName.coreAreaBussUserId,
                  relationChargeUserName: item.tempInfo.xgfName.coreAreaBussUserName
                }
              }
              if (value === '4' && item.tempInfo.dzName && item.tempInfo.dzName.length > 0) {
                xgfUser = {
                  relationChargeUserId: item.tempInfo.dzName[0].areaCoordinatorId,
                  relationChargeUserName: item.tempInfo.dzName[0].areaCoordinatorName
                }
              }
              if (value === '5' && item.tempInfo.xgfName) {
                xgfUser = {
                  relationChargeUserId: item.tempInfo.xgfName.coreAreaAttache,
                  relationChargeUserName: item.tempInfo.xgfName.coreAreaAttacheName
                }
              }
              Object.assign(val, xgfUser)
              relationHandleDTO.push(val)
            })
          }
        } else if (item.coordReviewDTO.reviewResult === '1' || item.coordReviewDTO.reviewResult === '2') { // 赞成/退回跟进人
          if (item.relationHandleDTO) {
            relationHandleDTO = item.relationHandleDTO
          }
          if (item.replyContentDTO) {
            replyContentDTO = item.replyContentDTO
          }
          if (item.coordReviewDTO.reviewResult === '2' && this.UtilJs.isEmpty(item.oldInfo.backTraceReason)) { // 退回跟进人时，退回原因必填
            flag = false
          } else if (item.coordReviewDTO.reviewResult === '2' && !this.UtilJs.isEmpty(item.oldInfo.backTraceReason)) {
            backTraceReason = item.oldInfo.backTraceReason
            flag = true
          } else {
            // backTraceReason = item.coordReviewDTO.backTraceReason1
            backTraceReason = ''
            flag = true
          }
        } else {
          item.coordReviewDTO.reviewResult = ''
        }
        if (flag) {
          data = {
            backTraceReason: backTraceReason,
            feedbackKeyId: item.coordReviewDTO.feedbackKeyId,
            keyId: item.coordReviewDTO.keyId,
            modifyPracticableResult: modifyPracticableResult,
            modifyTime: item.modifyTime,
            practicableResult: item.coordReviewDTO.practicableResult,
            relationHandleDTO: relationHandleDTO,
            replyContentDTO: replyContentDTO,
            resultHistoryNo: item.coordReviewDTO.resultHistoryNo,
            reviewFlag: item.coordReviewDTO.reviewFlag,
            reviewResult: item.coordReviewDTO.reviewResult,
            reviewType: this.reviewType,
            targetHistoryNo: item.coordReviewDTO.targetHistoryNo
          }
          subData.push(data)
        }
      })
      if (flag) {
        return subData
      } else {
        return false
      }
    },
    // 提交事件
    onSubmit () {
      if (this.UtilJs.isEmpty(this.dataTables) || this.dataTables.length === 0) {
        this.warning(this.$t('common.noDataError'))
        return
      }
      let data = []
      let flag = true
      let saveList = this.dataTables.map(item => {
        return item.qstDetailDTOList
      })
      saveList.forEach(item => {
        if (!this.saveData(item)) {
          flag = false
          this.warning('退回跟进人时，必须填写原因')
        } else {
          data.push(this.saveData(item))
        }
      })

      if (!flag) {
        return false
      }
      let a = []
      data.forEach(item => {
        item.forEach(it => {
          a.push(it)
        })
      })
      let tempData = a.filter(it => {
        if (it.reviewResult !== '') {
          return it
        }
      })
      this.submitDatas = tempData
      if (this.submitDatas.length > 0) {
        for (let index in this.submitDatas) {
          let items = this.submitDatas[index]
          if (items.reviewResult === '3') {
            if (items.relationHandleDTO.length === 0 && items.replyContentDTO.replyFileInfos && this.UtilJs.isEmpty(items.replyContentDTO.replyLawContent)) {
              this.warning(this.$t('coordManageMain.practicablejudge'))
              return false
            }
            if (items.relationHandleDTO && items.relationHandleDTO.length > 0) {
              for (let i in items.relationHandleDTO) {
                let item = items.relationHandleDTO[i]
                if (this.UtilJs.isEmpty(item.practicableSuggestion)) {
                  this.warning(this.$t('coordManageMain.practicablejudge'))
                  return false
                }
                // else if (e.tempInfo.relatedType.length !== Object.keys(e.tempInfo.effectReview).length) {
                //   this.warning(this.$t('coordManageMain.practicablejudge'))
                //   return false
                // for (let index in e.tempInfo.effectReview) {
                //   console.log(e.tempInfo.effectReview)
                //   if (this.UtilJs.isEmpty(e.tempInfo.effectReview[index])) {
                //     this.warning(this.$t('coordManageMain.practicablejudge'))
                //     return false
                //   }
                // }
                // }
              }
            } else if (items.replyContentDTO.length === 0 && items.relationHandleDTO.length === 0) {
              this.warning(this.$t('coordManageMain.practicablechoice'))
              return
            }
          }
        }
        this.assetpkgmgrFullScreenLoading()
        this.reviewUpdateApi.defaultNewSave(this.submitDatas).then(res => {
          this.assetpkgmgrFullScreenLoading().close()
          if (res.success) {
            this.success(this.dialogTitle + this.$t('common.submittedSuccess'))
            this.$emit('createQust', true)
            this.dialogVisible = false
          } else {
            this.success(this.dialogTitle + this.$t('common.submitFail'))
          }
        }).catch(res => this.assetpkgmgrFullScreenLoading().close())
      } else {
        this.warning('没有要提交的数据')
      }
    },
    // 保存事件
    onSaved () {
      if (this.UtilJs.isEmpty(this.dataTables) || this.dataTables.length === 0) {
        this.warning(this.$t('common.noDataError'))
        return
      }
      let data = []
      let flag = true
      let saveList = this.dataTables.map(item => {
        return item.qstDetailDTOList
      })
      saveList.forEach(item => {
        if (!this.saveData(item)) {
          flag = false
          this.warning('退回跟进人时，必须填写原因')
        } else {
          data.push(this.saveData(item))
        }
      })
      if (!flag) {
        return false
      }
      let a = []
      data.forEach(item => {
        item.forEach(it => {
          a.push(it)
        })
      })
      let tempData = a.filter(it => {
        if (it.reviewResult !== '') {
          return it
        }
      })
      this.submitDatas = tempData
      if (this.submitDatas.length > 0) {
        this.assetpkgmgrFullScreenLoading()
        this.tpUpdateApi.putData(this.submitDatas).then(res => {
          this.assetpkgmgrFullScreenLoading().close()
          if (res.success) {
            this.success(this.dialogTitle + this.$t('common.saveSuccess'))
            this.$emit('createQust', true)
            this.dialogVisible = false
          } else {
            this.success(this.dialogTitle + this.$t('common.saveError'))
          }
        }).catch(res => this.assetpkgmgrFullScreenLoading().close())
      } else {
        this.warning('没有要保存的数据')
      }
    },
    // 履历弹窗
    showHistoryDialog (val) {
      this.newEditModel = 'V'
      this.hisForm = val
      this.historyVisible = true
    },
    // 资产标志管理弹窗
    showMarkDialog (val) {
      this.flagForm = {
        assetCode: val.assetCode,
        auditFileType: val.auditFileType,
        feedbackResource: this.queryParas.feedbackResource
      }
      this.newEditModel = 'E'
      this.flagVisible = true
    },
    showPopDialog (form, type) {
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
