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

import { getDeliveryWarehouseDrugList } from '#/views/system/delivery-warehouse-stock/api';

interface RowType {
  id: number;
  drug_name: string;
  quote: string;
  promo_fee: string;
  platform_fee: string;
  stock: number;
  frozen_number: number;
  drug?: { drug_name: string };
}

export const gridOptions: VxeGridProps<RowType> = {
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  columns: [
    {
      field: 'drug_name',
      title: '药品名称',
      slots: { default: 'drug_name' },
      minWidth: 160,
    },
    { field: 'quote', title: '报价' },
    { field: 'promo_fee', title: '推广费' },
    { field: 'platform_fee', title: '平台费' },
    { field: 'stock', title: '库存' },
    { field: 'frozen_number', title: '冻结数量' },
    { type: 'html', title: '操作', slots: { default: 'action' }, width: 100 },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getDeliveryWarehouseDrugList({
          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-actions',
    },
    custom: {
      icon: 'vxe-icon-menu',
    },
  },
  showOverflow: false,
};
