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',
    editComponent: 'Input',
    // 默认必填校验
    editRule: true,
    edit: true,
    editCellRender: (value) => {
      return h(
        ElTag,
        {
          style: {
            marginRight: '6px',
          },
          type: 'info',
        },
        {
          default: () => value,
        },
      );
    },
  },
  {
    label: '头像',
    prop: 'avatar',
    render(record) {
      return h(ElAvatar, {
        size: 48,
        src: record.row.avatar,
        shape: 'square',
        fit: 'fill',
      });
    },
  },
  {
    label: '地址',
    prop: 'address',
    editComponent: 'Select',
    editComponentProps: {
      options: [
        {
          label: '广东省',
          value: 1,
        },
        {
          label: '浙江省',
          value: 2,
        },
      ],
    },
    edit: true,
  },
  {
    label: '开始日期',
    prop: 'beginTime',
    edit: true,
    editComponent: 'DatePicker',
    editComponentProps: {
      type: 'datetime',
      format: 'yyyy-MM-dd HH:mm:ss',
    },
  },
  {
    label: '结束日期',
    prop: 'endTime',
  },
  {
    label: '创建时间',
    prop: 'date',
  },
  {
    label: '停留时间',
    prop: 'time',
  },
];
