// 保理信息修改履历
<template>
  <data-table operateBtnLayout
              :columns="columns"
              :api="api"
              :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: {
    query: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  computed: {
    api () {
      return factoringBusinessInfoApi.searchApi
    }
  },
  mounted () {
    this.queryParas.assetInfoId = this.query.assetInfoId
    this.queryParas.assetPoolId = this.query.assetPoolId
    this.handleFilter()
  },
  data () {
    const { factoringBusinessInfo } = this.$i18n.messages[this.$i18n.locale]
    return {
      queryParas: {
        assetInfoId: null,
        assetPoolId: null
      },
      sourceData: [],
      columns: [
        // 修改项目
        {
          prop: 'columnName',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.modify_project
        },
        // 修改前
        {
          prop: 'preValue',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.modify_before
        },
        // 修改后
        {
          prop: 'modifiedValue',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.modify_after
        },
        // 修改时间
        {
          prop: 'addTime',
          align: 'center',
          width: '110px',
          label: factoringBusinessInfo.modify_time,
          format: row => format.formatDatetime(row.addTime)
        },
        // 修改人
        {
          prop: 'addUserName',
          align: 'left',
          width: '110px',
          label: factoringBusinessInfo.modify_person
        }
      ]
    }
  },
  methods: {
    handleFilter () {
      factoringBusinessInfoApi.searchApi.modifyList(this.queryParas).then(res => {
        if (res && res.data) {
          this.sourceData = res.data
        }
      })
    }
  },
  watch: {
    query (val) {
      this.queryParas.assetInfoId = val.assetInfoId
      this.queryParas.assetPoolId = val.assetPoolId
      this.handleFilter()
    }
  }
}
</script>
