config.ts 880 Bytes
import { Tag } from 'ant-design-vue';
import { BasicColumn } from '/@/components/Table';
import { formatToDateTime } from '/@/utils/dateUtil';
import { h } from 'vue';

// 表格配置
export const columns: BasicColumn[] = [
  {
    title: '事件时间',
    dataIndex: 'createdTime',
    format(text) {
      return formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss');
    },
  },
  {
    title: '服务器',
    dataIndex: 'body.server',
  },
  {
    title: '事件',
    dataIndex: 'body.event',
  },
  {
    title: '状态',
    dataIndex: 'body.success',
    customRender: ({ record }) => {
      const color = record.body.success ? 'success' : 'error';
      const text = record.body.success ? '成功' : '失败';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '错误',
    dataIndex: 'error',
    slots: { customRender: 'errorDetail' },
  },
];