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

export const columns = [
  {
    type: 'selection',
  },
  {
    label: 'ID',
    prop: 'id',
    width: 100,
  },
  {
    label: '通知标题',
    prop: 'title',
    width: 300,
  },
  {
    label: '通知封面',
    prop: 'cover',
    render(record) {
      return h(ElAvatar, {
        size: 48,
        src: record.row.cover,
        shape: 'square',
        fit: 'fill',
      });
    },
    width: 100,
  },
  {
    label: '通知类型',
    prop: 'type',
    // render(record) {
    //   return h('span', record.row.type === 1 ? '通知' : '公告');
    // },
    render(record) {
      return h(
        ElTag,
        {
          type: record.row.type == 1 ? 'primary' : 'warning',
        },
        {
          default: () => (record.row.type == 1 ? '通知' : '公告'),
        },
      );
    },
  },
  {
    label: '通知状态',
    prop: 'status',
    // render(record) {
    //   return h('span', record.row.status === 1 ? '正常' : '关闭')
    // },
    render(record) {
      return h(
        ElTag,
        {
          type: record.row.status ==1 ? 'success' : 'danger',
        },
        {
          default: () => (record.row.status ==1 ? '正常' : '禁用'),
        },
      );
    },
  },
  {
    label: '点击率',
    prop: 'clickNum',
  },
  {
    label: '创建人',
    prop: 'createUser',
  },
  {
    label: '创建时间',
    prop: 'createTime',
    width: 180,
  },
];
