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

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

interface RowType {
  id: string;
  name: string;
  introduce: string;
  status: number;
  bank_card_report_status?: number;
  bank_card_report_status_text?: 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: 100 },
    { field: 'name', align: 'left', title: '仓库名称' },
    { field: 'introduce', title: '仓库介绍' },
    {
      field: 'bank_card_report_status',
      title: '银行卡报备',
      slots: { default: 'bank_card_report_status' },
      width: 120,
    },
    {
      field: 'status',
      title: '状态',
      slots: { default: 'status' },
      width: 100,
    },
    { field: 'created_at', title: '创建时间' },
    { type: 'html', title: '操作', slots: { default: 'action' }, width: 260 },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getDeliveryWarehouseList({
          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,
};
