import type { TableColumnData } from '@arco-design/web-vue';
import { dateFormat } from '@/utils';

const columns = [
  {
    title: 'id',
    dataIndex: 'id',
    slotName: 'id',
    width: 68,
    align: 'left',
    fixed: 'left',
  }, #foreach($field in ${table.fields})#if("$!field.propertyName" != "id"){
    title: '${field.comment}',
    dataIndex: '${field.propertyName}',
    slotName: '${field.propertyName}',
    align: 'left',
    #if(${field.propertyType} == 'String')
    minWidth: 238,
    ellipsis: true,
    tooltip: true,
    #elseif(${field.propertyType} == 'Date')
    width: 180,
    render: ({ record }) => {
      return record.${field.propertyName} && dateFormat(new Date(record.${field.propertyName}));
    },
    #end
  }, #end#end{
    title: '创建时间',
    dataIndex: 'createTime',
    slotName: 'createTime',
    align: 'center',
    width: 180,
    render: ({ record }) => {
      return dateFormat(new Date(record.createTime));
    },
  }, {
    title: '修改时间',
    dataIndex: 'updateTime',
    slotName: 'updateTime',
    align: 'center',
    width: 180,
    render: ({ record }) => {
      return dateFormat(new Date(record.updateTime));
    },
  }, {
    title: '创建人',
    dataIndex: 'creator',
    slotName: 'creator',
  }, {
    title: '修改人',
    dataIndex: 'updater',
    slotName: 'updater',
  }, {
    title: '操作',
    slotName: 'handle',
    width: 130,
    align: 'center',
    fixed: 'right',
  },
] as TableColumnData[];

export default columns;
