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

export const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    width: 50,
    fixed: 'left',
  },
  {
    title: '租户名称',
    dataIndex: 'name',
    width: 150,
  },
  {
    title: '租户编码',
    dataIndex: 'code',
    width: 100,
  },
  {
    title: '租户图片',
    dataIndex: 'image',
    customRender({ record }) {
      return h(Avatar, {
        size: 48,
        src: record.image,
        shape: 'square',
        fit: 'fill',
      });
    },
    width: 100,
  },
  {
    title: '统一社会信用代码',
    dataIndex: 'license',
    width: 160,
  },
  {
    title: '租户限额',
    dataIndex: 'number',
    width: 100,
  },
  {
    title: '租户人数',
    dataIndex: 'userNum',
    width: 100,
  },
  {
    title: '到期时间',
    dataIndex: 'expireTime',
    width: 180,
  },
  {
    title: '联系人姓名',
    dataIndex: 'contactUser',
    width: 140,
  },
  {
    title: '联系人电话',
    dataIndex: 'contactMobile',
    width: 140,
  },
  {
    title: '联系人姓名',
    dataIndex: 'contactUser',
    width: 140,
  },
  {
    title: '联系人邮箱',
    dataIndex: 'contactEmail',
    width: 200,
  },
  {
    title: '租户网址',
    dataIndex: 'contactSite',
    width: 140,
    customRender({ record }) {
      return h(
        'a',
        {
          href: record.contactSite,
          target: '_blank',
        },
        '点击查看网址',
      );
    },
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    width: 100,
    customRender({ record }) {
      return h(
        Tag,
        {
          color: record.status == 1 ? 'success' : 'error',
        },
        {
          default: () => (record.status == 1 ? '正常' : '禁用'),
        },
      );
    },
  },
  {
    title: '创建人',
    dataIndex: 'createUser',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    fixed: 'right',
    dataIndex: 'action',
    key: 'action',
    width: 300,
  },
];
