<!--异常订单记录表-->
<template>
  <div>
    <up-down-layout :handleFlag.sync="handleFlag">
      <search-form
        @clearParam="clearParam"
        @handleFilter="handleFilter"
        searchPerms="search"
        resetPerms="reset"
        :formValue.sync="queryParas"
        v-model="queryParas"
        :componentList="componentList"
        slot="query">
      </search-form>

      <template slot="table">
        <el-form :show-message="false">
          <data-table :menuCode="menuId" :spanMethod="mergedCell"
                      :cellStyle="cellStyle"
                      :api="api"
                      :border="true" :stripe="true"
                      :menuFlag="true"
                      :handleFlag.sync="handleFlag"
                      :showSelection="true"
                      :queryParas="queryParas"
                      :sourceData.sync="formTableData.sourceData"
                      :loadCount.sync="loadCount"
                      :columns="columns"
                      v-bind="elHeightObj"
                      @getTableData = "getTableData"
                      :operateBtnLayout="operateBtnLayout"
                      @selectRowChange="selectionData"
          >
            <template slot="headButton">
              <el-row>
                <el-col :span="24" class="textRight">
                  <auth-button size="medium" type="primary" @click="lawFirmAbnormalDetail()"
                               :label="$t('common.export')" class="iconfont icondaochu"></auth-button>
                  <auth-button size="medium" type="primary" @click="generateDetail()" :label="$t('common.save')"
                               class="iconfont iconbaocun11"></auth-button>
                </el-col>
              </el-row>
            </template>

            <template slot="estimatedFinishTimeCopy" slot-scope="scope">
              <el-date-picker   :picker-options="pickerOption" :disabled="scope.data.row.toHandleTheState==='已完成'" @change="saveStatusChange"  v-model="scope.data.row.estimatedFinishTime" value-format="yyyy-MM-dd"></el-date-picker>
            </template>

            <!--<template slot="remarks" slot-scope="scope">
              <el-input  :disabled="scope.data.row.toHandleTheState==='已完成'" @focus="getFocus"   @change="saveStatusChange" type="textarea" size="mini" :rows="2" v-model="scope.data.row.memo" :placeholder="$t('common.MultilineInput')" maxlength="100"></el-input>
            </template>-->
            <template slot="remarks"  slot-scope="scope">
              <el-tooltip placement="top"  v-if="scope.data.row.memo !== ''">
                <div slot="content" >{{scope.data.row.memo}}</div>
                <span>
                  <el-input  :disabled="scope.data.row.toHandleTheState==='已完成'" @focus="getFocus"   @change="saveStatusChange" type="textarea" size="mini" :rows="2" v-model="scope.data.row.memo" :placeholder="$t('common.MultilineInput')" maxlength="100"></el-input>
                </span>
              </el-tooltip>
              <el-input  v-if="scope.data.row.memo === ''"  :disabled="scope.data.row.toHandleTheState==='已完成'" @focus="getFocus"   @change="saveStatusChange" type="textarea" size="mini" :rows="2" v-model="scope.data.row.memo" :placeholder="$t('common.MultilineInput')" maxlength="100"></el-input>
            </template>

            <el-table-column :label="$t('common.operate')" align="center" fixed="right" :width="100">
              <template slot-scope="scope">
                <el-row>
                  <el-col :span="12" v-if="(scope.row.toHandleTheState===$t('traceMgr.untreated')||scope.row.toHandleTheState===$t('traceMgr.InProcessing')) && scope.row.coreAreaAttache === $store.getters.userId">
                    <el-tooltip effect="dark" :content="$t('approval.columnName')" class="item" placement="top">
                      <el-button size="mini" circle @click="complete(scope.row)" class="iconfont iconbanli-active"></el-button>
                    </el-tooltip>
                  </el-col>
                  <el-col :span="12" v-if="scope.row.toHandleTheState===$t('traceMgr.beenCompleted')">
                    <el-tooltip  effect="dark" :content="$t('common.view')" class="item" placement="top">
                      <el-button size="mini" circle @click="doHandleTask(scope.row)" class="iconfont iconzuopintoupiao"></el-button>
                    </el-tooltip>
                  </el-col>
                  <el-col :span="12" v-if="scope.row.toHandleTheState===$t('traceMgr.untreated')||scope.row.toHandleTheState===$t('traceMgr.InProcessing')||scope.row.toHandleTheState===$t('traceMgr.beenCompleted')">
                    <el-tooltip class="item" placement="top" effect="dark" :content="$t('common.OrderRecord')">
                      <el-button size="mini" @click="supplemenFileAbnormalDetail(scope.row)" class="iconfont iconlvli" circle></el-button>
                    </el-tooltip>
                  </el-col>
                </el-row>
              </template>
            </el-table-column>
          </data-table>
        </el-form>
      </template>
    </up-down-layout>
    <!--律所  -->
    <lawFirmAbnormalDetailDialog :visible.sync="externalMechanismAnomaly" :editModel="editModel" :assetCode="assetCode" :assetInfoId="assetInfoId"
                                 :form="form"></lawFirmAbnormalDetailDialog>
    <!---资料-->
    <supplemenFileAbnormalDetailDialog :visible.sync="FileAbnorma" :editModel="editModel" :form="File"
                                       :assetId="assetInfoId"></supplemenFileAbnormalDetailDialog>
    <!--入池-->
    <supplemenFileInPoolAbnormalDetailDialog :visible.sync="exceptionDetailsShould" :editModel="editModel"
                                             :form="Should"
                                             :assetInfoId="assetInfoId"></supplemenFileInPoolAbnormalDetailDialog>
    <!--中登-->
    <china-clear-abnormal-detail-dialog :visible.sync="chinaClear" :editModel="editModel"
                                        :form="Detail"></china-clear-abnormal-detail-dialog>
    <factoringInfoDetail :visible.sync="fileListShow" :keyId="assetInfoIdForDetail" :needComplete="true"
                         :title="$t('common.OrderRecord')" :editModel="editModel"></factoringInfoDetail>

    <!--生成情况说明-->signFign
    <generate-task :visible.sync="Generate" :editModel="editModel" :form="Description"></generate-task>

    <!-- 中登异常-->
    <abnormal-handle-page :form="form" signFign="2" :assetInfoId="assetInfoId"
                          :visible.sync="abnormalHandleVisible"></abnormal-handle-page>
    <!-- 律所反馈 -->
    <law-firm-task-dialog  :visible.sync="lawFirmTaskDialogShow" :taskId="taskId" :assetCode="assetCode" :assetInfoId="assetInfoId" :lawFirmTaskType="lawFirmTaskType"
                           :close="closeLawFirmTaskDialog" :handler="handler"></law-firm-task-dialog>
    <!--   资料补寄异常   -->
    <supplier-file :visible.sync="supplierFileDialogShow" :fileStampWay="fileStampWay" :supplierId="supplierId" :bpmId="bpmId" :assetCode="assetCode" :assetInfoId="assetInfoId" :handler="handler"></supplier-file>

    <!-- 中登异常查看-->
    <abnormal-info-page  :form="form" signFign="2" :assetInfoId="assetInfoId" :visible.sync="abnormalInfoVisible"></abnormal-info-page>
  </div>
</template>
<script>
import BasePage from '@/pages/basePage'
import * as format from '@/filters/index'
import mixin from '@/pages/mixin'
import {
  authButton, btnUpload, btnBatchUpload, btnDownload,
  btnImport, upDownLayout, searchForm, DataTable, SelectCoreEnterprise, SelectCoreEnterpriseCascade,
  SelectFinancialInstitutions, SelectPeriodsCascade, SelectAreaCommissioner, SelectBusinessCommissioner,
  SelectFactoringCommissioner, SelectSmallArea, SelectAddress, SelectPlanManager, factoringInfoDetail
} from 'newepoch-components'
import lawFirmAbnormalDetailDialog
  from '@/components/tracemgr/regionalCommissioner/workbench/abnormalOrder/lawFirmAbnormalDetailDialog'
import supplemenFileAbnormalDetailDialog
  from '@/components/tracemgr/regionalCommissioner/workbench/abnormalOrder/supplemenFileAbnormalDetailDialog'
import supplemenFileInPoolAbnormalDetailDialog
  from '@/components/tracemgr/regionalCommissioner/workbench/abnormalOrder/supplemenFileInPoolAbnormalDetailDialog'
import chinaClearAbnormalDetailDialog
  from '@/components/tracemgr/regionalCommissioner/workbench/abnormalOrder/chinaClearAbnormalDetailDialog'
import generateTask from '@/components/tracemgr/factoringCommissioner/taskTable/generateTheSituation/taskDialog'
import tracemgrApi from '@/api/tracemgrApi.js'
import fileApi from '@/api/fileApi.js'
import { downFile } from '@/utils/devUtils'
import SelectFlag from '@/components/tracemgr/common/SelectFlag'
import abnormalHandlePage from '@/components/tracemgr/regionalCommissioner/TaskTable/abnormalHandle/abnormalHandlePage'
import abnormalInfoPage from '@/components/tracemgr/regionalCommissioner/TaskTable/abnormalInfoList/abnormalInfoPage'
import lawFirmTaskDialog from '@/components/tracemgr/factoringCommissioner/taskTable/lawFirm/taskDialog.vue'
import supplierFile from '@/components/tracemgr/regionalCommissioner/TaskTable/supplemenFileInPool/taskDialog.vue'

export default {
  extends: new BasePage(),
  mixins: [mixin],
  name: 'abnormalOrderList',
  components: {
    abnormalHandlePage,
    abnormalInfoPage,
    lawFirmTaskDialog,
    supplierFile,
    format,
    SelectFlag,
    SelectCoreEnterpriseCascade,
    searchForm,
    DataTable,
    SelectCoreEnterprise,
    upDownLayout,
    factoringInfoDetail,
    SelectPlanManager,
    SelectAddress,
    btnBatchUpload,
    btnDownload,
    btnUpload,
    authButton,
    btnImport,
    SelectFinancialInstitutions,
    SelectPeriodsCascade,
    SelectAreaCommissioner,
    SelectBusinessCommissioner,
    SelectFactoringCommissioner,
    SelectSmallArea,
    lawFirmAbnormalDetailDialog,
    supplemenFileInPoolAbnormalDetailDialog,
    chinaClearAbnormalDetailDialog,
    generateTask,
    supplemenFileAbnormalDetailDialog
  },
  data () {
    return {
      pickerOption: {
        disabledDate (time) {
          return time.getTime() <= Date.now() - 8.64e7
        }
      },
      supplierId: '',
      bpmId: '',
      fileStampWay: '',
      userHaveFocus: false,
      isToCHR: false,
      assetInfoIdForDetail: '',
      taskId: '',
      form: {},
      supplierFileDialogShow: false,
      lawFirmTaskDialogShow: false,
      lawFirmTaskType: '',
      assetCode: '',
      abnormalHandleVisible: false,
      Remarks: '',
      dateTime: '',
      item: {},
      abnormalInfoVisible: false,
      editModel: {},
      formTableData: {
        sourceData: []
      },
      externalMechanismAnomaly: false,
      exceptionDetailsShould: false,
      styles: '',
      assetInfoId: '',
      fileListShow: false,
      buttonDisable: false,
      Generate: false,
      needComplete: true,
      chinaClear: false,
      FileAbnorma: false,
      currentTotal: 0,
      sIdx: 0,
      loadCount: 0,
      operateBtnLayout: '',
      queryParas: {
        pageIndex: 1,
        pageSize: 10,
        paymentConfirmationNo: '',
        coreEnterprise: '',
        financialInstitutions: '',
        periods: '',
        nameOfProjectCompany: '',
        supplierName: '',
        businessProcessState: '',
        abnormalCategories: '',
        toHandleTheState: ['1', '2'],
        sectionNumber: '',
        region: '',
        businessPersonnel: '',
        regionalCommissioner: '',
        regionalCommissionerId: [this.$store.getters.userId]
      },
      spanArr: [],
      position: 0,
      curRowArr: [],
      sameRowArr: [],
      Anomaly: {
        ConfirmationOfPayment: [],
        supplierName: [],
        assetInfoId: ''
      },
      Should: {
        assetInfoId: '',
        fileCode: ''
      },
      File: {
        assetInfoId: '',
        fileCode: ''
      },
      Detail: {
        ConfirmationOfPayment: [],
        supplierName: [],
        assetInfoId: ''
      },
      Description: {
        assetInfoId: '',
        factType: ''
      },
      showOperation: true,
      selectedRows: [],
      handleFlag: true,
      componentList: [
        // 付款确认书编号
        {
          value: 'paymentConfirmationNo',
          componentName: 'el-input',
          name: 'paymentConfirmationNo',
          label: this.$i18n.messages[this.$i18n.locale].common.paymentConfirmationNo,
          prop: 'PaymentConfirmationNo',
          labelWidth: '110px',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.input + this.$i18n.messages[this.$i18n.locale].common.paymentConfirmationNo
        },
        // 核心企业
        {
          value: 'coreEnterprise',
          disabled: false,
          componentName: SelectCoreEnterprise,
          label: this.$i18n.messages[this.$i18n.locale].common.coreEnterprise,
          prop: 'coreEnterprise',
          labelWidth: '120px',
          multiple: true
        }, // 计划管理人/再保理银行
        {
          value: 'financialInstitutions',
          componentName: SelectPlanManager,
          multiple: true,
          name: 'financialInstitutions',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.financialInstitutions,
          prop: 'financialInstitutions',
          labelWidth: '160px'
        }, // 期数
        {
          value: 'periods',
          componentName: SelectFlag,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.periodsCascade,
          labelWidth: '110px',
          options: [{ label: 1, value: 1 }, { label: 2, value: 2 }, { label: 3, value: 3 }, { label: 4, value: 4 }, {
            label: 5,
            value: 5
          }, { label: 6, value: 6 },
          { label: 7, value: 7 }, { label: 8, value: 8 }, { label: 9, value: 9 }, { label: 10, value: 10 }, {
            label: 11,
            value: 11
          }, { label: 12, value: 12 },
          { label: 13, value: 13 }, { label: 14, value: 14 }, { label: 15, value: 15 }, {
            label: 16,
            value: 16
          }, { label: 17, value: 17 }, { label: 18, value: 18 },
          { label: 19, value: 19 }, { label: 20, value: 20 }, { label: 21, value: 21 }, {
            label: 22,
            value: 22
          }, { label: 23, value: 23 }, { label: 24, value: 24 },
          { label: 25, value: 25 }, { label: 26, value: 26 }, { label: 27, value: 27 }, {
            label: 28,
            value: 28
          }, { label: 29, value: 29 }, { label: 30, value: 30 },
          { label: 31, value: 31 }, { label: 32, value: 32 }, { label: 33, value: 33 }, {
            label: 34,
            value: 34
          }, { label: 35, value: 35 }, { label: 36, value: 36 },
          { label: 37, value: 37 }, { label: 38, value: 38 }, { label: 39, value: 39 }, {
            label: 40,
            value: 40
          }, { label: 41, value: 41 }, { label: 42, value: 42 },
          { label: 43, value: 43 }, { label: 44, value: 44 }, { label: 45, value: 45 }, {
            label: 46,
            value: 46
          }, { label: 47, value: 47 }, { label: 48, value: 48 },
          { label: 49, value: 49 }, { label: 50, value: 50 }],
          multiple: true
        }, // 项目公司名称
        {
          value: 'nameOfProjectCompany',
          disabled: false,
          componentName: 'el-input',
          name: 'nameOfProjectCompany',
          label: this.$i18n.messages[this.$i18n.locale].common.nameOfProjectCompany,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.input + this.$i18n.messages[this.$i18n.locale].common.nameOfProjectCompany,
          prop: 'nameOfProjectCompany',
          labelWidth: '120px'
        },
        // 供应商名称
        {
          value: 'supplierName',
          disabled: false,
          componentName: 'el-input',
          name: 'supplierName',
          label: this.$i18n.messages[this.$i18n.locale].common.supplierName,
          prop: 'supplierName',
          labelWidth: '160px',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.input + this.$i18n.messages[this.$i18n.locale].common.supplierName
        }, // 业务流程状态
        {
          value: 'businessProcessState',
          disabled: false,
          componentName: 'SelectDictionary',
          dictTypeCode: 'tracemgr_business_process_status',
          name: 'businessProcessState',
          label: this.$i18n.messages[this.$i18n.locale].common.businessProcessState,
          prop: 'businessProcessState',
          filterable: true,
          labelWidth: '110px'
        }, // 异常类别
        {
          value: 'abnormalCategories',
          disabled: false,
          componentName: 'SelectDictionary',
          dictTypeCode: 'tracemgr_abnormal_type',
          name: 'abnormalCategories',
          label: this.$i18n.messages[this.$i18n.locale].common.abnormalCategories,
          prop: 'abnormalCategories',
          labelWidth: '120px'
        }, // 办理状态
        {
          value: 'toHandleTheState',
          dictTypeCode: 'tracemgr_bpm_task_status', // 下拉值
          componentName: 'SelectDictionary',
          labelWidth: '160px',
          multiple: true,
          label: this.$i18n.messages[this.$i18n.locale].common.toHandleTheState,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.selectInfo
        },
        // 区域编号
        {
          value: 'sectionNumber',
          componentName: 'el-input',
          name: 'SectionNumber',
          label: this.$i18n.messages[this.$i18n.locale].common.sectionNumber,
          prop: 'SectionNumber',
          labelWidth: '110px',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.input + this.$i18n.messages[this.$i18n.locale].common.sectionNumber
        }, // 区域
        {
          value: 'region',
          componentName: SelectSmallArea,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.region,
          labelWidth: '120px',
          multiple: true
        }, // 业务人员
        {
          value: 'businessPersonnel',
          componentName: SelectBusinessCommissioner,
          disabled: false,
          name: 'businessPersonnel',
          multiple: true,
          label: this.$i18n.messages[this.$i18n.locale].common.businessPersonnel,
          prop: 'businessPersonnel',
          labelWidth: '160px'
        },
        // 区域专员
        {
          value: 'regionalCommissionerId',
          multiple: true,
          componentName: SelectAreaCommissioner,
          name: 'regionalCommissioner',
          label: this.$i18n.messages[this.$i18n.locale].common.theRegionalCommissioner,
          labelWidth: '110px'
        }
      ],
      columns: [
        // 付款确认书编号
        {
          prop: 'paymentConfirmationNo',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.confirmationOfPayment,
          showOverflowTooltip: true,
          width: '240px',
          fixed: 'left'
        },
        // 区域编号
        {
          prop: 'sectionNumber',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.sectionNumber,
          showOverflowTooltip: true,
          width: '200px',
          fixed: 'left'
        },
        // 区域
        {
          prop: 'district',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.district,
          showOverflowTooltip: true,
          width: 150,
          fixed: 'left'
        },
        // 项目公司
        {
          prop: 'projectCompany',
          align: 'left',
          label: this.$i18n.messages[this.$i18n.locale].common.projectCompany,
          showOverflowTooltip: true,
          width: 150,
          fixed: 'left'
        },
        // 供应商名称
        {
          prop: 'supplier',
          align: 'left',
          label: this.$i18n.messages[this.$i18n.locale].common.supplierName,
          showOverflowTooltip: true,
          width: '200px'
        },
        // 产品
        {
          prop: 'product',
          align: 'left',
          label: this.$i18n.messages[this.$i18n.locale].common.product,
          showOverflowTooltip: true,
          width: 200
        },
        // 盖章方式
        {
          prop: 'sealWay',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.sealWay,
          showOverflowTooltip: true,
          width: 120,
          format: (row) => {
            return format.formatDict(row.sealWay, 'tracemgr_seal_type')
          }
        },
        //  ZD0081
        // 保理金额
        {
          prop: 'theAmountOfFactoring',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.theAmountOfFactoring,
          showOverflowTooltip: true,
          width: 120,
          format: (row) => {
            if (row.theAmountOfFactoring === undefined || row.theAmountOfFactoring === '') {
              return ''
            }
            return format.thousandFilter(row.theAmountOfFactoring) + '元'
          }
        },
        // 合同名称
        {
          prop: 'basicContractName',
          align: 'left',
          label: this.$i18n.messages[this.$i18n.locale].common.nameOfTheContract,
          showOverflowTooltip: true,
          width: 200
        },
        // 业务人员
        {
          prop: 'businessPersonnel',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.businessPersonnel,
          showOverflowTooltip: true,
          width: 120
        },
        // 区域专员
        {
          prop: 'customerTypeName',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.theRegionalCommissioner,
          showOverflowTooltip: true,
          width: 120
        },
        // 业务流程状态
        {
          prop: 'businessProcessName',
          align: 'left',
          label: this.$i18n.messages[this.$i18n.locale].common.businessProcessState,
          showOverflowTooltip: true,
          width: '200px',
          filterable: true
        },
        // 异常类别
        {
          prop: 'abnormalCategories',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.abnormalCategories,
          showOverflowTooltip: true,
          width: '150px',
          format: (row) => {
            return format.formatDict(row.abnormalCategories, 'tracemgr_abnormal_type')
          }
        },
        // 任务发起时间
        {
          prop: 'taskInitiationTime',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.taskInitiationTime,
          showOverflowTooltip: true,
          width: '150px'
        },
        // 保理专员
        {
          prop: 'factoringCommissioner',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.factoringCommissioner,
          showOverflowTooltip: true,
          width: '120px'
        },
        // 办理状态
        {
          prop: 'toHandleTheState',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.toHandleTheState,
          showOverflowTooltip: true,
          width: '120px'
        },
        // 预计完成时间
        {
          prop: 'estimatedFinishTimeCopy',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.estimatedTimeOfCompletion,
          showOverflowTooltip: true,
          width: '200px',
          slot: true
        },
        // 备注
        {
          prop: 'remarks',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.remarks,
          showOverflowTooltip: true,
          width: '200px',
          slot: true
        }
      ],
      pageSize: 10
    }
  },
  watch: {
    'formTableData.sourceData': {
      deep: true,
      handler: function (newVal, oldVal) {
        this.spanArr = []
        this.sameRowArr = []
        this.isToCHR = false
        let isTongChouRen = false
        let $this = this
        if (newVal) {
          tracemgrApi['orderTrackListApi'].getCurrentUserRole().then(res => {
            if (res.data && res.data.length > 0) {
              for (let i = 0; i < res.data.length; i++) {
                if (res.data[i].v === this.$i18n.messages[this.$i18n.locale].baoLiWorkbenchOrderTrack.factoringCoordinator) {
                  isTongChouRen = true
                  break
                }
              }
              if (isTongChouRen) {
                $this.isToCHR = true
              }
            }
          })
          if (this.formTableData.sourceData.length > 0) {
            for (const item of this.formTableData.sourceData) {
              if (item.memoCopy !== item.memo || item.estimatedFinishTimeCopy !== item.estimatedFinishTime) {
                this.$emit('listData', true)
                return
              }
            }
          }
        }
      }
    }
  },
  mounted () {
    this.handler()
  },
  methods: {
    mergedCell: function ({ row, column, rowIndex, columnIndex }) {
      if (this.spanArr.length === 0) {
        this.getSpanArr()
      }
      if (columnIndex === 0) { // 对第一列进行合并
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 1) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 2) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 3) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 4) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 5) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 6) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 7) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 8) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 9) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 10) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 11) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 12) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 20) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
    },
    getSpanArr () {
      this.spanArr = [] // 避免表格错乱！
      this.sIdx = 0
      let $this = this
      this.formTableData.sourceData.forEach((item, index) => {
        item.index = index
        if (index === 0) {
          $this.spanArr.push(1)
          $this.position = 0
          $this.sameRowArr.push([index])
        } else {
          if ($this.formTableData.sourceData[index].paymentConfirmationNo === $this.formTableData.sourceData[index - 1].paymentConfirmationNo) { // 这里是要合并行
            $this.spanArr[this.position] += 1
            $this.spanArr.push(0)
            $this.sameRowArr[$this.sIdx].push(index)
          } else {
            $this.spanArr.push(1)
            $this.position = index
            $this.sIdx += 1
            $this.sameRowArr.push([index])
          }
        }
      })
    },
    handler () {
      this.handleFilter()
    },
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      return ''
    },
    apportionData: function () {
      this.handleFilter()
    },
    searchForm () {
      this.getPage()
    },
    clearParam () {
      this.user = []
      this.user.push(this.$store.getters.userId)
      this.queryParas = {
        pageIndex: 1,
        pageSize: 10,
        type: 3,
        paymentConfirmationNo: '',
        coreEnterprise: '',
        financialInstitutions: '',
        periods: '',
        nameOfProjectCompany: '',
        supplierName: '',
        businessProcessState: '',
        abnormalCategories: '',
        toHandleTheState: ['1', '2'],
        sectionNumber: '',
        region: '',
        businessPersonnel: '',
        regionalCommissioner: '',
        regionalCommissionerId: [this.$store.getters.userId]
      }
    },
    closeLawFirmTaskDialog () {
      this.lawFirmTaskDialogShow = !this.lawFirmTaskDialogShow
    },
    complete (row) {
      if (row.taskTypeName === '3' && row.abnormalCategories !== '1') {
        let data = {}
        data.assetInfoId = row.assetInfoId
        data.abnormalType = row.abnormalCategories
        data.dealPersonType = 2
        tracemgrApi['fcTaskTablePage'].getNoCompleteTask(data).then(res => {
          if (res.data) {
            row.taskId = res.data
            let taskId = { taskId: row.taskId }
            // 领取任务
            tracemgrApi['fcTaskTablePage'].claimTask(taskId).then(res => {
              if (res.data) {
                this.handleFilter()
                this.openDialog(row)
              } else {
                this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.claimTaskErroeMessage)
              }
            })
          } else {
            this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.noSelectDate)
          }
        })
      } else {
        this.openDialog(row)
      }
    },
    doHandleTask (row) {
      let $this = this
      $this.form.param = []
      if (row.abnormalCategories === '3') {
        row.assetCode = row.paymentConfirmationNo
        row.supplierId = row.creditorId
        $this.assetInfoId = row.assetInfoId
        $this.form = Object.assign({}, row)
        $this.FileAbnorma = true
        return
      }
      if (row.abnormalCategories === '2') {
        let data = {}
        data.assetInfoId = row.assetInfoId
        data.abnormalType = row.abnormalCategories
        data.dealPersonType = 2
        tracemgrApi['fcTaskTablePage'].getNoCompleteTask(data).then(res => {
          if (res) {
            $this.taskId = row.data
            $this.assetCode = row.paymentConfirmationNo
            $this.externalMechanismAnomaly = true
          }
        })
        $this.form.assetInfoId = row.assetInfoId
        return
      }
      // 中登异常
      if (row.abnormalCategories === '1') {
        $this.assetInfoId = row.assetInfoId
        $this.form = {}
        $this.form.assetCode = row.paymentConfirmationNo
        $this.abnormalInfoVisible = true
      }
    },
    openDialog: function (row) {
      let $this = this
      $this.form.param = []
      if (row.abnormalCategories === '3' || row.abnormalCategories === '4') {
        $this.assetInfoId = row.assetInfoId
        $this.assetCode = row.paymentConfirmationNo
        $this.supplierId = row.creditorId
        $this.bpmId = row.taskId
        $this.fileStampWay = row.sealWay
        $this.supplierFileDialogShow = true
        return
      }
      if (row.abnormalCategories === '2') {
        $this.taskId = row.taskId
        $this.assetCode = row.paymentConfirmationNo
        $this.assetInfoId = row.assetInfoId
        $this.lawFirmTaskType = this.$i18n.messages[this.$i18n.locale].common.theRegionalCommissioner
        $this.lawFirmTaskDialogShow = true
        return
      }
      // 中登异常
      if (row.abnormalCategories === '1') {
        $this.assetInfoId = row.assetInfoId
        $this.form = {}
        $this.form.assetCode = row.paymentConfirmationNo
        $this.abnormalHandleVisible = true
        // $this.abnormalHandleVisible = true
      }
    },
    unaccomplished () {
    },
    //* **  中登异常
    chinaClearDetail (row) {
      let $this = this
      $this.item = Object.assign({}, row)
      this.editModel = row
      this.chinaClear = true
    },
    //* ** 资料
    supplemenFileAbnormalDetail: function (row) {
      this.assetInfoIdForDetail = row.assetInfoId
      this.fileListShow = true
    },
    //* ** 入池
    supplemenFileInPoolAbnormal: function (row) {
      let $this = this
      $this.item = Object.assign({}, row)
      this.assetInfoId = row.assetInfoId
      this.editModel = row
      this.exceptionDetailsShould = true
    },
    generateThe: function () {
      let $this = this
      $this.item = Object.assign({ assetInfoId: '', factType: '' })
      this.Generate = true
    },
    //  导出
    lawFirmAbnormalDetail () {
      let $this = this
      $this.loading = true
      tracemgrApi['abnormalOrderApi'].excelExport(this.queryParas).then(res => {
        if (res.success) {
          fileApi.file.download({ keyId: res.data }).then(res => {
            downFile(res)
            $this.loading = false
          }).catch(() => {
            $this.loading = false
          })
        } else {
          $this.loading = false
          $this.error(this.$i18n.messages[this.$i18n.locale].ladingManageList.exportFaile)
        }
      }).catch(() => {
        $this.loading = false
      })
    },
    //  保存
    generateDetail (row) {
      let orderArr = []
      // 循环选中的列
      let editData = this.formTableData.sourceData
      editData.forEach(item => {
        // 封装数据
        orderArr.push({
          keyId: item.keyId,
          estimatedFinishTime: item.estimatedFinishTime,
          memo: item.memo
        })
      })
      tracemgrApi['abnormalOrderListApi'].save(orderArr).then(res => {
        if (res.data) {
          this.success(this.$i18n.messages[this.$i18n.locale].common.saveSuccess)
          this.handleFilter()
          this.$emit('setNeedSave', false)
        } else {
          this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.dontDown)
        }
      }, res => {
      })
    },
    abnormalExport: function () {
      let $this = this
      $this.loading = true
      tracemgrApi['abnormalOrderApi'].excelExport(this.queryParas).then(res => {
        if (res.success) {
          fileApi.file.download({ keyId: res.data }).then(res => {
            downFile(res)
            $this.loading = false
          }).catch(() => {
            $this.loading = false
          })
        } else {
          $this.loading = false
          $this.error(this.$i18n.messages[this.$i18n.locale].ladingManageList.exportFaile)
        }
      }).catch(() => {
        $this.loading = false
      })
    },
    resetData () {
      for (const item of this.formTableData.sourceData) {
        item.memo = item.memoCopy
        item.estimatedFinishTime = item.estimatedFinishTimeCopy
      }
    },
    saveStatusChange (e1) {
      if (this.userHaveFocus) {
        this.$emit('setNeedSave', true)
      }
    },
    getTableData () {
      this.$emit('setNeedSave', false)
      this.userHaveFocus = false
    },
    getFocus () {
      this.userHaveFocus = true
    }
  },
  computed: {
    api () {
      return tracemgrApi['abnormalOrderApi']
    }
  }
}
</script>

<style scoped>
  @import '~@/styles/tracemgr/factoringCommissioner/workbench/orderTrack/orderTrackList.scss'
</style>
