Skip to content

Commit

Permalink
fix: total field parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tuin77 committed Oct 17, 2024
1 parent 7f89561 commit e603473
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/effects/plugins/src/vxe-table/extends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { VxeGridProps, VxeUIExport } from 'vxe-table';

import type { VxeGridApi } from './api';

import { isFunction } from '@vben/utils';
import { getNestedValue, isFunction } from '@vben/utils';

import dayjs from 'dayjs';

Expand Down Expand Up @@ -40,9 +40,13 @@ function extendProxyOption(
const data = await configFn(params, formValues, ...args);

// If the page is incorrect, make corrections and request again
const total = proxyConfig?.response?.total as string;
const response = proxyConfig?.response || {};
const total = response?.total;

const { pageSize, currentPage } = params.page;
const resultTotal: number = data[total];
const resultTotal: number = isFunction(total)
? total({ data, $grid: api.grid })
: getNestedValue(data, total || 'total') || 0;
if (Number(resultTotal)) {
const currentTotalPage = Math.max(1, Math.ceil(resultTotal / pageSize));
if (currentPage > currentTotalPage) {
Expand Down

0 comments on commit e603473

Please sign in to comment.