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

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

interface RowType {
  id: number;
  order_no: string;
  status: number;
  express_name: string;
  express_mobile: string;
  express_region: string;
  express_address: string;
  created_at: string;
}

export const gridOptions: VxeGridProps<RowType> = {
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  columns: [
    { field: 'order_no', align: 'left', title: '订单号', minWidth: 160 },
    {
      field: 'status',
      title: '状态',
      slots: { default: 'status' },
      width: 120,
    },
    { field: 'express_name', title: '收货人' },
    { field: 'express_mobile', title: '联系电话' },
    { field: 'express_region', title: '收货地区' },
    { field: 'express_address', title: '收货地址', minWidth: 200 },
    {
      field: 'logistics_summary',
      title: '物流',
      minWidth: 160,
      slots: { default: 'logistics' },
    },
    { field: 'created_at', title: '下单时间', width: 180 },
    { type: 'html', title: '操作', slots: { default: 'action' }, width: 160 },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getDeliveryWarehouseOrderList({
          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,
};
