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

import { getOrderList } from '#/views/business/order/product-order/api';

interface RowType {
  id: string;
  name: string;
  logo: string;
  introduce: string;
  created_at: string;
}

export const gridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: '',
  },
  columns: [
    { type: 'expand', width: 80, slots: { content: 'expand-content' } },
    { field: 'id', align: 'left', title: 'ID', width: 100 },
    {
      field: 'order_no',
      align: 'left',
      width: 220,
      title: '订单号/诊所',
      slots: { default: 'order-store' },
    },
    {
      field: 'user.avatarUrl',
      title: '下单用户信息',
      slots: { default: 'avatar' },
      width: 100,
    },
    {
      field: 'express_info',
      title: '收货信息',
      width: 200,
      slots: { default: 'express-info' },
    },
    {
      field: 'delivery_method',
      title: '订单类型&邮寄方式&订单状态',
      width: 120,
      slots: { default: 'delivery-method' },
    },
    {
      field: 'price_info',
      title: '金额',
      width: 160,
      slots: { default: 'price-info' },
    },
    {
      field: 'salesperson',
      title: '推广员',
      width: 180,
      slots: { default: 'salesperson' },
    },
    {
      field: 'is_sync_erp',
      title: 'Erp状态',
      width: 120,
      slots: { default: 'is-sync-erp' },
    },
    {
      field: 'is_free_shipping',
      title: '是否包邮',
      width: 100,
      slots: { default: 'is-free-shipping' },
    },
    // {
    //   field: 'is_online',
    //   title: '订单来源',
    //   width: 100,
    //   slots: { default: 'is-online' },
    // },
    // {
    //   field: 'pay_time',
    //   title: '支付时间',
    //   width: 240,
    //   slots: { default: 'pay-time' },
    // },
    // { field: 'created_at', width: 240, title: '下单时间' },
    {
      type: 'html',
      title: '操作',
      fixed: 'right',
      slots: { default: 'action' },
      width: 300,
    },
  ],
  keepSource: true,
  pagerConfig: {},
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getOrderList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
  border: false,
  toolbarConfig: {
    search: true,
    refresh: true,
    print: false,
    export: false,
    zoom: true,
    slots: {
      buttons: 'toolbar-buttons',
    },
    custom: {
      icon: 'vxe-icon-menu',
    },
  },
  expandConfig: {},
  showOverflow: false,
};
