diff --git a/packages/amis/src/renderers/CRUD2.tsx b/packages/amis/src/renderers/CRUD2.tsx index 7f1d91e4d..cf9412d7d 100644 --- a/packages/amis/src/renderers/CRUD2.tsx +++ b/packages/amis/src/renderers/CRUD2.tsx @@ -388,7 +388,7 @@ export default class CRUD2 extends React.Component { } initQuery(values: object) { - const {store, orderBy, orderDir} = this.props; + const {store, orderBy, orderDir, loadType} = this.props; const params: any = {}; if (orderBy) { @@ -402,7 +402,8 @@ export default class CRUD2 extends React.Component { ...values, ...store.query }, - replaceQuery: this.props.initFetch !== false + replaceQuery: this.props.initFetch !== false, + loadMore: loadType === 'more' }); // 保留一次用于重置查询条件 @@ -426,9 +427,10 @@ export default class CRUD2 extends React.Component { query?: object; // 查询条件,没有将使用当前的 resetQuery?: boolean; replaceQuery?: boolean; + loadMore?: boolean; }) { const {store, syncLocation, env, pageField, perPageField} = this.props; - let {query, resetQuery, replaceQuery} = data || {}; + let {query, resetQuery, replaceQuery, loadMore} = data || {}; query = syncLocation && query @@ -444,9 +446,10 @@ export default class CRUD2 extends React.Component { perPageField, replaceQuery ); + store.changePage(1); this.lastQuery = store.query; - this.getData(undefined, undefined, undefined); + this.getData(undefined, undefined, undefined, loadMore ?? false); } handleStopAutoRefresh() { @@ -1015,15 +1018,15 @@ export default class CRUD2 extends React.Component { }; return render(region, schema, { - ...props, // 包两层,主要是为了处理以下 case // 里面放了个 form,form 提交过来的时候不希望把 items 这些发送过来。 // 因为会把数据呈现在地址栏上。 + /** data 可以被覆盖,因为 filter 中不需要额外的 data */ data: createObject( createObject(store.filterData, store.getData(this.props.data)), {} ), - render: this.renderChild, + ...props, ...childProps }); } @@ -1049,8 +1052,14 @@ export default class CRUD2 extends React.Component { return filter.map((item, index) => this.renderChild(`filter/${index}`, item, { - key: index + '', - onSubmit: (data: any) => this.handleSearch({query: data}) + key: index + 'filter', + data: this.props.store.filterData, + onSubmit: (data: any) => this.handleSearch({query: data}), + onReset: () => + this.handleSearch({ + resetQuery: true, + replaceQuery: true + }) }) ); }