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

import { getSpecialPrescriptionCategoryList } from '../api';

interface RowType {
  id: number;
  name: string;
  sort: number;
  status: number;
  status_txt: string;
  created_at: string;
  updated_at: string;
}

export const gridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: '',
  },
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
    isHover: true,
    isCurrent: true,
  },
  columns: [
    { type: 'checkbox', width: 60 },
    { field: 'id', align: 'left', title: 'ID', width: 80 },
    { field: 'name', align: 'left', title: '分类名称', minWidth: 160 },
    { field: 'sort', align: 'left', title: '排序', width: 100 },
    { field: 'status_txt', align: 'left', title: '状态', width: 100 },
    { field: 'created_at', title: '创建时间', width: 180 },
    { type: 'html', title: '操作', slots: { default: 'action' }, width: 160 },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getSpecialPrescriptionCategoryList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
  border: false,
  toolbarConfig: {
    search: true,
    refresh: true,
    print: false,
    export: false,
    zoom: true,
    slots: {
      buttons: 'toolbar-actions',
    },
    custom: {
      icon: 'vxe-icon-menu',
    },
  },
  showOverflow: false,
};
