fix: 修复CRUD的filter中clearValueOnHidden字段使用上次保留值的问题 (#5896)

This commit is contained in:
RUNZE LU 2022-12-30 11:05:59 +08:00 committed by GitHub
parent ec084e3b0b
commit a03677616a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import React from 'react';
import isEqual from 'lodash/isEqual';
import pickBy from 'lodash/pickBy';
import {Renderer, RendererProps} from 'amis-core';
import {SchemaNode, Schema, ActionObject, PlainObject} from 'amis-core';
import {CRUDStore, ICRUDStore} from 'amis-core';
@ -872,7 +873,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
}
handleFilterSubmit(
values: object,
values: Record<string, any>,
jumpToFirstPage: boolean = true,
replaceLocation: boolean = false,
search: boolean = true
@ -886,6 +887,14 @@ export default class CRUD extends React.Component<CRUDProps, any> {
loadDataOnceFetchOnFilter
} = this.props;
/** 找出clearValueOnHidden的字段, 保证updateQuery时不会使用上次的保留值 */
values = {
...values,
...pickBy(
values?.__super?.diff ?? {},
(value) => value === undefined
)
};
values = syncLocation
? qsparse(qsstringify(values, undefined, true))
: values;