import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    title: '日志标题',
    dataIndex: 'title',
    width: 100,
  },
  {
    title: '日志类型',
    dataIndex: 'type',
    width: 100,
    customRender({ record }) {
      let typeText = '';
      switch (record.type) {
        case 1:
          typeText = '登录';
          break;
        case 2:
          typeText = '注册';
          break;
        case 3:
          typeText = '找回密码';
          break;
        case 4:
          typeText = '业务';
          break;
        case 5:
          typeText = '其他';
          break;
        default:
          break;
      }
      return h('span', typeText || '-');
    },
  },
  {
    title: '模板编号',
    dataIndex: 'code',
    width: 100,
  },
  {
    title: '接收人邮箱',
    dataIndex: 'receiveEmail',
    width: 100,
  },
  {
    title: '接收人类型',
    dataIndex: 'status',
    width: 100,
    customRender({ record }) {
      let typeText = '';
      switch (record.receiveType) {
        case 1:
          typeText = '系统用户';
          break;
        case 2:
          typeText = '会员用户';
          break;
        case 3:
          typeText = '其他';
          break;
        default:
          break;
      }
      return h('span', typeText || '-');
    },
  },
  {
    title: '请求耗时',
    dataIndex: 'consumeTime',
    width: 100,
  },
  {
    title: '日志状态',
    dataIndex: 'status',
    width: 100,
    customRender({ record }) {
      return h('span', record.status === 1 ? '已读' : '未读');
    },
  },
  {
    title: '创建人',
    dataIndex: 'createUser',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    fixed: 'right',
    dataIndex: 'action',
    key: 'action',
    width: 200,
  },
];
