mirror of
https://gitee.com/eolink_admin/postcat.git
synced 2024-12-02 19:57:45 +08:00
feat: open tab in current detail page
This commit is contained in:
parent
6df5efcecc
commit
e22d99d26b
@ -65,7 +65,7 @@ export class ApiTabComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
if (apiID) {
|
if (apiID) {
|
||||||
const tab = this.getTabInfo({
|
const tab = this.getTabInfo({
|
||||||
id: apiID,
|
tabData: this.apiDataItems[apiID],
|
||||||
});
|
});
|
||||||
this.appendOrSwitchTab('unset', tab);
|
this.appendOrSwitchTab('unset', tab);
|
||||||
} else {
|
} else {
|
||||||
@ -81,7 +81,6 @@ export class ApiTabComponent implements OnInit, OnDestroy {
|
|||||||
* @param tabContent
|
* @param tabContent
|
||||||
*/
|
*/
|
||||||
private appendOrSwitchTab(which = 'test', tabContent: any = {}): void {
|
private appendOrSwitchTab(which = 'test', tabContent: any = {}): void {
|
||||||
if (this.tabSerive.tabs.length >= this.MAX_TAB_LIMIT) return;
|
|
||||||
let tab: TabItem = Object.assign(
|
let tab: TabItem = Object.assign(
|
||||||
{
|
{
|
||||||
uuid: new Date().getTime(),
|
uuid: new Date().getTime(),
|
||||||
@ -99,9 +98,15 @@ export class ApiTabComponent implements OnInit, OnDestroy {
|
|||||||
this.switchTab(existApiIndex, switchTab);
|
this.switchTab(existApiIndex, switchTab);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// avoid open too much tab,if detail or no change,open page in current tab
|
||||||
|
if(this.tabSerive.currentTab?.path.includes('detail')){
|
||||||
|
this.switchTab(this.selectedIndex, tab);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.appendTab(tab);
|
this.appendTab(tab);
|
||||||
}
|
}
|
||||||
private appendTab(tab) {
|
private appendTab(tab) {
|
||||||
|
if (this.tabSerive.tabs.length >= this.MAX_TAB_LIMIT) return;
|
||||||
this.tabSerive.tabs.push(tab);
|
this.tabSerive.tabs.push(tab);
|
||||||
this.changeSelectIndex(this.tabSerive.tabs.length - 1);
|
this.changeSelectIndex(this.tabSerive.tabs.length - 1);
|
||||||
}
|
}
|
||||||
@ -232,11 +237,12 @@ export class ApiTabComponent implements OnInit, OnDestroy {
|
|||||||
break;
|
break;
|
||||||
case 'addApiSuccess':
|
case 'addApiSuccess':
|
||||||
case 'editApiSuccess':
|
case 'editApiSuccess':
|
||||||
|
//jump to detail page
|
||||||
this.switchTab(
|
this.switchTab(
|
||||||
this.selectedIndex,
|
this.selectedIndex,
|
||||||
this.getTabInfo({
|
this.getTabInfo({
|
||||||
path: this.defaultTabs['detail'].path,
|
path: this.defaultTabs['detail'].path,
|
||||||
apiData: inArg.data,
|
tabData: inArg.data,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -256,7 +262,7 @@ export class ApiTabComponent implements OnInit, OnDestroy {
|
|||||||
this.selectedIndex,
|
this.selectedIndex,
|
||||||
this.getTabInfo({
|
this.getTabInfo({
|
||||||
path: this.defaultTabs[inArg.data.routerLink].path,
|
path: this.defaultTabs[inArg.data.routerLink].path,
|
||||||
id: Number(this.route.snapshot.queryParams.uuid),
|
tabData: this.apiDataItems[this.route.snapshot.queryParams.uuid],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -266,7 +272,7 @@ export class ApiTabComponent implements OnInit, OnDestroy {
|
|||||||
this.selectedIndex,
|
this.selectedIndex,
|
||||||
this.getTabInfo({
|
this.getTabInfo({
|
||||||
path: this.defaultTabs['edit'].path,
|
path: this.defaultTabs['edit'].path,
|
||||||
apiData: inArg.data,
|
tabData: inArg.data,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -292,13 +298,12 @@ export class ApiTabComponent implements OnInit, OnDestroy {
|
|||||||
* @param apiData tab content api data
|
* @param apiData tab content api data
|
||||||
* @returns {TabItem}
|
* @returns {TabItem}
|
||||||
*/
|
*/
|
||||||
private getTabInfo(inArg: { id?: number; apiData?: any; path?: string }) {
|
private getTabInfo(inArg: { tabData: any; path?: string }) {
|
||||||
let apiData = inArg.apiData || this.apiDataItems[inArg.id];
|
|
||||||
const result = {
|
const result = {
|
||||||
path: inArg.path || this.router.url.split('?')[0],
|
path: inArg.path || this.router.url.split('?')[0],
|
||||||
title: apiData.name,
|
title: inArg.tabData.name,
|
||||||
method: apiData.method,
|
method: inArg.tabData.method,
|
||||||
key: apiData.uuid?.toString(),
|
key: inArg.tabData.uuid?.toString(),
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user