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

import { normalizeLogTimeFilters } from '../../shared/normalizeLogFilters';
import { getProductOrderPriceAdjustLogList } from '../api';

export const gridOptions: VxeGridProps<any> = {
  columns: [
    { field: 'id', title: 'ID', width: 70 },
    { field: 'product_order_id', title: '订单ID', width: 90 },
    { field: 'drug_id', title: '药品ID', width: 90 },
    { field: 'old_price', title: '原售价', width: 90 },
    { field: 'new_price', title: '新售价', width: 90 },
    { field: 'adjust_amount', title: '调整额', width: 90 },
    { field: 'adjust_mode_txt', title: '方式', width: 80 },
    { field: 'user_id', title: '操作人', width: 90 },
    { field: 'remark', title: '备注', minWidth: 120 },
    { field: 'created_at', title: '时间', width: 170 },
    { title: '操作', width: 90, fixed: 'right', slots: { default: 'action' } },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) =>
        getProductOrderPriceAdjustLogList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...normalizeLogTimeFilters(formValues || {}),
        }),
    },
  },
  height: 'auto',
  toolbarConfig: { search: true, refresh: true, zoom: true },
};
