diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/ExposeApiManager.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/ExposeApiManager.ts index 97598d6a..0b1c4943 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/ExposeApiManager.ts +++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/ExposeApiManager.ts @@ -63,6 +63,7 @@ export class ExposeApiManager { getCascadeChildren: tools.apiFM.getData.getCascadeChildren, getCascadeParents: tools.apiFM.getData.getCascadeParents, getSelectedCell: tools.apiFM.getData.getSelectedCell, + getURLSearchParams: tools.apiFM.getData.getURLSearchParams, // 获取子组件ref的api getQueryForm: tools.apiFM.componentRef.getQueryForm, diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/src/GetData.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/src/GetData.ts index e71651be..a6a5792a 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/src/GetData.ts +++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/expose-api/src/GetData.ts @@ -179,4 +179,13 @@ export class GetData extends Base { } return data; } + + /** + * 获取当前 查询表单 + 排序等信息基于后台 criteria查询 构建的 URLSearchParams 对象 + * @param pageable 是否需要带上分页信息 + */ + getURLSearchParams(pageable: boolean = false) { + const reqParams: any = this.tools?.reqApiFM.buildFetchDataBaseParams({ pagination: this.tools.table.store.pagination }, pageable); + return this.tools?.criteriaFM.buildURLSearchParams(reqParams); + } } diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RequestApi.ts b/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RequestApi.ts index c30a30d0..230586e8 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RequestApi.ts +++ b/io.sc.platform.core.frontend/src/platform/components/grid/ts/function/RequestApi.ts @@ -199,14 +199,24 @@ export class RequestApi extends Base { }); } - private async requestHandle(ops: any) { + /** + * 构建查询基本参数 + * @param ops 当前分页排序信息 + * @param noPageable 强制忽略表格分页配置 + */ + buildFetchDataBaseParams(ops: any, noPageable: boolean = false) { const reqParams: any = {}; - if (this.props.pageable && !this.props.tree && !this.props.localMode) { - reqParams.page = ops.pagination.page; - reqParams.size = ops.pagination.rowsPerPage; + if (noPageable) { + reqParams.pageable = false; + } else { + if (this.props.pageable && !this.props.tree && !this.props.localMode) { + reqParams.page = ops.pagination.page; + reqParams.size = ops.pagination.rowsPerPage; + } + reqParams.pageable = this.props.tree || this.props.localMode ? false : this.props.pageable; } - reqParams.pageable = this.props.tree || this.props.localMode ? false : this.props.pageable; if (ops.pagination.sortBy && ops.pagination.sortBy !== '') { + // 处理表格点击列头进行的排序 if (ops.pagination.descending) { reqParams.sortBy = '-' + ops.pagination.sortBy; reqParams.descending = ops.pagination.descending; @@ -214,10 +224,17 @@ export class RequestApi extends Base { reqParams.sortBy = ops.pagination.sortBy; } } else if (this.props.sortBy && this.props.sortBy.length > 0) { + // 处理表格配置的默认排序 reqParams.sortBy = this.props.sortBy; } + return reqParams; + } + + private async requestHandle(ops: any) { + // 构建查询基本参数 + const reqParams: any = this.buildFetchDataBaseParams(ops); - // 后台 RestCrudController 查询 + // 根据基本参数 + 查询表单 构建基于后台 criteria 查询的 URLSearchParams 对象 let urlSearchParams = this.tools?.criteriaFM.buildURLSearchParams(reqParams); // 请求前事件触发