import { h } from 'vue';
import { ElAvatar, ElTag } from 'element-plus';
import type { BasicColumn } from '@/components/Table';

export const columns: BasicColumn[] = [
  {
    label: 'id',
    prop: 'id',
  },
  {
    label: '编码',
    prop: 'no',
  },
  {
    label: '名称',
    prop: 'name',
  },
  {
    label: '头像',
    prop: 'avatar',
    width: 100,
    render(record) {
      return h(ElAvatar, {
        size: 48,
        src: record.row.avatar,
        shape: 'square',
        fit: 'fill',
      });
    },
  },
  {
    label: '地址',
    prop: 'address',
  },
  {
    label: '开始日期',
    prop: 'beginTime',
  },
  {
    label: '结束日期',
    prop: 'endTime',
  },
  {
    label: '状态',
    prop: 'status',
    render(record) {
      return h(
        ElTag,
        {
          type: record.row.status ? 'success' : 'danger',
        },
        {
          default: () => (record.row.status ? '启用' : '禁用'),
        },
      );
    },
  },
  {
    label: '创建时间',
    prop: 'date',
  },
  {
    label: '停留时间',
    prop: 'time',
  },
];
