fix: resolve issue with grid reload parameter not working (#4888)

This commit is contained in:
Vben
2024-11-13 22:06:04 +08:00
committed by vben
parent 8cc73cf59c
commit 5b079471b9
4 changed files with 361 additions and 120 deletions

View File

@@ -1,3 +1,4 @@
import type { Recordable } from '@vben/types';
import type { VxeGridProps, VxeUIExport } from 'vxe-table';
import type { VxeGridApi } from './api';
@@ -7,7 +8,7 @@ import { formatDate, formatDateTime, isFunction } from '@vben/utils';
export function extendProxyOptions(
api: VxeGridApi,
options: VxeGridProps,
getFormValues: () => Record<string, any>,
getFormValues: () => Recordable<any>,
) {
[
'query',
@@ -25,17 +26,28 @@ function extendProxyOption(
key: string,
api: VxeGridApi,
options: VxeGridProps,
getFormValues: () => Record<string, any>,
getFormValues: () => Recordable<any>,
) {
const { proxyConfig } = options;
const configFn = (proxyConfig?.ajax as any)?.[key];
const configFn = (proxyConfig?.ajax as Recordable<any>)?.[key];
if (!isFunction(configFn)) {
return options;
}
const wrapperFn = async (params: any, _formValues: any, ...args: any[]) => {
const wrapperFn = async (
params: Recordable<any>,
customValues: Recordable<any>,
...args: Recordable<any>[]
) => {
const formValues = getFormValues();
const data = await configFn(params, formValues, ...args);
const data = await configFn(
params,
{
...customValues,
...formValues,
},
...args,
);
return data;
};
api.setState({