import { h } from 'vue';
import { NTag } from 'naive-ui';

export const columns = [
  {
    title: '序号',
    dataIndex: 'id',
    key: 'id',
    width: 100,
  },
  {
    title: '平账类型',
    dataIndex: 'type',
    key: 'type',
    render(row) {
      return row.type === 1 ? '米大师' : '未知';
    },
    width: 100,
  },
  {
    title: '玩家ID',
    dataIndex: 'user_id',
    key: 'user_id',
    width: 100,
  },
  {
    title: '玩家openid',
    dataIndex: 'openid',
    key: 'openid',
    width: 180,
  },
  {
    title: '平账金额(分)',
    dataIndex: 'balance',
    key: 'balance',
    width: 150,
    render(row) {
      return row.balance;
    },
  },
  {
    title: '平账单号',
    dataIndex: 'order_sn',
    key: 'order_sn',
    width: 240,
  },
  {
    title: '操作人ID',
    dataIndex: 'created_by',
    key: 'created_by',
    width: 100,
  },
  {
    title: '响应结果',
    dataIndex: 'response',
    key: 'response',
    render(row) {
      return row.response;
    },
    width: 80,
  },
  {
    title: '错误信息',
    dataIndex: 'error',
    key: 'error',
    render(row) {
      return row.error;
    },
    width: 80,
  },
  {
    title: '平账状态',
    dataIndex: 'status',
    key: 'status',
    render(row) {
      return h(
        NTag,
        {
          style: {
            marginRight: '6px',
          },
          type: row.status === 1 ? 'info' : 'error',
          bordered: false,
        },
        {
          default: () => (row.status === 1 ? '成功' : '失败'),
        }
      );
    },
    width: 150,
  },
  {
    title: '创建时间',
    dataIndex: 'created_at',
    key: 'created_at',
    width: 160,
  },
];
