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

export const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    title: '通知标题',
    dataIndex: 'title',
    width: 300,
  },
  {
    title: '通知封面',
    dataIndex: 'cover',
    key: 'cover',
    width: 100,
    customRender({ record }) {
      return h(Avatar, {
        size: 48,
        src: record.cover,
        shape: 'square',
        fit: 'fill',
      });
    },
  },
  {
    title: '通知类型',
    dataIndex: 'type',
    width: 100,
    customRender({ record }) {
      return h(
        Tag,
        {
          color: record.type == 1 ? 'processing' : 'success',
        },
        {
          default: () => (record.type == 1 ? '通知' : '公告'),
        },
      );
    },
  },
  {
    title: '通知状态',
    dataIndex: 'status',
    width: 100,
    customRender({ record }) {
      return h(
        Tag,
        {
          color: record.status == 1 ? 'success' : 'error',
        },
        {
          default: () => (record.status == 1 ? '正常' : '禁用'),
        },
      );
    },
  },
  {
    title: '点击率',
    dataIndex: 'clickNum',
    width: 100,
  },
  {
    title: '创建人',
    dataIndex: 'createUser',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    width: 200,
    fixed: 'right',
    key: 'action',
    dataIndex: 'action',
  },
];
