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

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

interface RowType {
  id: string;
  name: string;
  logo: string;
  introduce: string;
  created_at: string;
  zone_id: number;
  zone_name: string;
  category_id: number;
  category_name: 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: 100 },
    { field: 'drug_name', align: 'left', title: '器械名称' },
    { field: 'pinyin_simple', title: '拼音' },
    {
      field: 'zone_name',
      title: '分区',
      width: 100,
      slots: { default: 'zone' },
    },
    {
      field: 'category_name',
      title: '分类',
      width: 120,
      slots: { default: 'category' },
    },
    { field: 'supplier.name', title: '供应商', slots: { default: 'supplier' } },
    {
      field: 'image',
      align: 'left',
      title: '产品图片',
      slots: { default: 'image' },
      width: 130,
    },
    { field: 'function', title: '器械功能' },
    { field: 'specification', title: '规格型号' },
    { field: 'status', title: '状态', slots: { default: 'status' } },
    { field: 'created_at', title: '发布时间' },
    { type: 'html', title: '操作', width: 230, slots: { default: 'action' } },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getMedicalDeviceList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...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,
};








