From ba186e739ed0f569131c27dbabc687e771a5bb3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=94=BF=E6=9D=83?= <1978141412@qq.com> Date: Tue, 24 Sep 2024 09:32:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20drtab=E9=BB=98=E8=AE=A4=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E9=BB=98=E8=AE=A4=E7=BC=96=E8=BE=91=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/control/drtab/drtab.controller.ts | 55 ++++++++++++++++++--------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/control/drtab/drtab.controller.ts b/src/control/drtab/drtab.controller.ts index a93e37fa63..3182ab5433 100644 --- a/src/control/drtab/drtab.controller.ts +++ b/src/control/drtab/drtab.controller.ts @@ -8,6 +8,7 @@ import { calcNavParams, Srfuf, IPanelItemNavPosController, + hasSubRoute, } from '@ibiz-template/runtime'; import { getNestedRoutePath } from '@ibiz-template/vue3-util'; import { IDEDRCtrlItem, IDEDRTab } from '@ibiz/model-core'; @@ -163,28 +164,34 @@ export class DRTabController const { editItemCaption, editItemCapLanguageRes, - hideEditItem, editItemSysImage, uniqueTag, dedrtabPages, } = this.model; + const hideEditItem = !Object.is(this.model.hideEditItem, false); const drTabPages: IDRTabPagesState[] = []; - let caption = editItemCaption; - if (editItemCapLanguageRes) { - caption = ibiz.i18n.t(editItemCapLanguageRes.lanResTag!, editItemCaption); + if (!hideEditItem) { + let caption = editItemCaption; + if (editItemCapLanguageRes) { + caption = ibiz.i18n.t( + editItemCapLanguageRes.lanResTag!, + editItemCaption, + ); + } + + // 首项 + drTabPages.push({ + tag: uniqueTag!, + caption, + hidden: !!hideEditItem, + disabled: false, + sysImage: editItemSysImage, + fullPath: this.routeDepth + ? getNestedRoutePath(this.router.currentRoute.value, this.routeDepth!) + : '', + }); } - // 首项 - drTabPages.push({ - tag: uniqueTag!, - caption, - hidden: !!hideEditItem, - disabled: false, - sysImage: editItemSysImage, - fullPath: this.routeDepth - ? getNestedRoutePath(this.router.currentRoute.value, this.routeDepth!) - : '', - }); // 关系项 dedrtabPages?.forEach((item: IDEDRCtrlItem) => { let itemCaption = item.caption; @@ -206,14 +213,19 @@ export class DRTabController } else { this.state.activeName = drTabPages[0].tag; } + + // 路由模式下,且有子路由的时候不需要navpos跳转路由,只要做呈现 + const isRoutePushed = !!this.routeDepth && hasSubRoute(this.routeDepth); + this.handleTabChange(isRoutePushed); } /** * 处理分页改变 * * @memberof DRTabController + * @param {boolean} [isRoutePushed=false] 是否是路由已经跳转过了 */ - handleTabChange(): void { + handleTabChange(isRoutePushed: boolean = false): void { const { activeName } = this.state; const drBarItem = this.model.dedrtabPages?.find( item => item.id === activeName, @@ -221,10 +233,10 @@ export class DRTabController if (drBarItem) { this.setVisible('navPos'); - this.openNavPosView(drBarItem); + this.openNavPosView(drBarItem, isRoutePushed); } else { this.setVisible('form'); - if (this.routeDepth) { + if (this.routeDepth && this.state.drTabPages[0]) { this.router.push(this.state.drTabPages[0].fullPath!); } } @@ -292,15 +304,20 @@ export class DRTabController * 打开导航占位视图 * * @param {IDEDRCtrlItem} drTabPages 关系分页 + * @param {boolean} [isRoutePushed=false] * @memberof DRTabController */ - async openNavPosView(drTabPages: IDEDRCtrlItem): Promise { + async openNavPosView( + drTabPages: IDEDRCtrlItem, + isRoutePushed = false, + ): Promise { const { context, params } = this.prepareParams(drTabPages); this.navPos?.openView({ key: drTabPages.id!, context, params, viewId: drTabPages.appViewId, + isRoutePushed, }); } } -- Gitee