import type { VxeGridProps } from '#/adapter/vxe-table';

import { normalizeLogTimeFilters } from '../../shared/normalizeLogFilters';
import { getErrorLogList } from '../api';

export const gridOptions: VxeGridProps<any> = {
  columns: [
    { field: 'id', title: 'ID', width: 80 },
    { field: 'type_txt', title: '类型', width: 100, slots: { default: 'type' } },
    { field: 'created_at', title: '创建时间', width: 170 },
    { field: 'content', title: '内容摘要', minWidth: 280, slots: { default: 'content' } },
    { title: '操作', width: 90, fixed: 'right', slots: { default: 'action' } },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) =>
        getErrorLogList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...normalizeLogTimeFilters(formValues || {}),
        }),
    },
  },
  height: 'auto',
  toolbarConfig: { search: true, refresh: true, zoom: true },
};
