From b38c15aff679a47e5a2ca40a3437db064b1d56ab Mon Sep 17 00:00:00 2001 From: likunming Date: Tue, 19 Aug 2025 21:11:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8C=89=E9=92=AE=E5=8F=8A=E6=89=A9=E5=B1=95=E5=8D=95?= =?UTF-8?q?=E9=80=89=E7=BB=84=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grid/ts/expose-api/ExposeApiManager.ts | 1 + .../grid/ts/expose-api/src/GetData.ts | 9 ++++++ .../components/grid/ts/function/RequestApi.ts | 29 +++++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) 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); // 请求前事件触发