<!-- 线下审核发票信息 -->
<template>
  <div class="invoice">
    <dym-form :componentList="componentList" :formValue="form"></dym-form>
    <data-table :api="api" :handleFlag.sync="handleFlag" :queryParas="queryParas" ref="invoiceTable"
                :sourceData.sync="sourceData" :loadCount.sync="loadCount" :columns="columns" operateBtnLayout=""
                @getTableData="getTableData">
    </data-table>
    <div class="bottomDiv">
      <span class="span1">{{$t('taskManage.todoTask.invoiceTotalAmount') + '：'}}{{invoiceAmounts | thousandFilter}}</span>
      <span class="span2">{{$t('taskManage.todoTask.accountsTotalReceivable') + '：'}}{{usedAmounts | thousandFilter}}</span>
    </div>
  </div>
</template>
<script>
import BasePage from '@/pages/basePage.js'
import { dymForm, DataTable } from 'newepoch-components'
import * as format from '@/filters'
import taskManageApi from '@/api/dataAudit/taskManageApi.js'
export default {
  extends: new BasePage(),
  components: {
    dymForm,
    DataTable
  },
  data () {
    return {
      form: {},
      queryParas: {
        pageIndex: 1,
        pageSize: 10,
        assetInfoId: ''
      },
      // 发票金额合计
      invoiceAmounts: 0,
      // 应收账款合计
      usedAmounts: 0,
      sourceData: [],
      componentList: [
        // 基础商务合同编号
        {
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.basicBusinessContractNumber,
          value: 'basicContractCode',
          disabled: true,
          componentName: 'el-input',
          cols: [24, 24, 24, 8],
          labelWidth: '126px',
          prop: 'basicContractCode'
        },
        // 基础商务合同名称
        {
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.basicBusinessContractName,
          value: 'basicContractName',
          disabled: true,
          componentName: 'el-input',
          cols: [24, 24, 24, 8],
          labelWidth: '126px',
          prop: 'basicContractName'
        },
        // 基础合同类别
        {
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.basicContractType,
          value: 'contractType',
          disabled: true,
          componentName: 'el-select',
          cols: [24, 24, 24, 8],
          labelWidth: '100px',
          prop: 'contractType'
        }
      ],
      columns: [
        // 发票号码
        {
          prop: 'invoiceNo',
          align: 'right',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.invoiceNumber
        },
        // 票据名称
        {
          prop: 'invoiceName',
          align: 'left',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.invoiceName
        },
        // 开票日期
        {
          prop: 'openDate',
          align: 'center',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.invoiceDate,
          format: (row) => { return format.formatDate(row.openDate) }
        },
        // 发票金额
        {
          prop: 'invoiceAmount',
          align: 'right',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.invoiceAmount,
          format: (row) => { return format.thousandFilter(row.invoiceAmount) }
        },
        // 应收账款金额
        {
          prop: 'usedAmount',
          align: 'right',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.accountsReceivable,
          format: (row) => { return format.thousandFilter(row.usedAmount) }
        },
        // 发票备注
        {
          prop: 'remark',
          align: 'left',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.invoiceRemark,
          format: (row) => { return this.UtilJs.isEmpty(row.remark) ? '-' : row.remark }
        },
        // 查验结果
        {
          prop: 'lastCheckResult',
          align: 'left',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].taskManage.todoTask.checkResult,
          format: (row) => { return this.UtilJs.isEmpty(row.lastCheckResult) ? '-' : row.lastCheckResult }
        }
      ]
    }
  },
  computed: {
    api () {
      return taskManageApi.invoice
    }
  },
  methods: {
    loadFormData (auditOfflineInfoId) {
      let _this = this
      taskManageApi.offLine.getPayCodeInfo({ auditOfflineInfoId: auditOfflineInfoId }).then(res => {
        if (res && res.data) {
          _this.form = Object.assign({}, res.data)
          _this.form.contractType = format.formatDict(_this.form.contractType, 'ZD0107')
        }
      })
    },
    loadData (assetInfoId) {
      let _this = this
      _this.queryParas.assetInfoId = assetInfoId
      _this.$refs.invoiceTable.loadTableData()
    },
    getTableData (list) {
      let _this = this
      if (list.length === 0) {
        _this.invoiceAmounts = 0
        _this.usedAmounts = 0
      } else {
        _this.invoiceAmounts = list[0].invoiceAmounts
        _this.usedAmounts = list[0].usedAmounts
      }
    }
  }
}
</script>
<style scoped lang="scss" src="@/styles/dataAudit/taskManage/invoice.scss">
</style>>
