<template>
  <div>
    <data-table :menuFlag="false" :handleFlag.sync="handleFlag" :loadPage="loadPage"
                :queryParas="queryParas" :sourceData.sync="formTableData.sourceData" :border="true" :stripe="true"
                :loadCount.sync="loadCount" :columns="columns" :operateBtnLayout="operateBtnLayout"
                operatWidth="0px">
    </data-table>
  </div>
</template>
<script>
import BasePage from '@/pages/basePage'
import * as format from '@/filters/index'
import mixin from '@/pages/mixin'
import { DataTable, upDownLayout } from 'newepoch-components'
import tracemgrApi from '@/api/tracemgrApi'
export default {
  extends: new BasePage(),
  name: 'supplierModifyHistoryList',
  mixins: [mixin],
  components: {
    upDownLayout,
    format,
    DataTable
  },
  mounted () {
    this.handleFilter()
  },
  props: {
    creditorId: {
      type: String
    }
  },
  data: function () {
    return {
      isManager: false,
      styles: '',
      buttonDisable: false,
      needComplete: true,
      currentTotal: 0,
      loadPage: 'getLogList',
      loadCount: 0,
      operateBtnLayout: '',
      formTableData: {
        sourceData: []
      },
      showOperation: true,
      handleFlag: true,
      queryParas: {
        pageIndex: 1,
        pageSize: 10,
        id: this.creditorId
      },
      columns: [
        {
          prop: 'operateField',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.updateItem,
          showOverflowTooltip: true
        },
        {
          prop: 'operateBefore',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.modifyingValue,
          showOverflowTooltip: true
        },
        {
          prop: 'operateAfter',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.oldModifyingValue,
          showOverflowTooltip: true
        },
        {
          prop: 'operateUserName',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.updatePerson,
          showOverflowTooltip: true
        },
        {
          prop: 'modifyTime',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.updateTime,
          showOverflowTooltip: true,
          format: function (row) {
            let date = new Date(row.modifyTime)
            let y = date.getFullYear()
            let MM = date.getMonth() + 1
            MM = MM < 10 ? ('0' + MM) : MM
            let d = date.getDate()
            d = d < 10 ? ('0' + d) : d
            let h = date.getHours()
            h = h < 10 ? ('0' + h) : h
            let m = date.getMinutes()
            m = m < 10 ? ('0' + m) : m
            let s = date.getSeconds()
            s = s < 10 ? ('0' + s) : s
            return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
          }
        }
      ]
    }
  },
  computed: {
  },
  watch: {
  },
  methods: {
    searchData (val) {
      this.queryParas.id = val
      console.log(this.queryParas)
      this.isLoading = true
      return tracemgrApi['supplierDistributionApiList'].getLogList(this.queryParas).then(res => {
        this.formTableData.sourceData = res.data
        this.isLoading = false
      }, res => {
        this.isLoading = false
      })
      // this.val = []
    }
  }
}
</script>
