<template>
  <dialog-edit :visible.sync="dialogVisible"
               :title="$t('common.chinaClearExceptionHandling')"
               :editModel="'V'"
               :form="form"
               append-to-body
               :api="api"
               :footerBtnShow="isFootView"
               :appendToBody="true"
               autoClose
               @close="handleClose"
               :saveLabel="$t('common.complete')"
               :before-close="handleClose">
    <el-row>
      <payment-info :keyId="formData.assetInfoId" :title="$t('traceMgr.orderInfo')"></payment-info>
    </el-row>
    <!--发票情况列表 -->
    <div>
      <div  class="textRight handle-divider-style">
        <el-row>
          <el-button size="medium" type="primary" class="iconfont iconxiangqing1"  @click="openInvoiceAssignment"  v-if="oponMess"> {{$t('traceMgr.invoiceDil')}}</el-button>
          <el-button size="medium" :class="oponMess?'el-icon-arrow-down':'el-icon-arrow-up'" circle  @click="changeButton()"> </el-button>
        </el-row>
      </div>
      <div  class="handle-text-margin-bottom title">
        <div class="handle-text-margin-bottom-supplier">
          <span    >{{$t('traceMgr.invoiceStatusList')}}</span>
        </div>
        <el-divider></el-divider>
      </div>
    </div>
<!--    上面是页头 -->
    <data-table :cellStyle="cellStyle"  :stripe="true" v-if="oponMess"
                :api="api" :handleFlag.sync="handleFlag" :border="true" :showPage="false" :menuFlag="false"
                :queryParas="queryParas" @getTableData="tableData" :sourceData.sync="sourceData" :loadPage="loadPage"
                :loadCount.sync="loadCount" :columns="columns" :operateBtnLayout="operateBtnLayout"
    >
    </data-table>
    <div  v-for="(item,index,key) in abnormalHandleTableList" :key="key">
      <abnormalHandleList :synchronizationObj="synchronizationObj"
                          :addAbnormalHandleFormData="addAbnormalHandleFormData"
                          :checkCheckboxAndData="checkCheckboxAndData"
                          :resetData="resetData"
                          :index="index"
                          :fileIdList="abnormalHandleTableList[0][4].szProjectSuspiciousReturnApiDtos[index].registrationFiles"
                          :createAbnormalList="createAbnormalList"
                          :colseAbnormalHandle="colseAbnormalHandle"
                          :loading="loading"
                          :requestAssistance="requestAssistance"
                          :addCheckboxList="addCheckboxList"
                          :checkboxList="checkboxList"
                          :openOtherAbnormal="openOtherAbnormal"
                          :checkboxs="checkboxs"
                          :sign="sign"
                          :submitCheck="submitCheck"
                          :toHandleClose="toHandleClose"
                          :getMessages="getMesages"
                          :abnormalHandleTableList="item"
                          :homePageResetDataList="homePageResetDataList">
      </abnormalHandleList>
    </div>
    <!--话术-->
    <el-row>
      <el-row class="title"   v-if="employees.length > 0">
        <el-col :span="2"><span>{{$t('common.contact')}}：</span></el-col><br/>
      </el-row>
      <el-row class="marginBottom2 title paddingLeft20">
        <el-col  :span="10" v-for="(employee,index) in employees" :key="index">
          <el-col :span="3"><span>&nbsp;</span></el-col>
          <span v-if="employee.employeeName">{{employee.employeeName}}</span>
          <span v-if="employee.telephone">-{{employee.telephone}}</span>
          <span v-if="employee.account">-{{employee.account}}</span>
        </el-col>
      </el-row>
      <!--话术组件-->
      <el-row class="body_msg">
        <el-col :span="1" class="text-center">
          <span>{{$t('common.discourse')}}</span>
        </el-col>
        <el-col :span="10">
          <speech-craft-input :defaultSpeechFlag="false" @defaultSpeech="getDiscourse"  :autosize="autosize" v-model="discourse" ></speech-craft-input>
        </el-col>
      </el-row>
    </el-row>

    <el-row>

      <div class="copy_bt">
        <div  class="handle-text-margin-bottom title">
          <div class="handle-text-margin-bottom-supplier">
            <span    >{{$t('common.followUpStatus')}}</span>
          </div>
          <el-divider></el-divider>
        </div>
      </div>

    </el-row>
    <div class="copy_bt row-left">
      <el-form :size="'small'" :show-message="false" :model="this.formData" :rules="rules"   validate-on-rule-change  ref="form" label-width="125px">
    <el-row>
      <el-col :span="8">
      <el-form-item   label-width="40%"  prop="possibleResolutionTime" class="el-form-item-size" :label="$t('traceMgr.possibleResolutionTime')+'：'">
      <el-date-picker
        type="date"
        size="mini"
        :picker-options="pickerOptions0"
        v-model="formData.possibleResolutionTime"
        :placeholder="$t('common.pleaseSelect')">
      </el-date-picker>
      </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
      <el-form-item prop="remarksOnAbnormalProgressDetails"  validate-on-rule-change  label-width="40%" class="el-form-item-size" :label="$t('common.remarksOnAbnormalProgressDetails')+'：'">
        <el-input size="mini" placeholder="" v-model="formData.remarksOnAbnormalProgressDetails" maxlength="50">
        </el-input>
      </el-form-item>
      </el-col>
    </el-row>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="save()" :loading="saveLoding" size="medium" type="primary">{{$t('common.save')}}</el-button>
      <el-button @click="submit()" :loading="submitLoading" size="medium" type="primary">{{$t('common.complete')}}</el-button>
      <el-button size="medium" @click="handleClose">{{$t('common.close')}}</el-button>
    </div>
    <other-abnormal-task :visible.sync="otherAbnormal"  :orderInfo="orderInfo"  > </other-abnormal-task>
    <invoiceAssignmentEdit :dialogAttrs="dialogAttrs" :visible.sync="invoiceAssignment" :assetInfoId="assetInfoId"></invoiceAssignmentEdit>
  </dialog-edit>
</template>
<script>
import { DataTable, btnDownload, btnUpload, paymentInfo, speechCraftInput, authButton, DialogEdit, invoiceAssignmentEdit } from 'newepoch-components'
import tracemgrApi from '@/api/tracemgrApi.js'
import BasePage from '@/pages/basePage'
import businessFileDownloadDialog from '@/components/tracemgr/common/businessFileDownloadDialog.vue'
import abnormalHandleList from '@/components/tracemgr/factoringCommissioner/taskTable/abnormalHandle/abnormalHandleList'
import otherAbnormalTask from '@/components/tracemgr/factoringCommissioner/taskTable/abnormalHandle/otherAbnormalTaskPage'
import { UPLOAD_API } from '@/constant.js'
import fileApi from '@/api/fileApi'
import { downFile } from '@/utils/devUtils'
import * as format from '@/filters/index'
import mixin from '@/pages/mixin'
export default {
  extends: new BasePage('fileList'),
  mixins: [mixin],
  name: 'fileList',
  props: {
    visible: {
      type: Boolean
    },
    form: {
      type: Object
    },
    assetInfoId: {
      type: String
    },
    signFign: {
      type: String
    }
  },
  components: {
    DataTable,
    fileApi,
    DialogEdit,
    downFile,
    businessFileDownloadDialog,
    format,
    speechCraftInput,
    paymentInfo,
    otherAbnormalTask,
    invoiceAssignmentEdit,
    tracemgrApi,
    abnormalHandleList,
    authButton,
    UPLOAD_API,
    btnDownload,
    btnUpload
  },
  data () {
    return {
      uploadApi: UPLOAD_API,
      loadCount: 0,
      oponMess: true,
      loading: true,
      toHandleClose: false,
      sign: '',
      dialogAttrs: {
        appendToBody: true
      },
      formData: {
        assetInfoId: '',
        possibleResolutionTime: '',
        remarksOnAbnormalProgressDetails: ''
      },
      submitRow: [],
      requestAssistance: {
        'assetInfoId': ''
      },
      rules: {
        possibleResolutionTime: [
          { required: true }
        ],
        remarksOnAbnormalProgressDetails: [
          { required: true }
        ]
      },
      isFootView: false,
      showBusinessFileDownloadDialogValue: false,
      queryParas: {},
      resetData: false,
      abnormalHandleFormRow: [],
      list: [],
      employees: [],
      invoiceAssignment: false,
      fileIdList: [],
      fileIdToSaveMess: '',
      checkboxs: false,
      abnormalHandleTableList: [],
      saveLoding: false,
      submitLoading: false,
      submitCheck: false,
      checkboxList: 0,
      checkCheckboxAndData: false,
      synchronizationObj: {
        taskIdListLength: 0,
        index: 0
      },
      orderInfo: {},
      loadingOff: false,
      otherAbnormal: false,
      assetCode: '',
      assetInfomations: {},
      customerAccountName: '',
      // 设置只能选择当前日期及之后的日期
      pickerOptions0: {
        disabledDate (time) {
          return time.getTime() < Date.now() - 8.64e7// 如果没有后面的-8.64e7就是不可以选择今天的
        } },
      userInfo: {},
      colseAbnormalHanleList: [],
      num: '',
      uploadStatus: 0,
      rowSpan: '',
      szProjectSuspicious: [],
      operateBtnLayout: '',
      loadPage: 'getInvoiceList',
      taskId: '',
      bussCon: '',
      submitInfo: false,
      factoringMoney: '',
      autosize: {
        minRows: 8,
        maxRows: 10
      },
      handleFlag: true,
      discourse: '',
      sourceData: [],
      columns: [
        // 发票代码
        {
          prop: 'invoiceCode',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.invoiceCode,
          width: 100
        },
        //  发票号码
        {
          prop: 'invoiceNo',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.invoiceNum,
          width: 100 },
        //  开票日期
        {
          prop: 'openDateOfString',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.billingDate,
          width: 100 },
        //  发票金额
        {
          prop: 'invoiceAmount',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.invoiceAmount,
          width: 100 },
        //  应收款金额(抵扣金额)
        {
          prop: 'usedAmount',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.deductibleAmount,
          width: 100 },
        //  剩余可抵扣金额(包含该发票在本订单中的抵扣金额)
        {
          prop: 'taxExcludingAmount',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.remainingDeductibleAmountInclude,
          width: 100 }
      ]
    }
  },
  computed: {
    api () {
      return tracemgrApi['abnormalHandleApi']
    },
    dialogVisible: {
      get: function () {
        return this.visible
      },
      set: function (val) {
        this.$emit('update:visible', val)
      }
    }
  },
  watch: {
    visible: {
      handler: function (newValue) {
        let $this = this
        if (newValue) {
          $this.sourceData = []
          $this.abnormalHandleTableList = []
          $this.resetData = false
          $this.$nextTick(function () {
            let $this = this
            $this.queryParas['assetId'] = $this.assetInfoId
            $this.handleFilter()
            $this.getAssetInfoByKeyId()
            $this.formData.assetInfoId = $this.assetInfoId
            $this.requestAssistance.assetInfoId = $this.assetInfoId
            tracemgrApi['abnormalHandleApi'].getAbnormalTaskList({ 'assetId': $this.formData.assetInfoId, 'signFign': $this.signFign }).then(table => {
              if (table.data) {
                let taskIds = ''
                for (let i = 0; i < table.data.length; i++) {
                  if (i + 1 === table.data.length) {
                    taskIds = taskIds + table.data[i][4].taskId
                  } else {
                    taskIds = taskIds + table.data[i][4].taskId + ','
                  }
                }
                tracemgrApi['taskList'].abnormalHandleClaim({ 'taskId': taskIds }).then(res => {
                })
              }

              $this.$set($this, 'abnormalHandleTableList', table.data)
              $this.$set($this.formData, 'remarksOnAbnormalProgressDetails', table.data[0][4].memo)
              $this.formData.remarksOnAbnormalProgressDetails = table.data[0][4].memo
              if (table.data[0][4].estimatedFinishTime && table.data[0][4].estimatedFinishTime > 1577808000) {
                $this.$set($this.formData, 'possibleResolutionTime', table.data[0][4].estimatedFinishTime)
              } else {
                $this.$set(table.data[0][4], 'estimatedFinishTimeCopy', '')
              }
              $this.getDiscourse()
              $this.$set($this.formData, 'szProjectSuspicious', table.data[0][4].szProjectSuspiciousReturnApiDtos)
              $this.resetData = !$this.resetData
              $this.$nextTick(() => {
                $this.$refs['form'].clearValidate()
              })
            }, res => {
              $this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.getAbnormalHandleFail)
            })
          })
        } else {
          $this.formData = {}
          $this.abnormalHandleTableList = []
          $this.resetData = !$this.resetData
          $this.$nextTick(() => {
            $this.resetData = !$this.resetData
            $this.$refs['form'].clearValidate()
          })
        }
      }
    }
  },
  methods: {
    changeButton () { this.oponMess = !this.oponMess },
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      return ''
    },
    tableData (data) {
      this.sourceData = data
    },
    closeDialog () {
      this.dialogVisible = false
    },
    handleClose (done) {
      if (!this.dialogVisible) {
        return
      }
      if (this.abnormalHandleTableList.length === 0) {
        this.dialogVisible = false
      }
      this.colseAbnormalHanleList = []
      this.synchronizationObj.index = 0
      this.synchronizationObj.taskIdListLength = this.abnormalHandleTableList.length
      this.toHandleClose = !this.toHandleClose
    },
    getAssetInfoByKeyId () {
      // 获取联系人信息
      tracemgrApi['onlineAuditTaskDialog'].getEmployeeInfos({ 'assetCode': this.form.assetCode }).then(res => {
        this.employees = res.data
      })
    },
    save: function () {
      let $this = this
      if ($this.abnormalHandleTableList.length === 0) {
        $this.warning(this.$i18n.messages[this.$i18n.locale].traceMgr.NOHaveDataNotToSubmit)
        return
      }
      $this.saveLoding = true
      $this.submitRow = []
      $this.abnormalHandleFormRow = []
      $this.sign = ''
      this.checkboxList = 0
      $this.synchronizationObj.taskIdListLength = $this.abnormalHandleTableList.length
      $this.synchronizationObj.index = 0
      $this.sign = 'save'
      $this.checkboxs = !$this.checkboxs
    },
    addAbnormalHandleFormData (table, submitInfo, sign) {
      let $this = this
      if (!submitInfo && submitInfo) {
        $this.saveLoding = false
        $this.submitLoading = false
      }
      if (!submitInfo || !$this.submitInfo) {
        return
      }
      if (sign === 'save') {
        if ($this.synchronizationObj.index === $this.synchronizationObj.taskIdListLength) {
          $this.$refs['form'].validate((valid) => {
            if (valid) {
              let data = $this.abnormalHandleFormRow
              let resultData = []
              let exceId = []
              data.forEach(item => {
                let param = {
                  'estimatedFinishTime': $this.formData.possibleResolutionTime,
                  'assetInfoId': $this.formData.assetInfoId,
                  'taskType': '1',
                  'fileId': item.fileId === undefined ||
                  item.fileId === null || item.fileId === '' ? item.uploadFileId : item.fileId,
                  'solution': item.factoringProposal,
                  'isHelp': item.message,
                  'isOp': '1',
                  'signFign': $this.signFign,
                  'helpTaskId': item.helpTaskId,
                  'exceptionSolveFlag': item.exceptionSolveFlag,
                  'zdExceptionId': item.id,
                  'solveFlag': item.solveFlag,
                  'taskId': item.taskId,
                  'processInstanceId': item.processInstanceId,
                  'memo': $this.formData.remarksOnAbnormalProgressDetails,
                  'assetCode': item.assetCode
                }
                exceId.push(item.id)
                resultData.push(param)
              })

              let allParams = $this.abnormalHandleTableList
              allParams.forEach(item => {
                let mess = false
                exceId.forEach(id => {
                  if (item[4].id === id) {
                    mess = true
                  }
                })
                if (!mess) {
                  let param = {
                    'estimatedFinishTime': $this.formData.possibleResolutionTime,
                    'assetInfoId': $this.formData.assetInfoId,
                    'taskType': '1',
                    'fileId': item[4].fileId === undefined ||
                    item[4].fileId === null || item[4].fileId === '' ? item[4].uploadFileId : item[4].fileId,
                    'solution': item[4].factoringProposal,
                    'isHelp': item[4].message,
                    'isOp': '0',
                    'exceptionSolveFlag': item[4].exceptionSolveFlag,
                    'helpTaskId': item[4].helpTaskId,
                    'signFign': $this.signFign,
                    'zdExceptionId': item[4].id,
                    'uploadFileName': item[4].uploadFileName,
                    'taskId': item[4].taskId,
                    'solveFlag': item[4].solveFlag,
                    'assetCode': item[4].assetCode,
                    'dealStatus': '0',
                    'processInstanceId': item[4].processInstanceId,
                    'memo': $this.formData.remarksOnAbnormalProgressDetails
                  }
                  resultData.push(param)
                }
              })
              let result = $this.abnormalHandleTableList[0][4].szProjectSuspiciousReturnApiDtos
              tracemgrApi['abnormalHandleApi'].save({ 'abnormalHandleCerateInfoDtos': resultData, 'szProjectSuspiciousReturnApiDtos': result }).then(res => {
                if (res.data) {
                  $this.homePageResetDataList()
                  $this.saveLoding = false
                  $this.success($this.$i18n.messages[this.$i18n.locale].common.saveBtnSuccessfully)
                }
              }, res => {
                $this.saveLoding = false
                $this.error($this.$i18n.messages[this.$i18n.locale].common.saveError)
              })
            }
          })
        }
      }
      if (sign === 'submit') {
        if ($this.synchronizationObj.index === $this.synchronizationObj.taskIdListLength) {
          $this.$refs['form'].validate((valid) => {
            if (valid) {
              let data = $this.abnormalHandleFormRow
              let resultData = []
              let exceId = []
              data.forEach(item => {
                let param = {
                  'estimatedFinishTime': $this.formData.possibleResolutionTime,
                  'assetInfoId': $this.formData.assetInfoId,
                  'taskType': '1',
                  'fileId': item.fileId === undefined ||
                  item.fileId === null || item.fileId === '' ? item.uploadFileId : item.fileId,
                  'solution': item.factoringProposal,
                  'isHelp': item.message,
                  'helpTaskId': item.helpTaskId,
                  'signFign': $this.signFign,
                  'isOp': '1',
                  'zdExceptionId': item.id,
                  'uploadFileName': item.uploadFileName,
                  'exceptionSolveFlag': item.exceptionSolveFlag,
                  'taskId': item.taskId,
                  'solveFlag': '1',
                  'dealStatus': '1',
                  'assetCode': item.assetCode,
                  'processInstanceId': item.processInstanceId,
                  'memo': $this.formData.remarksOnAbnormalProgressDetails
                }
                exceId.push(item.id)
                resultData.push(param)
              })
              let allParams = $this.abnormalHandleTableList
              allParams.forEach(item => {
                let mess = false
                exceId.forEach(id => {
                  if (item[4].id === id) {
                    mess = true
                  }
                })
                if (!mess) {
                  let param = {
                    'estimatedFinishTime': $this.formData.possibleResolutionTime,
                    'assetInfoId': $this.formData.assetInfoId,
                    'taskType': '1',
                    'fileId': item[4].fileId === undefined ||
                    item[4].fileId === null || item[4].fileId === '' ? item[4].uploadFileId : item[4].fileId,
                    'solution': item[4].factoringProposal,
                    'isHelp': item[4].message,
                    'isOp': '0',
                    'exceptionSolveFlag': item[4].exceptionSolveFlag,
                    'helpTaskId': item[4].helpTaskId,
                    'signFign': $this.signFign,
                    'zdExceptionId': item[4].id,
                    'uploadFileName': item[4].uploadFileName,
                    'taskId': item[4].taskId,
                    'solveFlag': item[4].solveFlag,
                    'assetCode': item[4].assetCode,
                    'dealStatus': '0',
                    'processInstanceId': item[4].processInstanceId,
                    'memo': $this.formData.remarksOnAbnormalProgressDetails
                  }
                  resultData.push(param)
                }
              })
              let result = $this.abnormalHandleTableList[0][4].szProjectSuspiciousReturnApiDtos
              tracemgrApi['abnormalHandleApi'].submit({ 'abnormalHandleCerateInfoDtos': resultData, 'szProjectSuspiciousReturnApiDtos': result }).then(res => {
                if (res.data) {
                  $this.handleFilter()
                  tracemgrApi['abnormalHandleApi'].getAbnormalTaskList({ 'assetId': $this.formData.assetInfoId, 'signFign': $this.signFign }).then(table => {
                    $this.abnormalHandleTableList = table.data
                  }, res => {
                    $this.error($this.$i18n.messages[this.$i18n.locale].traceMgr.getAbnormalHandleFail)
                  })
                  $this.homePageResetDataList()
                  $this.resetData = !$this.resetData
                  $this.saveLoding = false
                  $this.submitLoading = false
                  $this.visible = false
                  $this.dialogVisible = false
                  $this.success($this.$i18n.messages[this.$i18n.locale].common.submittedSuccess)
                  $this.$emit('updateData')
                }
              }, res => {
                $this.saveLoding = false
                $this.submitLoading = false
                $this.error($this.$i18n.messages[this.$i18n.locale].common.submitFail)
              })
            }
          })
        }
      }
    },
    getMesages (message, config, sign, table, status) {
      let $this = this
      if (sign === 'save') {
        if (message.factoringProposals.length !== 0) {
          $this.list.push(message)
        } else if (status && message.factoringProposals.length === 0) {
          $this.abnormalHandleFormRow.push(table)
        }
        if (config) {
          let information = {
            eiditMess: [],
            factoringProposals: []
          }
          if ($this.list.length > 0) {
            $this.submitInfo = false
          }
          $this.list.forEach(item => {
            information.factoringProposals.push(item.factoringProposals)
          })
          let factoringProposals = ''
          if (information.factoringProposals[0] !== undefined) {
            information.factoringProposals.forEach((item, key) => {
              if (key === information.factoringProposals.length - 1) {
                factoringProposals += item
              } else {
                factoringProposals += item + '，'
              }
            })
            factoringProposals += $this.$i18n.messages[this.$i18n.locale].traceMgr.messageTips
            $this.saveLoding = false
            $this.warning(factoringProposals)
          }
          $this.list = []
        }
      }

      if (sign === 'submit') {
        if (message.eiditMess.length !== 0) {
          $this.list.push(message)
        } else if (status && message.eiditMess.length === 0) {
          $this.abnormalHandleFormRow.push(table)
        }
        if (config) {
          let information = {
            eiditMess: []
          }
          if ($this.list.length > 0) {
            $this.submitInfo = false
          }
          $this.list.forEach(item => {
            information.eiditMess.push(item.eiditMess)
          })
          let mess = ''

          if (information.eiditMess.length > 0) {
            if (information.eiditMess[0].length > 0) {
              information.eiditMess.forEach((item, key) => {
                if (key === information.eiditMess.length - 1) {
                  mess += item
                } else {
                  mess += item + '，'
                }
              })
              mess += $this.$i18n.messages[this.$i18n.locale].traceMgr.messageTips
              $this.submitLoading = false
              $this.warning(mess)
              $this.list = []
            }
          }
          $this.list = []
        }
      }
    },
    addCheckboxList (num, submitStauas, sign) {
      this.checkboxList += num
      if (submitStauas) {
        this.toSave(sign)
      }
    },
    toSave: function (sign) {
      let $this = this
      if (this.checkboxList === 0 && sign === 'submit') {
        this.warning($this.$i18n.messages[this.$i18n.locale].traceMgr.abnormal)
        $this.saveLoding = false
        $this.submitLoading = false
        return
      }
      $this.$refs['form'].validate((valid) => {})
      if ($this.formData.possibleResolutionTime === '' ||
          $this.formData.possibleResolutionTime === undefined ||
          $this.formData.possibleResolutionTime === null) {
        $this.saveLoding = false
        $this.submitLoading = false
        this.warning($this.$i18n.messages[this.$i18n.locale].traceMgr.resolutionTime)
        return
      }
      if ($this.formData.remarksOnAbnormalProgressDetails === '' ||
          $this.formData.remarksOnAbnormalProgressDetails === undefined ||
          $this.formData.remarksOnAbnormalProgressDetails === null) {
        this.warning($this.$i18n.messages[this.$i18n.locale].traceMgr.remark)
        $this.saveLoding = false
        $this.submitLoading = false
        return
      }
      if (sign === 'save') {
        $this.submitInfo = true
        $this.synchronizationObj.taskIdListLength = $this.abnormalHandleTableList.length
        $this.synchronizationObj.index = 0
        $this.checkCheckboxAndData = !$this.checkCheckboxAndData
      }
      if (sign === 'submit') {
        $this.submitInfo = true
        $this.synchronizationObj.taskIdListLength = $this.abnormalHandleTableList.length
        $this.synchronizationObj.index = 0
        $this.submitCheck = !$this.submitCheck
      }
    },
    submit: function () {
      let $this = this
      if ($this.abnormalHandleTableList.length === 0) {
        $this.warning($this.$i18n.messages[this.$i18n.locale].traceMgr.NOHaveDataNotToSubmit)
        return
      }
      $this.abnormalHandleFormRow = []
      $this.sign = ''
      $this.submitLoading = true
      this.checkboxList = 0
      $this.synchronizationObj.taskIdListLength = $this.abnormalHandleTableList.length
      $this.synchronizationObj.index = 0
      $this.sign = 'submit'
      $this.checkboxs = !$this.checkboxs
    },
    homePageResetDataList: function (assetId) {
      let $this = this
      tracemgrApi['abnormalHandleApi'].getAbnormalTaskList({ 'assetId': $this.formData.assetInfoId, 'signFign': $this.signFign }).then(table => {
        $this.$set($this, 'abnormalHandleTableList', table.data)
        console.log('possibleResolutionTime:' + table.data[0][4].estimatedFinishTime + table.data[0][4].estimatedFinishTime > 1577808000)
        if (table.data[0][4].estimatedFinishTime && table.data[0][4].estimatedFinishTime > 1577808000) {
          $this.$set($this.formData, 'possibleResolutionTime', table.data[0][4].estimatedFinishTime)
        } else {
          $this.$set(table.data[0][4], 'estimatedFinishTimeCopy', '')
        }
        $this.$set($this.formData, 'remarksOnAbnormalProgressDetails', table.data[0][4].memo)
        this.$nextTick(() => {
          this.$refs['form'].clearValidate()
        })
        $this.resetData = !$this.resetData
      }, res => {
        $this.error($this.$i18n.messages[this.$i18n.locale].traceMgr.getAbnormalHandleFail)
      })
    },
    openOtherAbnormal: function (row) {
      this.orderInfo['assetCode'] = row.assetCode
      this.orderInfo['creditor'] = row.creditor
      this.orderInfo['caichan'] = ''
      this.orderInfo['djzmNum'] = row.djzmNum
      this.orderInfo['Id'] = row.id
      this.orderInfo['assetId'] = this.formData.assetInfoId
      this.otherAbnormal = true
    },
    colseAbnormalHandle: function (obj) {
      let $this = this
      let editMessage = false
      if (obj.taskIdListLength !== obj.index) {
        return
      }
      let item = this.colseAbnormalHanleList
      if (item === undefined || item === null || item.length === 0) {
        this.dialogVisible = false
        return
      }
      item.forEach(data => {
        if (data !== undefined) {
          if (data.estimatedFinishTime === null || data.estimatedFinishTime === undefined || data.estimatedFinishTim === '') {
            data.estimatedFinishTime = undefined
          }
          if (data.estimatedFinishTimeCopy === null || data.estimatedFinishTimeCopy === undefined || data.estimatedFinishTimeCopy === '') {
            data.estimatedFinishTimeCopy = undefined
          }
          if (data.factoringProposal === null || data.factoringProposal === undefined || data.factoringProposal === '') {
            data.factoringProposal = undefined
          }
          if (data.factoringProposalCopy === null || data.factoringProposalCopy === undefined || data.factoringProposalCopy === '') {
            data.factoringProposalCopy = undefined
          }

          if (data.memo === null || data.memo === undefined || data.memo === '') {
            data.memo = undefined
          }
          if (data.memoCopy === null || data.memoCopy === undefined || data.memoCopy === '') {
            data.memoCopy = undefined
          }
          if (data.uploadFileId === null || data.uploadFileId === undefined || data.uploadFileId === '') {
            data.uploadFileId = undefined
          }
          if (data.factoringProposal !== data.factoringProposalCopy) {
            editMessage = true
          }
          if (data.uploadFileId !== undefined) {
            editMessage = true
          }
        }
      })
      if ($this.formData.possibleResolutionTime === null || $this.formData.possibleResolutionTime === undefined || $this.formData.possibleResolutionTime === '') {
        $this.formData.possibleResolutionTime = undefined
      }
      if ($this.formData.remarksOnAbnormalProgressDetails === null || $this.formData.remarksOnAbnormalProgressDetails === undefined || $this.formData.remarksOnAbnormalProgressDetails === '') {
        $this.formData.remarksOnAbnormalProgressDetails = undefined
      }
      if ($this.formData.possibleResolutionTime !== $this.abnormalHandleTableList[0][4].estimatedFinishTimeCopy) {
        editMessage = true
      }
      if ($this.formData.remarksOnAbnormalProgressDetails !== $this.abnormalHandleTableList[0][4].memoCopy) {
        editMessage = true
      }
      if (!editMessage) {
        this.dialogVisible = false
        return
      }
      var p = new Promise((resolve, reject) => {
        this.$confirm(this.$i18n.messages[this.$i18n.locale].traceMgr.TipsInfo, this.$i18n.messages[this.$i18n.locale].common.tip, {
          confirmButtonText: this.$i18n.messages[this.$i18n.locale].traceMgr.leaveInfo,
          cancelButtonText: this.$i18n.messages[this.$i18n.locale].approval.cancel,
          type: 'warning'
        }).then(() => {
          // 点击离开
          this.dialogVisible = false
          p.toString()
        }).catch(err => {
          reject(err)
        })
      })
    },
    createAbnormalList: function (row) {
      this.colseAbnormalHanleList.push(row)
    },
    openInvoiceAssignment: function () {
      this.invoiceAssignment = true
    },
    getDiscourse: function () {
      let $this = this
      tracemgrApi['orderTrackApi'].getPhone().then(info => {
        tracemgrApi['onlineAuditTaskDialog'].getOrderInfo($this.formData.assetInfoId).then(res => {
          let text = $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleOne
          text += res.data.assetPaymentInfoDTO.assetCode
          text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleTwo
          text += res.data.assetPaymentInfoDTO.bussContractName
          text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleThere
          text += res.data.assetPaymentInfoDTO.factoringMoney
          text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleFour
          let list = $this.abnormalHandleTableList
          list.forEach((item, key) => {
            if (list.length - 1 === key) {
              text += item[0].pledgeeAssignee
            } else {
              text += item[0].pledgeeAssignee + ','
            }
          })
          text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleFive
          list.forEach((item, key) => {
            text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleSix + item[2].propertyDescription + '\n'
            text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleSeven + item[2].proposal + '\n'
            text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleEight
          })
          text += $this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleContext

          // 保理专员
          text = text + $this.$i18n.messages[$this.$i18n.locale].traceMgr.four + res.data.assetPaymentPoolOperDTO.customerAccountName
          // 座机
          text = text + $this.$i18n.messages[$this.$i18n.locale].traceMgr.five
          // 手机
          text = text + $this.$i18n.messages[$this.$i18n.locale].traceMgr.six + info.data.mobile
          $this.discourse = text
        }, res => {
          this.error($this.$i18n.messages[$this.$i18n.locale].traceMgr.getorderInfoFial)
        })
      }, res => {
        this.error($this.$i18n.messages[$this.$i18n.locale].traceMgr.getUserInfoFial)
      })
    }
  }
}
</script>
<style scoped lang="scss">
  @import '~@/styles/tracemgr/factoringCommissioner/taskTable/abnormalHandle/taskDialog.scss';
</style>
