<!-- 商家-砍价报表-->
<template>
  <el-dialog
    append-to-body
    :title="title"
    :visible.sync="dialogFormVisible"
    width="1000px"
    @close="close"
  >
    <el-table
      v-loading="listLoading"
      border
      :data="list"
      height="500"
      width="60%"
    >
      <el-table-column
        align="center"
        :label="__('砍价历史编号')"
        prop="ach_id"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        :label="__('砍价用户')"
        prop="user_id"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        :label="__('砍价用户昵称')"
        prop="user_nickname"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        :label="__('砍掉价格')"
        prop="ach_price"
        show-overflow-tooltip
        width="150px"
      />
      <el-table-column
        align="center"
        :label="__('商品编号')"
        prop="item_id"
        show-overflow-tooltip
        width="150px"
      />
      <el-table-column
        align="center"
        :formatter="formatDatetime"
        :label="__('砍价时间')"
        prop="ach_datetime"
        show-overflow-tooltip
        width="170px"
      />
    </el-table>
  </el-dialog>
</template>
<script>
  import { translateTitle as __ } from '@/utils/i18n'
  import { getList } from '@/api/activity/cutprice/history'
  import { renderTime } from '@/utils/date'

  export default {
    name: 'StoreActivityBuyItemTable',
    components: {},
    data() {
      return {
        list: [],

        listLoading: true,
        dialogFormVisible: false,
        title: '',
        layout: 'total, sizes, prev, pager, next, jumper',
        queryForm: {
          pageNum: 1,
          pageSize: 20,
        },
      }
    },
    created() {},
    methods: {
      __,
      showTable(row) {
        this.queryForm.ac_id = row.ac_id
        this.dialogFormVisible = true
        this.fetchData()
      },
      close() {
        this.queryForm = this.$options.data().queryForm
        this.dialogFormVisible = false
      },
      formatDatetime(row) {
        return renderTime(row.ach_datetime)
      },
      async fetchData() {
        this.listLoading = true
        const { data } = await getList(this.queryForm)
        this.list = data.items
        this.total = data.records
        this.listLoading = false

      },
    },
  }
</script>
