import { h } from 'vue';
import { ElAvatar } 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',
    editRow: true,
    // 默认必填校验
    editRule: true,
    edit: true,
  },
  {
    label: '头像',
    prop: 'avatar',
    render(record) {
      return h(ElAvatar, {
        size: 48,
        src: record.row.avatar,
        shape: 'square',
        fit: 'fill',
      });
    },
  },
  {
    label: '地址',
    prop: 'address',
    editRow: true,
    editComponent: 'Select',
    editComponentProps: {
      options: [
        {
          label: '广东省',
          value: 1,
        },
        {
          label: '浙江省',
          value: 2,
        },
      ],
    },
    edit: true,
    width: 200,
  },
  {
    label: '开始日期',
    prop: 'beginTime',
    editRow: true,
    edit: true,
    width: 260,
    editComponent: 'DatePicker',
    editComponentProps: {
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '结束日期',
    prop: 'endTime',
    width: 160,
  },
  {
    label: '状态',
    prop: 'status',
    editRow: true,
    edit: true,
    editComponent: 'Switch',
    editValueMap: (value) => {
      return value ? '启用' : '禁用';
    },
  },
  {
    label: '创建时间',
    prop: 'date',
    width: 160,
  },
  {
    label: '停留时间',
    prop: 'time',
    width: 80,
  },
];
