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

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

interface RowType {
  id: number;
  name: string;
  mobile: string;
  type: number;
  status: number;
  input_user_id: number;
  inputUser: {
    nick_name: string;
  };
  auditAdmin: {
    nick_name: string;
  };
  depart: {
    name: string;
  };
  titleInfo: {
    name: string;
  };
  audit_time: number;
  created_at: string;
}

// 录入列表表格配置
export const inputGridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: '',
  },
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  columns: [
    { type: 'checkbox', width: 60 },
    { field: 'id', align: 'left', title: 'ID', width: 100 },
    { field: 'name', align: 'left', title: '医生姓名' },
    { field: 'mobile', title: '手机号', width: 140, slots: { default: 'mobile' } },
    {
      field: 'type',
      align: 'left',
      title: '身份',
      width: 100,
      slots: { default: 'type' },
    },
    { field: 'depart.name', title: '科室', width: 120 },
    { field: 'titleInfo.name', title: '职称', width: 120 },
    {
      field: 'status',
      align: 'left',
      title: '审核状态',
      width: 120,
      slots: { default: 'status' },
    },
    { field: 'created_at', title: '录入时间' },
    {
      type: 'html',
      title: '操作',
      fixed: 'right',
      width: 200,
      slots: { default: 'action' },
    },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getDoctorInputList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
  height: 'auto',
  border: false,
  toolbarConfig: {
    search: true,
    refresh: true,
    print: false,
    export: false,
    zoom: true,
    slots: {
      buttons: 'toolbar-actions',
    },
  },
  showOverflow: false,
};

// 审核列表表格配置
export const auditGridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: '',
  },
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  columns: [
    { type: 'checkbox', width: 60 },
    { field: 'id', align: 'left', title: 'ID', width: 100 },
    { field: 'name', align: 'left', title: '医生姓名' },
    { field: 'mobile', title: '手机号', width: 140, slots: { default: 'mobile' } },
    {
      field: 'type',
      align: 'left',
      title: '身份',
      width: 100,
      slots: { default: 'type' },
    },
    { field: 'depart.name', title: '科室', width: 120 },
    { field: 'titleInfo.name', title: '职称', width: 120 },
    {
      field: 'status',
      align: 'left',
      title: '审核状态',
      width: 120,
      slots: { default: 'status' },
    },
    {
      field: 'inputUser',
      title: '录入人',
      minWidth: 140,
      slots: { default: 'inputUser' },
    },
    { field: 'auditAdmin.nick_name', title: '审核人' },
    { field: 'audit_time', title: '审核时间', slots: { default: 'audit_time' } },
    { field: 'created_at', title: '录入时间' },
    {
      type: 'html',
      title: '操作',
      align: 'right',
      slots: { default: 'action' },
    },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getDoctorInputList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
  height: 'auto',
  border: false,
  toolbarConfig: {
    search: true,
    refresh: true,
    print: false,
    export: false,
    zoom: true,
  },
  showOverflow: false,
};
