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

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

interface RowType {
  id: number;
  order_no: string;
  status: number;
}

/** 我的开票表格 */
export const gridOptions: VxeGridProps<RowType> = {
  checkboxConfig: { highlight: true, labelField: '' },
  columns: [
    { field: 'id', title: 'ID', width: 70 },
    { field: 'order_no', title: '订单号', minWidth: 160 },
    { field: 'title_name', title: '抬头', minWidth: 120 },
    { field: 'party_name', title: '开票方', minWidth: 120 },
    { field: 'amount', title: '本方金额', width: 110 },
    { field: 'status_text', title: '状态', width: 90, slots: { default: 'status' } },
    { field: 'created_at', title: '创建时间', minWidth: 160 },
    {
      title: '操作',
      align: 'right',
      slots: { default: 'action' },
      width: 200,
      fixed: 'right',
    },
  ],
  keepSource: true,
  pagerConfig: {},
  columnConfig: { useKey: true },
  rowConfig: { useKey: true },
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getMyInvoiceListApi({
          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' },
  },
  showOverflow: false,
};
