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

import { TableApi } from '#/api';

export const searchFormOptions: VbenFormProps = {
  showCollapseButton: false,
  schema: [
    {
      component: 'Input',
      fieldName: 'name',
      label: '名称',
    },
  ],
};

export const gridOptions: VxeGridProps<TableApi.RecordItem> = {
  toolbarConfig: {
    refresh: true,
    print: false,
    export: true,
    zoom: true,
    custom: true,
  },
  columns: [
    { title: '序号', type: 'seq', width: 50 },
    { align: 'left', field: 'tableType', title: '类型', width: 120 },
    { align: 'left', field: 'name', title: '查询名称', width: 200 },
    { align: 'left', field: 'code', title: '查询编码', width: 100 },
    { field: 'sort', title: '排序', width: 50 },
    { align: 'left', field: 'remark', title: '备注' },
    {
      field: 'action',
      fixed: 'right',
      slots: { default: 'action' },
      title: '操作',
      width: 140,
    },
  ],
  height: 'auto',
  keepSource: true,
  pagerConfig: {},
  exportConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await TableApi.getPage({
          pageIndex: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
};
