diff --git a/src/control/drtab/drtab.controller.ts b/src/control/drtab/drtab.controller.ts index a93e37fa635aa1463812402cccdb66b353856fa0..3182ab54337a69f2ce5002f81cb770f8eb3ce97c 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, }); } }