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

export const columns = [
  {
    type: 'selection',
  },
  {
    label: 'ID',
    prop: 'id',
    width: 100,
  },
  {
    label: '友链名称',
    prop: 'name',
  },
  {
    label: '友链类型',
    prop: 'type',
    render(record) {
      return h('span', record.row.type === 1 ? '友情链接' : '合作伙伴')
    },
  },
  {
    label: '友链形式',
    prop: 'form',
    render(record) {
      return h('span', record.row.form === 1 ? '文字链接' : '图片链接')
    },
  },
  {
    label: '友链地址',
    prop: 'url',
    width: 200,
    render(record) {
      return h('a', {
        href: record.row.url,
        target:"_blank"
      }, record.row.url);
    },
  },
  // {
  //   label: '状态',
  //   prop: 'status',
  //   render(record) {
  //     return h('span', record.row.status === 1 ? '在用' : '停用')
  //   },
  // },
  {
    label: '状态',
    prop: 'status',
    render(record) {
      return h(
        ElTag,
        {
          type: record.row.status ==1 ? 'success' : 'danger',
        },
        {
          default: () => (record.row.status ==1 ? '正常' : '停用'),
        },
      );
    },
  },
  {
    label: '排序',
    prop: 'sort',
  },
  {
    label: '创建人',
    prop: 'createUser',
  },
  {
    label: '创建时间',
    prop: 'createTime',
    width: 180,
  },
];
