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

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

export const gridOptions: VxeGridProps<any> = {
  columns: [
    { field: 'id', title: 'ID', width: 70 },
    { field: 'operator_name', title: '操作人', width: 100 },
    { field: 'type_txt', title: '类型', width: 100 },
    { field: 'drug_name', title: '药品', minWidth: 120 },
    { field: 'drug_number', title: '编码', width: 110 },
    { field: 'old_buy', title: '原供货价', width: 90 },
    { field: 'new_buy', title: '新供货价', width: 90 },
    { field: 'old_price', title: '原售价', width: 90 },
    { field: 'new_price', title: '新售价', width: 90 },
    { field: 'store_id', title: '门店ID', width: 80 },
    { field: 'created_at', title: '时间', width: 170 },
    { title: '操作', width: 90, fixed: 'right', slots: { default: 'action' } },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) =>
        getStoreDrugUpdateLogList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...normalizeLogTimeFilters(formValues || {}),
        }),
    },
  },
  height: 'auto',
  toolbarConfig: { search: true, refresh: true, zoom: true },
};
