<template>
  <div class="">
    <toolbar @on-filter="filterData" @on-reset="filterData" />

    <base-table
      class="m-10 bg-w p-20 br-10"
      :columns="columns"
      :items="items"
      :pagination="pagination"
      :page-change="pageChange"
    />
  </div>
</template>

<script>
import toolbar from './toolbar';
import mxFilterList from '@/mixins/filterList';
import { getList } from '@/api/statistics/withdrawalRecord';

export default {
  name: 'WithdrawalRecord',

  components: { toolbar },

  mixins: [
    mxFilterList({
      fetchList: getList // 在下方data再声明一个 fetchList: iGetList 同等效果
    })
  ],

  data() {
    return {
      columns: [
        {
          key: 'id',
          name: '提现编号',
          width: '160'
        },
        {
          key: 'accountName',
          name: '提现用户',
          width: '160'
        },
        {
          key: 'phonenumber',
          name: '手机号',
          width: '120'
        },
        {
          key: 'channels',
          name: '提现渠道',
          width: '120'
        },
        {
          key: 'value',
          name: '提现金额',
          minWidth: '80',
          render: (h, { row }) => h('span', `￥${row.value}`)
        },
        {
          key: 'auditStatus',
          name: '状态',
          width: '80',
          type: 'tag',
          fetchTagType: val => {
            switch (val) {
              case 1:
                return 'success';
              case 0:
                return 'info';
              case -1:
                return 'error';
              default:
                return 'info';
            }
          },
          tagName: row => {
            switch (row.auditStatus) {
              case 1:
                return '通过';
              case 0:
                return '待审核';
              case -1:
                return '拒绝';
              default:
                return '-';
            }
          }
        },
        {
          key: 'createAt',
          name: '提现时间',
          width: '140'
        },
        {
          key: 'action',
          name: '操作',
          width: '120',
          render: (h, { row }) => {
            const action = [];
            row.auditStatus !== 1 &&
              action.push(
                h(
                  'el-button',
                  {
                    props: {
                      type: 'text'
                    },
                    on: {
                      click: () =>
                        this.$WithdrawalRecordVerifyItemModal({
                          id: row.id,
                          auditStatus: row.auditStatus
                        })
                    }
                  },
                  '编辑'
                )
              );
            return h('div', action);
          }
        }
      ]
    };
  },
  created() {
    this.$g_on('withdrawal_record_reload', this.reload);
  },

  beforeDestroy() {
    this.$g_off('withdrawal_record_reload', this.reload);
  }
};
</script>

<style type="scss" scoped></style>
