import { h } from 'vue';
import { ElTag } from 'element-plus';

export const columns = [
  {
    type: 'selection',
  },
  {
    label: 'ID',
    prop: 'id',
    fixed: 'left',
    width: 100,
  },
  {
    label: '访客',
    align: 'left',
    minWidth: 200,
    render(record) {
      return h('div', [
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          record.row.createUser,
        ),
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          record.row.ip,
        ),
        h(
          ElTag,
          {
            type: 'primary',
          },
          {
            default: () => record.row.location,
          },
        ),
      ]);
    },
  },
  {
    label: '请求接口',
    align: 'left',
    minWidth: 200,
    render(record) {
      return h('div', [
        h(
          ElTag,
          {
            type: 'info',
            style: { marginBottom: '5px' },
          },
          {
            default: () => record.row.requestMethod,
          },
        ),
        h('div', '接口：' + record.row.url),
        h('div', '名称：' + record.row.title),
      ]);
    },
  },
  {
    label: '接口响应',
    align: 'left',
    minWidth: 250,
    render(record) {
      return h('div', [
        h('span', '状态：'),
        h(
          ElTag,
          {
            type: record.row.status == 0 ? 'success' : 'danger',
            style: { marginBottom: '5px' },
          },
          {
            default: () => (record.row.status == 0 ? '正常' : '异常'),
          },
        ),
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          '请求耗时：' + record.row.consumeTime + 'ms',
        ),
        h('div', '响应时间：' + record.row.updateTime),
      ]);
    },
  },
  {
    label: '操作来源',
    align: 'left',
    minWidth: 200,
    render(record) {
      return h('div', [
        h('div', '系统：' + record.row.os),
        h('div', '类型：' + record.row.typeText),
        h('div', '来源：' + record.row.sourceText),
      ]);
    },
  },
  {
    label: '创建时间',
    prop: 'createTime',
    width: 180,
  },
];
