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

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

interface RowType {
  id: string;
  nick_name: string;
  email: string;
  avatar: string;
  roles: { name: string }[];
  open_id: string;
  code: string;
  platform_id: string;
  phone: string;
  desc: string;
  created_at: string;
}

export const gridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: '',
  },
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  columns: [
    { type: 'checkbox', width: 60 },
    { field: 'id', align: 'left', title: 'ID', width: 80 },
    {
      field: 'doctor_basic_info',
      align: 'left',
      title: '基础信息',
      width: 220,
      slots: { default: 'doctor_basic_info' },
    },
    {
      field: 'doctor_professional_info',
      align: 'left',
      title: '执业信息',
      width: 280,
      slots: { default: 'doctor_professional_info' },
    },
    { field: 'service_user', title: '审核状态', slots: { default: 'service-user' } },
    { field: 'created_at', title: '注册时间', width: 160 },
    { type: 'html', title: '操作', width: 260, slots: { default: 'action' } },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      // 请求后端接口方法
      query: async ({ page }, formValues) => {
        return await getDoctorList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
  height: 'auto',
  border: false,
  toolbarConfig: {
    // 是否显示搜索表单控制按钮
    // @ts-ignore 正式环境时有完整的类型声明
    search: true,
    refresh: true, // 刷新
    print: false, // 打印
    export: false, // 导出
    // custom: true, // 自定义列
    zoom: true, // 最大化最小化
    slots: {
      buttons: 'toolbar-actions',
    },
    custom: {
      // 自定义列-图标
      icon: 'vxe-icon-menu',
    },
  },
  showOverflow: false,
};
