<template>
  <dialog-edit :visible.sync="dialogVisible"
               :title="$t('traceMgr.abnormalInfoDiltl')"
               :editModel="'V'"
               :form="form"
               append-to-body
               :api="api"
               :footerBtnShow="isFootView"
               :appendToBody="true"
               :saveLabel="$t('common.complete')">
    <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-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  class="handle-text-margin-bottom title">
      <div class="handle-text-margin-bottom-supplier">
        <span    >{{$t('traceMgr.abnormalSituationList')}}</span>
      </div>
      <el-divider></el-divider>
    </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="abnormalInfoColumns" :operateBtnLayout="operateBtnLayout"
                :loadList='loadList'>
    </data-table>
    <div slot="footer" class="dialog-footer">
      <el-button size="medium" @click="dialogVisible=false">{{$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 otherAbnormalTask from '@/components/tracemgr/regionalCommissioner/TaskTable/abnormalInfoList/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
    }
  },
  components: {
    DataTable,
    fileApi,
    DialogEdit,
    downFile,
    businessFileDownloadDialog,
    format,
    speechCraftInput,
    paymentInfo,
    otherAbnormalTask,
    invoiceAssignmentEdit,
    tracemgrApi,
    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,
      loadList: 'getAbnormalInfoList',
      saveLoding: false,
      submitLoading: false,
      submitCheck: false,
      checkboxList: 0,
      checkCheckboxAndData: false,
      synchronizationObj: {
        taskIdListLength: 0,
        index: 0
      },
      orderInfo: {},
      loadingOff: false,
      otherAbnormal: false,
      assetCode: '',
      assetInfomations: {},
      customerAccountName: '',
      // 设置只能选择当前日期及之后的日期
      userInfo: {},
      colseAbnormalHanleList: [],
      num: '',
      uploadStatus: 0,
      rowSpan: '',
      szProjectSuspicious: [],
      operateBtnLayout: '',
      loadPage: 'getInvoiceList',
      taskId: '',
      bussCon: '',
      submitInfo: false,
      factoringMoney: '',
      handleFlag: true,
      discourse: '',
      sourceData: [],
      abnormalInfoColumns: [
        //  登记编号
        {
          prop: 'djzmNum',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.theregistrationNumber,
          width: 100
        },
        //  登记日期
        {
          prop: 'registTime',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.recordDate,
          width: 100 },
        //  质权人/受让人
        {
          prop: 'registTime',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.pledgeeAssignee,
          width: 100 },
        //  交易类型
        {
          prop: 'bizType',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.pradeType,
          width: 100 },
        //  过期情况
        {
          prop: 'isExpire',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.overdueSituation,
          width: 100 },
        //  财产描述
        {
          prop: 'transDesc',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.descriptionProperty,
          width: 100 },
        // 异常情况
        {
          prop: 'exceptionDesc',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message22,
          width: 100
        },
        //  中登异常解决方案
        {
          prop: 'solution',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message23,
          width: 100 },
        //  反馈人
        {
          prop: 'fankuiUserName',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message24,
          width: 100 },
        //  反馈日期
        {
          prop: 'fankuiTime',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message25,
          width: 100 },
        //  解决状态
        {
          prop: 'dealStatus',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message26,
          width: 100 },
        //  审核意见
        {
          prop: 'exceptionReason',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message27,
          width: 100 },
        // 审核人
        {
          prop: 'dealUserName',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message28,
          width: 100 },
        //  审核时间
        {
          prop: 'dealTime',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.message29,
          width: 100 }
      ],
      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.$nextTick(function () {
            let $this = this
            $this.queryParas['assetId'] = $this.assetInfoId
            $this.handleFilter()
            $this.formData.assetInfoId = $this.assetInfoId
            $this.requestAssistance.assetInfoId = $this.assetInfoId
          })
        } else {
          $this.formData = {}
        }
      }
    }
  },
  methods: {
    changeButton () { this.oponMess = !this.oponMess },
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      return ''
    },
    tableData (data) {
      this.sourceData = data
    },
    closeDialog () {
      this.dialogVisible = false
    },
    openInvoiceAssignment: function () {
      this.invoiceAssignment = true
    },
    openOtherAbnormal: function (row) {
      this.orderInfo['assetCode'] = row.assetCode
      this.orderInfo['creditor'] = row.creditor
      this.orderInfo['caichan'] = row.caichan
      this.orderInfo['djzmNum'] = row.djzmNum
      this.orderInfo['Id'] = row.id
      this.orderInfo['assetId'] = this.formData.assetInfoId
      this.otherAbnormal = true
    }
  }
}
</script>
<style scoped lang="scss">
  @import '~@/styles/tracemgr/factoringCommissioner/taskTable/abnormalHandle/taskDialog.scss';
</style>
