// 快递接收信息
<template>
  <data-table operateBtnLayout
              :columns="columns"
              :sourceData.sync="sourceData"
              :showPage="false">
  </data-table>
</template>
<script>
import { DataTable } from 'newepoch-components'
import * as format from '@/filters/index'
import factoringBusinessInfoApi from '@/api/factoringBusinessInfoApi'
export default {
  components: {
    DataTable
  },
  props: {
    queryData: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    const { factoringBusinessInfo } = this.$i18n.messages[this.$i18n.locale]
    return {
      queryParas: {
        assetInfoId: null
      },
      sourceData: [
        // {
        //   receive_time: 2209017600000,
        //   express_num: 123456,
        //   express_company: '顺丰',
        //   logistics_info: '已抵达成都',
        //   receipt: '张三',
        //   receice_file: '文件1',
        //   receive_num: 6
        // },
        // {
        //   receive_time: 2209017600000,
        //   express_num: 123456,
        //   express_company: '顺丰',
        //   logistics_info: '已抵达成都',
        //   receipt: '李四',
        //   receice_file: '文件1',
        //   receive_num: 6
        // }
      ],
      columns: [
        // 快递单号
        {
          prop: 'expressNo',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.express_num
        },
        // 快递公司
        {
          prop: 'expressCompany',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.express_company
        },
        // 物流信息
        {
          prop: 'logistic',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.logistics_info
        },
        // 接收人
        {
          prop: 'receiver',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.receipt
        },
        // 接收时间
        {
          prop: 'receiveDate',
          align: 'center',
          width: '110px',
          label: factoringBusinessInfo.receive_time,
          format: row => format.formatDatetime(row.receiveDate)
        },
        // 接收文件
        {
          prop: 'fileName',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.receice_file
        },
        // 接收份数
        {
          prop: 'receiveSource',
          align: 'right',
          width: '110px',
          label: factoringBusinessInfo.receive_num
        }
      ]
    }
  },
  mounted () {
    this.queryParas.assetInfoId = this.queryData.assetInfoId
    // this.handleFilter()
  },
  methods: {
    handleFilter () {
      factoringBusinessInfoApi.searchApi.expressReceive(this.queryParas).then(res => {
        if (res && res.data) {
          let receiceData = res.data
          this.sourceData = receiceData.map((value) => ({
            expressNo: value.expressNo,
            expressCompany: value.expressCompany === 1 ? '圆通' : value.expressCompany === 2 ? '顺丰' : '德邦',
            logistic: value.logistic,
            receiver: value.receiver,
            receiveDate: value.receiveDate,
            fileName: value.fileName,
            receiveSource: value.receiveSource
          }))
          // this.sourceData = res.data
        }
      })
    }
  },
  watch: {
    'queryData.assetInfoId': {
      handler: function (val) {
        this.queryParas.assetInfoId = val
      },
      immediate: true
    }
  }

}
</script>
