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

export const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    fixed: 'left',
    width: 100,
  },
  {
    title: '访客',
    align: 'left',
    width: 200,
    customRender({ record }) {
      return h('div', [
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          record.createUser,
        ),
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          record.ip,
        ),
        h(
          Tag,
          {
            color: 'processing',
          },
          {
            default: () => record.location,
          },
        ),
      ]);
    },
  },
  {
    title: '请求接口',
    align: 'left',
    width: 300,
    customRender({ record }) {
      return h('div', [
        h(
          Tag,
          {
            color: 'default',
            style: { marginBottom: '5px' },
          },
          {
            default: () => record.requestMethod,
          },
        ),
        h('div', '接口：' + record.url),
        h('div', '名称：' + record.title),
      ]);
    },
  },
  {
    title: '接口响应',
    align: 'left',
    width: 250,
    customRender({ record }) {
      return h('div', [
        h('span', '状态：'),
        h(
          Tag,
          {
            color: record.status == 0 ? 'success' : 'error',
            style: { marginBottom: '5px' },
          },
          {
            default: () => (record.status == 0 ? '正常' : '异常'),
          },
        ),
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          '请求耗时：' + record.consumeTime + 'ms',
        ),
        h('div', '响应时间：' + record.updateTime),
      ]);
    },
  },
  {
    title: '操作来源',
    align: 'left',
    width: 200,
    customRender({ record }) {
      return h('div', [
        h('div', '系统：' + record.os),
        h('div', '类型：' + record.typeText),
        h('div', '来源：' + record.sourceText),
      ]);
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    fixed: 'right',
    dataIndex: 'action',
    key: 'action',
    width: 200,
  },
];
