import { h } from 'vue';
import { ElAvatar, ElTag } from 'element-plus';
export const columns = [
  {
    type: 'selection',
  },
  {
    label: 'ID',
    prop: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    label: '广告标题',
    prop: 'title',
    minWidth: 250,
    render(record) {
      return h(
        'a',
        {
          href: record.row.url,
          target: '_blank',
        },
        record.row.title,
      );
    },
  },
  {
    label: '广告封面',
    prop: 'cover',
    minWidth: 100,
    render(record) {
      return h(ElAvatar, {
        size: 35,
        src: record.row.cover,
        shape: 'square',
        fit: 'fill',
      });
    },
  },
  {
    label: '广告类型',
    prop: 'type',
    minWidth: 100,
    render(record) {
      let typeText = '';
      switch (record.row.type) {
        case 1:
          typeText = '图片';
          break;
        case 2:
          typeText = '文字';
          break;
        case 3:
          typeText = '视频';
          break;
        default:
          break;
      }
      return h('span', typeText || '-');
    },
  },
  {
    label: '广告状态',
    prop: 'status',
    minWidth: 100,
    render(record) {
      return h(
        ElTag,
        {
          type: record.row.status == 1 ? 'success' : 'danger',
        },
        {
          default: () => (record.row.status == 1 ? '正常' : '停用'),
        },
      );
    },
  },
  {
    label: '广告尺寸',
    prop: 'size',
    minWidth: 100,
    render(record) {
      return record.row.width + 'x' + record.row.height;
    },
  },
  {
    label: '投放时间',
    prop: 'time',
    minWidth: 300,
    render(record) {
      return record.row.startTime + '-' + record.row.endTime;
    },
  },
  {
    label: '点击量',
    prop: 'click',
    minWidth: 100,
  },
  {
    label: '排序',
    prop: 'sort',
    minWidth: 100,
  },
  {
    label: '创建人',
    prop: 'createUser',
    minWidth: 100,
  },
  {
    label: '创建时间',
    prop: 'createTime',
    width: 180,
  },
];
