<!-- 合规处理/落实外部机构反馈意见一览画面 -->
<template>
  <div class="effectDealFeedBackMain">
    <up-down-layout :handleFlag.sync="handleFlag">
    <search-form slot="query" :formValue.sync="queryParas" @handleFilter="filedshandleFilter" @clearParam="clearParam" :componentList="componentList" class="wbjgSearchFormCheckBox mainSearchForm">
      <template slot="beforeBtnArea">
        <!--长度占位-->
        <span class="spanWidth"></span>
        <!--显示分配数据checkbox-->
        <el-checkbox v-model="displayFlag" class="checkFlex"><span class="effectoutfontStyle">{{$t('effectDealFeedBackMain.showMeData')}}</span></el-checkbox>
        <div class="divFlex"></div>
      </template>
    </search-form>
    <template slot="table">
      <!--主tab-->
      <el-tabs type="card" class="myeltab" v-model="tabValue.feedbackResource" @tab-click="fatherTabClick()">
        <el-tab-pane v-for="itemParent in outEditPane" :key="itemParent.dictId" :label="itemParent.dictName" :name="itemParent.dictId">
          <span slot="label">{{itemParent.dictName}}<span class="iconfont iconyichangshujutiaozheng" style="color:#F9D108" v-show="showIcon(itemParent)"></span></span>
          <!--副tab-->
          <el-tabs type="card" class="panecoler" v-model="tabValue.auditFileType" @tab-click="sonTabClick(item)">
            <el-tab-pane v-for="item in inEditPane" :key="item.fileType" :label="item.fileName" :name="item.fileType">
              <span slot="label">{{item.fileName}}<span class="iconfont iconyichangshujutiaozheng" style="color:#F9D108" v-show="showIcon(item)"></span></span>
            </el-tab-pane>
          </el-tabs>
        </el-tab-pane>
      </el-tabs>
      <keep-alive>
        <data-table class="efffectdDealTable" :sourceData.sync="sourceData" :columns="columns" v-bind="elHeightObj" :queryParas.sync="queryParas" :api="pageApi" :loadCount="loadCount" :span-method="objectSpanMethod" @getTableData="getTableData" :row-style="rowStyle">
          <!-- 相关方预计补回时间 -->
          <template slot="estimateSupplementTime" slot-scope="scope">
            <span v-if="scope.data.row.relation.indexOf($t('expressDataList.business')) < 0">{{scope.data.row.estimateSupplementTime | timeFormat}}</span>
            <el-date-picker
              v-else
              :disabled="scope.data.row.ownFlag !== '1'"
              v-model="scope.data.row.estimateSupplementTime"
              type="date"
              value-format="timestamp"
              @change="dataChange(scope.data.row)">
            </el-date-picker>
          </template>
          <!-- 是否通用问题 -->
          <template slot="isCommonQustion" slot-scope="scope">
            <span>{{scope.data.row.isCommonQustion | format(scope.data.row.isCommonQustion)}}</span>
             <i v-if="scope.data.row.pentagramFlag === '1'" style="margin-left:10px;color: rgba(229, 28, 35, 1)" class="iconfont iconxing"></i>
          </template>
          <template slot="suppliersName" slot-scope="scope">
            <span-plus :index="scope.data.$index" :text="scope.data.row.suppliersName"></span-plus>
          </template>
          <template slot="projectCompanyName" slot-scope="scope">
            <span-plus :index="scope.data.$index" :text="scope.data.row.projectCompanyName"></span-plus>
          </template>
          <template slot="effectMemo" slot-scope="scope">
            <span-plus :index="scope.data.$index" :text="scope.data.row.effectMemo"></span-plus>
          </template>
          <template slot="supplementNoFile" slot-scope="scope">
            <span-plus :index="scope.data.$index" :text="scope.data.row.supplementNoFile"></span-plus>
          </template>
          <!-- 资产标识 -->
          <template slot="assetFlagDTO" slot-scope="scope">
            <div class="viewIcon">
              <i v-if="scope.data.row.canChargeback === '1'" class="iconfont iconketuidan ketuidan"></i>
              <i v-if="scope.data.row.chargebacked === '1'" class="iconfont iconyituidan yituidan"></i>
              <i v-if="scope.data.row.isUrgent === '1'" class="iconfont iconjidan jidan"></i>
              <i v-if="scope.data.row.chargebackRisk === '1'" class="iconfont iconfengxian fengxian1"></i>
              <i v-if="scope.data.row.pump === '1'" class="iconfont iconfengxian fengxian2"></i>
              <i v-if="scope.data.row.difficultAsset === '1'" class="iconfont iconyinan yinanyuqi"></i>
              <i v-if="scope.data.row.over === '1'" class="iconfont iconyuqi yinanyuqi"></i>
            </div>
          </template>
          <template slot="headButton">
              <div class="headdiv" align="right">
                <!--批量落实-->
                <auth-button type="primary" icon="iconfont iconlashi1" :size="'medium'" :label="$t('effectDealFeedBackMain.batchImplement')" @click="effecBatchClick"></auth-button>
                <!--批量审核-->
                <auth-button type="primary" icon="iconfont iconshenhe" :size="'medium'" :label="$t('effectDealFeedBackMain.batchAudit')" @click="auditBatchClick"></auth-button>
                <!--批量发补寄-->
                <auth-button type="primary" icon="iconfont iconfabujianniu" :size="'medium'" :label="$t('effectDealFeedBackMain.batchSup')" @click="sendBatchClick"></auth-button>
              </div>
              <!-- 图标 -->
              <div class="headdivIcon" align="right">
                <i class="iconfont iconketuidan ketuidan"><span class="fontClass">{{$t('effectDealFeedBackMain.returnableBill')}}</span></i>
                <i class="iconfont iconyituidan yituidan"><span class="fontClass">{{$t('effectDealFeedBackMain.returnedOrder')}}</span></i>
                <i class="iconfont iconjidan jidan"><span class="fontClass">{{$t('effectDealFeedBackMain.urgentSingleAssets')}}</span></i>
                <i class="iconfont iconfengxian fengxian1"><span class="fontClass">{{$t('effectDealFeedBackMain.riskOfCancellation')}}</span></i>
                <i class="iconfont iconfengxian fengxian2"><span class="fontClass">{{$t('effectDealFeedBackMain.supChargeback')}}</span></i>
                <i class="iconfont iconyinan yinanyuqi"><span class="fontClass">{{$t('effectDealFeedBackMain.difficultAssets')}}</span></i>
                <i class="iconfont iconyuqi yinanyuqi"><span class="fontClass">{{$t('effectDealFeedBackMain.overdue')}}</span></i>
              </div>
          </template>
          <!-- 操作 -->
          <el-table-column :label="$t('common.operate')" align="center" width="250px" fixed="right">
            <template slot-scope="scope">
              <!-- 查看履历 -->
              <auth-button size="small" class="iconCircle marginLeft" v-if="scope.row.ownFlag === '1'"
                          :title="$t('effectDealFeedBackMain.checkResume')" icon="iconfont iconview" @click="viewAntecedents(scope.row)"></auth-button>
              <!-- 编辑备注 -->
              <auth-button size="small" class="iconCircle marginLeft" v-if="scope.row.ownFlag === '1'"
                          :title="$t('effectDealFeedBackMain.editorialRemarks')" icon="iconfont iconbianji" @click="editRemarks(scope.row)"></auth-button>
              <!-- 落实 -->
              <!-- <auth-button size="small" class="iconCircle marginLeft" v-if="scope.row.ownFlag === '1' && (scope.row.questionStatus === '1' || scope.row.relationDealStatus === '1' || scope.row.relationDealStatus === '2')"
                          :title="$t('effectDealFeedBackMain.implement')" icon="iconfont iconlashi" @click="workable(scope.row)"></auth-button> -->
              <auth-button size="small" class="iconCircle marginLeft" v-if="scope.row.isSelected && scope.row.isSelected === true"
                          :title="$t('effectDealFeedBackMain.implement')" icon="iconfont iconlashi" @click="workable(scope.row)"></auth-button>
              <!-- 发补寄 -->
              <auth-button size="small" class="iconCircle marginLeft" v-if="scope.row.ownFlag === '1' && scope.row.feedbackStatus === '5' && scope.row.supplementFlag === '1' && scope.row.dealEndFlag === '1'"
                          :title="$t('effectDealFeedBackMain.sending')" icon="iconfont iconbuji" @click="sending(scope.row)"></auth-button>
              <!-- 可退单 -->
              <auth-button size="small" class="iconCircle marginLeft" v-if="scope.row.ownFlag === '1' && scope.row.selectedChargebackFlag && scope.row.selectedChargebackFlag !== '1'"
                          :title="$t('effectDealFeedBackMain.returnableBill')" icon="iconfont iconketuidan" @click="returnableBill(scope.row)"></auth-button>
              <!-- 处理结束 -->
              <auth-button size="small" class="iconCircle marginLeft pssc-css" v-if="scope.row.ownFlag === '1' && scope.row.feedbackStatus === '5' && scope.row.dealEndFlag === '1'"
                          :title="$t('effectDealFeedBackMain.endProcessing')" icon="iconfont iconjieshu1" @click="endProcessing(scope.row)"></auth-button>
            </template>
          </el-table-column>
        </data-table>
      </keep-alive>
    </template>
    </up-down-layout>
    <!-- 批量发补寄 -->
    <supple-doc-batch-pop v-if="suppleDocVisible" :visible.sync="suppleDocVisible" :form="form" :editModel="editModel" :keyIdArray="keyIdArray"></supple-doc-batch-pop>
    <!-- 批量落实/审核 -->
    <effect-batch-pop v-if="effectBatchVisible" :visible.sync="effectBatchVisible" :editModel="editModel" :form="queryParas" :popTitle="title" :keyIdArray="keyIdArray" :effApi="effApi" @close="close" :queryParamBatch="queryParamBatch"></effect-batch-pop>
    <!-- 查看履历 -->
    <supple-doc-his-pop v-if="suppleDocHisVisible" :visible.sync="suppleDocHisVisible" :form="form"></supple-doc-his-pop>
    <!-- 编辑备注 -->
    <edit-memo v-if="editMemoVisible" :visible.sync="editMemoVisible" :form="form" @close="close"></edit-memo>
  </div>
</template>
<script>
import * as format from '@/filters/index'
import componentsApi from '@/api/assetoutfeedback/componentsApi'
import effectDealFeedBackApi from '@/api/assetoutfeedback/effectDealFeedBack/effectDealFeedBackApi'
import editMemo from '@/pages/assetoutfeedback/effectDealFeedBack/editMemo'
import effectBatchPop from '@/pages/assetoutfeedback/effectDealFeedBack/effectBatchPop'
import suppleDocHisPop from '@/pages/assetoutfeedback/effectDealFeedBack/suppleDocHisPop'
import suppleDocBatchPop from '@/pages/assetoutfeedback/effectDealFeedBack/suppleDocBatchPop'
import issueInput from '@/components/element/assetaudit/issueInput'
import absFileSelectList from '@/components/element/assetoutfeedback/absFileSelectList'
import { searchForm, DataTable, upDownLayout, SelectDictionary, authButton, SpanPlus } from 'newepoch-components'
import BasePage from '@/pages/basePage'
import mixin from '@/pages/mixin'
import { mapGetters } from 'vuex'
export default {
  name: 'nameindex',
  extends: new BasePage(),
  mixins: [mixin],
  components: { issueInput, DataTable, searchForm, upDownLayout, SelectDictionary, authButton, effectBatchPop, suppleDocBatchPop, suppleDocHisPop, editMemo, SpanPlus },
  computed: {
    dictApi () {
      return effectDealFeedBackApi.dictList
    },
    pageApi () {
      return effectDealFeedBackApi.getDealPage
    },
    // 批量落实接口
    batchImApi () {
      return effectDealFeedBackApi.getBatchInfo
    },
    // 落实接口
    SingleImApi () {
      return effectDealFeedBackApi.getSingleInfo
    },
    // 批量审核接口
    dealApi () {
      return effectDealFeedBackApi.getDealInfo
    },
    // 履历接口
    reimApi () {
      return effectDealFeedBackApi.getReimInfo
    },
    // 编辑备注
    memoApi () {
      return effectDealFeedBackApi.getMemoInfo
    },
    // 发补寄
    supBApi () {
      return effectDealFeedBackApi.getSupplementBatch
    },
    // 获取盖章方式
    stampApi () {
      return effectDealFeedBackApi.getInfoStamp
    },
    // 可退单
    backApi () {
      return effectDealFeedBackApi.putReBackData
    },
    api () {
      return {}
    },
    fileTypeApi () {
      return componentsApi.fileList
    },
    // 用户信息
    ...mapGetters(['userId']),
    outEditPane () {
      let options = this.$store.state.sys.dictionarys.filter(function (dict) {
        return dict.dictTypeCode === 'AUDIT_OUT_FEEDBACK_RESOURCE'
      })
      return options
    }
  },
  watch: {
    outEditPane () {
      // this.elOtherHeight = 150
      this.$nextTick(function () {
        this.initStyle()
      })
    }
  },
  data () {
    let $this = this
    return {
      inEditPane: [],
      effApi: {},
      keyIdArray: [],
      title: '',
      queryParamBatch: {},
      arrayList: [],
      elOtherHeight: 100,
      displayFlag: true,
      editMemoVisible: false,
      suppleDocHisVisible: false,
      suppleDocVisible: false,
      form: {}, // 测试表单数据
      effectBatchVisible: false, // 批量落实弹窗标识
      tabValue: {
        feedbackResource: '1',
        auditFileType: '1001'
      },
      handleFlag: true,
      sourceData: [],
      componentList: [
        {
          // 产品名称
          label: this.$i18n.messages[this.$i18n.locale].common.productName,
          disabled: false,
          value: 'projectId',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          labelWidth: '130px',
          clearable: true,
          componentName: absFileSelectList
        },
        {
          // 期数
          label: this.$i18n.messages[this.$i18n.locale].common.periodsNum,
          disabled: false,
          value: 'periods',
          maxlength: 3,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          labelWidth: '130px',
          clearable: true,
          componentName: issueInput
        },
        {
          // 供应商名称
          label: this.$i18n.messages[this.$i18n.locale].feedbackMaterialIndex.gys,
          disabled: false,
          value: 'suppliersName',
          maxlength: 255,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          labelWidth: '130px',
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 项目公司名称
          label: this.$i18n.messages[this.$i18n.locale].feedbackMaterialIndex.xmg,
          disabled: false,
          value: 'projectCompanyName',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          labelWidth: '130px',
          clearable: true,
          maxlength: 255,
          componentName: 'el-input'
        },
        {
          // 付款确认书编号
          label: this.$i18n.messages[this.$i18n.locale].common.payCode,
          disabled: false,
          value: 'assetCode',
          maxlength: 50,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          labelWidth: '130px',
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 反馈状态
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackStatus,
          disabled: false,
          value: 'feedbackStatus',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          labelWidth: '130px',
          clearable: true,
          componentName: 'SelectDictionary',
          dictTypeCode: 'AUDIT_OUT_FEEDBACK_STATUS'
        }
      ],
      columns: [
        {
          // 批次
          prop: 'feedbackFrequency',
          align: 'center',
          width: '60px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackFrequency,
          format (row) {
            if (row.feedbackFrequency === $this.$t('effectDealFeedBackMain.firstBatch')) {
              return $this.$t('effectDealFeedBackMain.seconedBatch')
            } else {
              return row.feedbackFrequency
            }
          }
        }, {
          // 反馈状态
          prop: 'feedbackStatus',
          align: 'center',
          width: '160px',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackStatus,
          format (row) {
            if (row.feedbackStatus === '0') {
              return '/'
            } else {
              return format.formatDict(row.feedbackStatus, 'AUDIT_OUT_FEEDBACK_STATUS')
            }
          }
        }, {
          // 是否放款
          prop: 'isLoan',
          align: 'center',
          width: '80px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.isLoan,
          format (row) {
            return row.isLoan === '1' ? $this.$t('common.no') : $this.$t('common.yes')
          }
        }, {
          // 付款确认书编号
          prop: 'assetCode',
          align: 'left',
          width: '240px',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.assetCode
        }, {
          // 供应商名称
          prop: 'suppliersName',
          align: 'left',
          width: '210px',
          showOverflowTooltip: true,
          // slot: true,
          label: this.$i18n.messages[this.$i18n.locale].feedbackMaterialIndex.gys
        }, {
          // 项目公司名称
          prop: 'projectCompanyName',
          align: 'left',
          width: '210px',
          showOverflowTooltip: true,
          // slot: true,
          label: this.$i18n.messages[this.$i18n.locale].feedbackMaterialIndex.xmg
        }, {
          // 资产标志
          prop: 'assetFlagDTO',
          align: 'left',
          width: '130px',
          slot: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.assetFlag
        }, {
          // 合规人员
          prop: 'traceUserName',
          align: 'center',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.traceUser
        }, {
          // 备注
          prop: 'effectMemo',
          align: 'left',
          width: '150px',
          showOverflowTooltip: true,
          // slot: true,
          label: this.$i18n.messages[this.$i18n.locale].reviewMaterialIndex.remark
        }, {
          // 问题序号
          prop: 'qusetionNumber',
          align: 'center',
          width: '80px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackQustionNo
        }, {
          // 相关方
          prop: 'relation',
          align: 'center',
          width: '120px',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.relation
        }, {
          // 未补回资料
          prop: 'supplementNoFile',
          align: 'left',
          width: '120px',
          showOverflowTooltip: true,
          // slot: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.supplementNoFile
        }, {
          // 相关方预计补回时间
          prop: 'estimateSupplementTime',
          align: 'center',
          width: '160px',
          slot: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.estimateSupplementTime
        }, {
          // 是否通用问题
          prop: 'isCommonQustion',
          align: 'center',
          width: '110px',
          slot: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.isCommonQustion
        }, {
          // 问题状态
          prop: 'questionStatus',
          align: 'center',
          width: '100px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.questionStatus,
          format (row) {
            if (row.questionStatus === '0') {
              return ''
            } else {
              return format.formatDict(row.questionStatus, 'AUDIT_OUT_QUST_FEEDBACK_STATUS')
            }
          }
        }
      ]
    }
  },
  mounted () {
    if (!this.UtilJs.isEmpty(this.$router.history.current.query)) {
      this.$set(this.queryParas, 'projectId', this.$router.history.current.query.projectId)
      this.$set(this.queryParas, 'periods', this.$router.history.current.query.periods)
      this.$set(this.queryParas, 'feedbackStatus', this.$router.history.current.query.feedbackStatus)
      this.displayFlag = this.$router.history.current.query.displayFlag
    }
    this.filedshandleFilter()
  },
  filters: {
    format (row) {
      return row === '0' ? '否' : '是'
    },
    timeFormat (row) {
      return format.formatCheckDatetime(row, 'yyyy-MM-dd')
    }
  },
  methods: {
    // tab文件类型处理
    async tabFileTypeList () {
      let param = {
        fileQueryType: '4',
        stampWay: ''
      }
      let fileParam = {
        projectId: this.queryParas.projectId ? this.queryParas.projectId : '',
        specialPlanPeriods: this.queryParas.periods ? this.queryParas.periods : '',
        participant: '60'
      }
      param.stampWay = await new Promise((resolve, reject) => {
        this.stampApi.getStampInfo(fileParam).then(res => {
          if (res.code === '0' && res.data && res.data.length > 0) {
            resolve(res.data[0].stampWay)
          } else {
            resolve('')
          }
        })
      })
      let fileParams = {
        projectId: this.queryParas.projectId ? this.queryParas.projectId : '',
        periods: this.queryParas.periods ? this.queryParas.periods : '',
        fileQueryType: '4',
        stampWay: param.stampWay
      }
      this.inEditPane = await new Promise((resolve, reject) => {
        this.fileTypeApi.getList(fileParams).then(res => {
          if (res.data) {
            resolve(res.data)
          }
        })
      })
    },
    // 查询显示提示Icon
    showIcon (item) {
      if (this.sourceData.filter(item => item.isSelected === true).length > 0 && (item.dictId === this.tabValue.feedbackResource || item.fileType === this.tabValue.auditFileType)) {
        return true
      } else {
        return false
      }
    },
    // 查看履历
    viewAntecedents (row) {
      this.reimApi.getDefaultHistory({ feedbackAssetKey: row.fdbkKeyId }).then(res => {
        if (res.data.length > 0) {
          this.form = {}
          this.form = Object.assign(Object.assign({}, { data: res.data }), { assetCode: row.assetCode })
          Object.assign(this.form, { keyId: row.fdbkKeyId })
          Object.assign(this.form, { assetInfoId: row.assetInfoId })
          Object.assign(this.form, { auditFileType: this.queryParas.auditFileType })
          this.suppleDocHisVisible = true
        } else {
          this.error('查看履历失败')
        }
      })
    },
    // 编辑备注
    editRemarks (row) {
      let param = Object.assign({ identityFlag: '1' },
        {
          assetKeyId: row.fdbkKeyId,
          assetCode: row.assetCode
        }
      )
      this.memoApi.getDefaultInfo(param).then(res => {
        if (res.data && !res.data.errFlag) {
          this.form = {}
          this.form = Object.assign(res.data, { identityFlag: '1' })
          this.editMemoVisible = true
        } else {
          this.error('编辑备注失败')
        }
      })
    },
    // 落实
    workable (row) {
      this.keyIdArray = []
      this.keyIdArray.push({
        keyId: row.fdbkKeyId
      })
      this.editModel = 'IS'
      this.effApi = this.SingleImApi
      this.title = this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.singleImplement
      this.effectBatchVisible = true
    },
    // 发补寄
    sending (row) {
      this.form = row
      this.editModel = 'FIS'
      this.suppleDocVisible = true
    },
    // 可退单
    returnableBill (row) {
      let param = [{
        'assetInfoId': row.assetInfoId,
        'enterpriseId': row.enterpriseId,
        'enterpriseType': ['10', '110'][row.enterpriseType - 1], // 1为10：律所；2为110：计划管理人
        // 'ifsSelected': row.ifsSelected,
        'selectedChargebackFlag': '1'
      }]
      this.$confirm('确认退单?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.backApi.putChargeback(param).then(res => {
          if (res.data > 0) {
            this.dshandleFilter()
            this.success('退单成功')
          } else {
            this.success('没有可退单资产')
          }
        })
      }).catch(() => {
      })
    },
    // 处理结束
    endProcessing (row) {
      this.$confirm('确认处理结束?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.reimApi.putDefaultOver({ keyId: row.fdbkKeyId, modifyTime: row.assetInfoModifyTime }).then(res => {
          if (res.data) {
            this.dshandleFilter()
            this.success('处理结束成功')
          } else {
            this.error('处理结束失败')
          }
        })
      }).catch(() => {
      })
    },
    // 点击父级tab
    fatherTabClick (tab, event) {
      // 去请求获得表格数据
      this.dshandleFilter()
    },
    // 点击子级tab
    sonTabClick (tab, event) {
      // 去请求获得表格数据
      this.dshandleFilter()
    },
    // 参数重构
    paramsMoreDo () {
      // 重构查询参数
      Object.assign(this.tabValue, { 'displayFlag': this.displayFlag === true ? '1' : '0' })
      Object.assign(this.tabValue, { 'traceUserId': this.userId })
      // Object.assign(this.tabValue, { 'traceUserId': '1912021116434240001' })
      this.queryParas = Object.assign(this.queryParas, this.tabValue)
    },
    // 文件列表相关查询
    async filedshandleFilter () {
      // 重构查询参数
      this.paramsMoreDo()
      // 文件类型tab
      await this.tabFileTypeList()
      // 调用基础画面的查询方法
      this.handleFilter()
    },
    // 查询
    dshandleFilter () {
      // 重构查询参数
      this.paramsMoreDo()
      // 调用基础画面的查询方法
      this.handleFilter()
    },
    // 批量落实
    effecBatchClick () {
      this.paramsMoreDo()
      this.batchImApi.getList(this.queryParas).then(res => {
        if (res.data.length > 0) {
          this.keyIdArray = []
          this.effApi = this.batchImApi
          this.keyIdArray = res.data
          this.editModel = 'I'
          this.title = this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.batchImplement
          this.effectBatchVisible = true
        } else {
          this.warning('没有可落实的数据')
        }
      })
    },
    // 批量审核
    auditBatchClick () {
      this.paramsMoreDo()
      if (this.queryParas.feedbackFrequency) {
        delete this.queryParas.feedbackFrequency
      }
      this.dealApi.getList(this.queryParas).then(res => {
        if (res.data.length > 0) {
          this.keyIdArray = []
          this.keyIdArray = res.data
          this.effApi = this.dealApi
          this.queryParamBatch = this.queryParas
          this.editModel = 'A'
          this.title = this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.batchAudit
          this.effectBatchVisible = true
        } else {
          this.warning('没有可审核的数据')
        }
      })
    },
    // 批量发补寄
    sendBatchClick () {
      this.paramsMoreDo()
      this.supBApi.getList(this.queryParas).then(res => {
        if (res.data.length > 0) {
          this.keyIdArray = []
          this.keyIdArray = res.data
          this.editModel = 'BIS'
          this.suppleDocVisible = true
        } else {
          this.warning('没有可发补寄的数据')
        }
      })
    },
    // 业务员改变时间
    dataChange (row) {
      if (row.estimateSupplementTime === null) {
        return
      }
      let param = {
        keyId: row.relationHandleKeyId,
        date: row.estimateSupplementTime
      }
      this.reimApi.putDefaultUpdate(param).then(res => {
        if (res.data) {
          this.success('成功修改补回时间')
        } else {
          this.error('修改补回时间失败')
        }
      })
    },
    // 数据初始化完成事件
    getTableData () {
      this.getRowSpan()
      this.getRowSpanTwo()
      this.getRowSpanRelation()
      this.getRowSpanQuesNo()
      this.implementButton()
      this.getRowFlag()
    },
    // 落实按钮是否显示判断(合并后)
    implementButton () {
      let fbkeyArr = []
      this.sourceData.forEach(res => {
        if (fbkeyArr.includes(res.fdbkKeyId)) {
          return
        }
        fbkeyArr.push(res.fdbkKeyId)
        let arr = this.sourceData.filter(item => item.fdbkKeyId === res.fdbkKeyId)
        arr.every(resq => {
          if (resq.ownFlag === '1' && (resq.questionStatus === '1' || arr.filter(resfilter => resfilter.qstDetailKeyId === resq.qstDetailKeyId).every(resqe => { if (resqe.relationDealStatus !== '1') { return false } else { return true } }) || resq.relationDealStatus === '2')) {
            arr.forEach(v => {
              // return { ...v, isSelected: true }
              v.isSelected = true
            })
            return false
          } else {
            return true
          }
        })
      })
    },
    // 画面关闭调用查询
    close (val) {
      if (val) {
        this.dshandleFilter()
      }
    },
    // 获取合并的数组
    getRowSpanTwo () {
      this.rowSpanArrTwo = []
      this.sourceData.forEach((item, index) => {
        if (index === 0) {
          this.rowSpanArrTwo.push(1)
          this.position = 0
        } else {
          if (this.sourceData[index].qusetionNumber === this.sourceData[index - 1].qusetionNumber && this.sourceData[index].qstDetailKeyId === this.sourceData[index - 1].qstDetailKeyId && this.sourceData[index].fdbkKeyId === this.sourceData[index - 1].fdbkKeyId) {
            this.rowSpanArrTwo[this.position] += 1 // 项目名称相同，合并到同一个数组中
            this.rowSpanArrTwo.push(0)
            this.sourceData[index].fdbkKeyId = this.sourceData[index - 1].fdbkKeyId
            this.sourceData[index].qstDetailKeyId = this.sourceData[index - 1].qstDetailKeyId
            this.sourceData[index].qusetionNumber = this.sourceData[index - 1].qusetionNumber
          } else {
            this.rowSpanArrTwo.push(1)
            this.position = index
          }
        }
      })
    },
    // 获取合并的数组
    getRowSpanRelation () {
      this.rowSpanArrRelation = []
      this.sourceData.forEach((item, index) => {
        if (index === 0) {
          this.rowSpanArrRelation.push(1)
          this.position = 0
        } else {
          if (this.sourceData[index].qusetionNumber === this.sourceData[index - 1].qusetionNumber && this.sourceData[index].relationHandleKeyId === this.sourceData[index - 1].relationHandleKeyId && this.sourceData[index].qstDetailKeyId === this.sourceData[index - 1].qstDetailKeyId && this.sourceData[index].fdbkKeyId === this.sourceData[index - 1].fdbkKeyId) {
            this.rowSpanArrRelation[this.position] += 1 // 项目名称相同，合并到同一个数组中
            this.rowSpanArrRelation.push(0)
            this.sourceData[index].qusetionNumber = this.sourceData[index - 1].qusetionNumber
            this.sourceData[index].fdbkKeyId = this.sourceData[index - 1].fdbkKeyId
            this.sourceData[index].qstDetailKeyId = this.sourceData[index - 1].qstDetailKeyId
            this.sourceData[index].relationHandleKeyId = this.sourceData[index - 1].relationHandleKeyId
          } else {
            this.rowSpanArrRelation.push(1)
            this.position = index
          }
        }
      })
    },
    // 获取合并的数组
    getRowSpanQuesNo () {
      this.rowSpanArrQuesNo = []
      this.sourceData.forEach((item, index) => {
        if (index === 0) {
          this.rowSpanArrQuesNo.push(1)
          this.position = 0
        } else {
          if (this.sourceData[index].qusetionNumber === this.sourceData[index - 1].qusetionNumber && this.sourceData[index].fdbkKeyId === this.sourceData[index - 1].fdbkKeyId) {
            this.rowSpanArrQuesNo[this.position] += 1 // 项目名称相同，合并到同一个数组中
            this.rowSpanArrQuesNo.push(0)
            this.sourceData[index].fdbkKeyId = this.sourceData[index - 1].fdbkKeyId
            this.sourceData[index].qusetionNumber = this.sourceData[index - 1].qusetionNumber
          } else {
            this.rowSpanArrQuesNo.push(1)
            this.position = index
          }
        }
      })
    },
    // 合并资产标志
    getRowFlag () {
      if (this.sourceData.length > 0) {
        this.sourceData.reverse()
        this.sourceData.forEach((item, index) => {
          if (index !== 0 && item.assetCode === this.sourceData[index - 1].assetCode) {
            let combind = {}
            let arr = ['canChargeback', 'chargebacked', 'isUrgent', 'chargebackRisk', 'pump', 'difficultAsset', 'over']
            arr.forEach(s => {
              if (this.sourceData[index - 1][s] === '1') {
                combind[s] = this.sourceData[index - 1][s]
              }
            })
            item = Object.assign(item, combind)
          }
          // console.log(item)
          return item
        })
        this.sourceData.reverse()
      }
    },
    // 行元素颜色警告
    rowStyle ({ row, rowIndex }) {
      if (!row.relation.indexOf(this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.documents)) {
        return 'background-color:#ffe5e5 !important;background:#ffe5e5 !important'
      }
      return ''
    },
    // 获取合并的数组
    getRowSpan () {
      this.rowSpanArr = []
      this.sourceData.forEach((item, index) => {
        if (this.sourceData[index].estimateSupplementTime === -2209017600000) {
          this.sourceData[index].estimateSupplementTime = null
        }
        if (index === 0) {
          this.rowSpanArr.push(1)
          this.position = 0
        } else {
          if (this.sourceData[index].fdbkKeyId === this.sourceData[index - 1].fdbkKeyId) {
            this.rowSpanArr[this.position] += 1 // 项目名称相同，合并到同一个数组中
            this.rowSpanArr.push(0)
            this.sourceData[index].fdbkKeyId = this.sourceData[index - 1].fdbkKeyId
          } else {
            this.rowSpanArr.push(1)
            this.position = index
          }
        }
      })
    },
    // 行合并
    objectSpanMethod ({ row, column, rowIndex, columnIndex }) {
      if ((columnIndex > -1 && columnIndex < 9) || columnIndex === 15) {
        let $row = this.rowSpanArr[rowIndex]
        return {
          rowspan: $row, // 行
          colspan: 1 // 列
        }
      }
      if ((columnIndex === 9)) {
        let $row = this.rowSpanArrQuesNo[rowIndex]
        return {
          rowspan: $row, // 行
          colspan: 1 // 列
        }
      }
      if ((columnIndex > 12 && columnIndex < 15)) {
        let $row = this.rowSpanArrTwo[rowIndex]
        return {
          rowspan: $row, // 行
          colspan: 1 // 列
        }
      }
      if ((columnIndex > 9 && columnIndex < 13)) {
        let $row = this.rowSpanArrRelation[rowIndex]
        return {
          rowspan: $row, // 行
          colspan: 1 // 列
        }
      }
    }
  }
}
</script>

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