<template>
  <dialog-edit :visible.sync="dialogVisible"
               :title="$t('traceMgr.otherAbnormalOrders')"
               :editModel="'V'"
               :orderInfo="orderInfo"
               :api="api"
               width="70%" top="10%"
               :footerBtnShow="isFootView"
               :appendToBody="true"
               :saveLabel="$t('common.complete')">
    <div>
    <!--发票情况列表-->
    <data-table :sourceData.sync="sourceData"
                :columns="columns"
                :border="true"
                :cellStyle="cellStyle"
                :api="api"
                @getTableData="getDate"
                :stripe="false"
                :handleFlag.sync="handleFlag"
                :menuFlag="false"
                :loadPage="loadPage"
                :loadCount.sync="loadCount"
                :operateBtnLayout="operateBtnLayout"
                :queryParas="queryParas">
    </data-table>
  </div>
  </dialog-edit>
</template>

<script>
import { DialogEdit, DataTable, authButton } from 'newepoch-components'
import BasePage from '@/pages/basePage'
import tracemgrApi from '@/api/tracemgrApi'
import mixin from '@/pages/mixin'
export default {
  extends: new BasePage('otherAbnormalTaskPage'),
  mixins: [mixin],
  name: 'otherAbnormalTaskPage',
  components: {
    DialogEdit,
    DataTable,
    authButton
  },
  data () {
    return {
      isFootView: false,
      loadPage: 'getPage',
      handleFlag: true,
      sourceData: [],
      operateBtnLayout: '',
      loadCount: 0,
      columns: [
        {
          prop: 'product',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].common.productInformation,
          align: 'left',
          width: 100,
          slot: true
        }, {
          prop: 'assetCode',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.paymentConfirmNo,
          align: 'left',
          width: 100
        }, {
          prop: 'creditor',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].feedBackMain.creditor,
          align: 'left',
          width: 100
        }, {
          prop: 'xmgsName',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].feedBackMain.debtor,
          align: 'left',
          width: 100
        }, {
          prop: 'htName',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].feedBackMain.basicContractName,
          align: 'left',
          width: 100 }, {
          prop: 'factoringMoney',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.factoringMoney,
          align: 'left',
          width: 100 }, {
          prop: 'factoring',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.factoringCommissioner,
          align: 'left',
          width: 100 }, {
          prop: 'transDesc',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.descriptionProperty,
          align: 'left',
          width: 400 }, {
          prop: 'exceptionDesc',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalSituation,
          align: 'left',
          width: 100 }, {
          prop: 'solution',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].factoringBusinessInfo.zd_solution,
          align: 'left',
          width: 100 }, {
          prop: 'exceptionSolution',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].common.factoringSolutions,
          align: 'left',
          width: 100 }
      ],
      queryParas: {}
    }
  },
  props: {
    visible: {
      type: Boolean,
      default: function () {
        return false
      }
    },
    orderInfo: {
      type: Object
    }
  },
  computed: {
    dialogVisible: {
      get () {
        return this.visible
      },
      set (val) {
        this.$emit('update:visible', val)
      }
    },
    api () {
      return tracemgrApi['abnormalHandleApi']
    }
  },
  methods: {
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      return ''
    },
    getDate: function (data) {
      let $this = this
      $this.sourceData = data
      tracemgrApi['onlineAuditTaskDialog'].getOrderInfo($this.orderInfo.assetId).then(res => {
        $this.$nextTick(function () {
          let asset = res.data
          debugger
          let assetPaymentInfoDTO = asset.assetPaymentInfoDTO
          let assetPaymentPoolDTO = asset.assetPaymentPoolDTO
          let assetPaymentPoolOperDTO = asset.assetPaymentPoolOperDTO
          $this.sourceData.forEach(iten => {
            $this.$set(iten, 'creditor', assetPaymentInfoDTO.creditor)
            $this.$set(iten, 'xmgsName', assetPaymentInfoDTO.debtor)
            $this.$set(iten, 'htName', assetPaymentInfoDTO.bussContractName)
            $this.$set(iten, 'factoringMoney', assetPaymentInfoDTO.factoringMoney)
            debugger
            $this.$set(iten, 'transDesc', $this.orderInfo.caichan)
            $this.$set(iten, 'product', assetPaymentPoolDTO.projectName)
            $this.$set(iten, 'region', assetPaymentPoolOperDTO.coreAreaName)
            $this.$set(iten, 'factoring', assetPaymentPoolOperDTO.customerAccountName)
          })
        })
      }, res => {
        this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.getorderInfoFial)
      })
    }
  },
  watch: {
    dialogVisible: {
      handler: function (val) {
        if (val) {
          let $this = this
          $this.$nextTick(function () {
            $this.queryParas = $this.orderInfo
            $this.queryParas['pageIndex'] = 1
            $this.queryParas['pageSize'] = 10
            $this.handleFilter()
          })
        }
      }
    }
  }
}
</script>

<style scoped>
  @import '~@/styles/tracemgr/factoringCommissioner/taskTable/chinaClear/invoiceList.scss'
</style>
