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

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

interface RowType {
  id: string;
  name: string;
  logo: string;
  introduce: 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: 'store_basic_info',
      align: 'left',
      title: '基础信息',
      width: 280,
      slots: { default: 'store_basic_info' },
    },
    {
      field: 'online_consultation_config',
      align: 'left',
      title: '在线复诊配置',
      width: 160,
      slots: { default: 'online_consultation_config' },
    },
    {
      field: 'special_prescription_config',
      align: 'left',
      title: '特色方配置',
      width: 180,
      slots: { default: 'special_prescription_config' },
    },
    {
      field: 'store_config_1',
      align: 'left',
      title: '开关配置',
      width: 330,
      slots: { default: 'store_config_1' },
    },
    {
      field: 'store_config_2',
      align: 'left',
      title: '业务配置',
      width: 330,
      slots: { default: 'store_config_2' },
    },
    {
      field: 'qr_code',
      align: 'left',
      title: '诊所二维码',
      slots: { default: 'qr_code' },
      width: 130,
    },
    { field: 'position', title: '详细地址', width: 140 },
    { field: 'new_admin.nick_name', title: '业务员', slots: { default: 'sales_admin' }, width: 160 },
    { field: 'mobile', title: '联系人、电话', slots: { default: 'mobile' }, width: 140 },
    {
      field: 'start_time',
      title: '营业时间',
      slots: { default: 'start-time' },
      width: 140,
    },
    { field: 'created_at', title: '注册时间', width: 140 },
    {
      type: 'html',
      title: '操作',
      fixed: 'right',
      width: 200,
      slots: { default: 'action' },
    },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getStoreList({
          page: page.currentPage,
          pageSize: page.pageSize,
          type: 0,
          ...formValues,
        });
      },
    },
  },
  height: 'auto',
  border: false,
  toolbarConfig: {
    // @ts-ignore 正式环境时有完整的类型声明
    search: true,
    refresh: true,
    print: false,
    export: false,
    zoom: true,
    slots: {
      buttons: 'toolbar-buttons',
    },
    custom: {
      icon: 'vxe-icon-menu',
    },
  },
  showOverflow: false,
};
