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: 'name',
    minWidth: 150,
  },
  {
    label: '租户编码',
    prop: 'code',
    minWidth: 100,
  },
  {
    label: '租户图片',
    prop: 'image',
    minWidth: 100,
    render(record) {
      return h(ElAvatar, {
        size: 48,
        src: record.row.image,
        shape: 'square',
        fit: 'fill',
      });
    },
  },
  {
    label: '统一社会信用代码',
    prop: 'license',
    minWidth: 160,
  },
  {
    label: '租户限额',
    prop: 'number',
    minWidth: 100,
  },
  {
    label: '租户人数',
    prop: 'userNum',
    minWidth: 100,
  },
  {
    label: '到期时间',
    prop: 'expireTime',
    minWidth: 180,
  },
  {
    label: '联系人姓名',
    prop: 'contactUser',
    minWidth: 140,
  },
  {
    label: '联系人电话',
    prop: 'contactMobile',
    minWidth: 140,
  },
  {
    label: '联系人姓名',
    prop: 'contactUser',
    width: 140,
  },
  {
    label: '联系人邮箱',
    prop: 'contactEmail',
    minWidth: 200,
  },
  {
    label: '租户网址',
    prop: 'contactSite',
    minWidth: 140,
    render(record) {
      return h(
        'a',
        {
          href: record.row.contactSite,
          target: '_blank',
        },
        '点击查看网址',
      );
    },
  },
  {
    label: '状态',
    prop: 'status',
    minWidth: 100,
    render(record) {
      return h(
        ElTag,
        {
          type: record.row.status == 1 ? 'success' : 'danger',
        },
        {
          default: () => (record.row.status == 1 ? '正常' : '禁用'),
        },
      );
    },
  },
  {
    label: '创建人',
    prop: 'createUser',
    minWidth: 100,
  },
  {
    label: '创建时间',
    prop: 'createTime',
    width: 180,
  },
];
