refactor: 顶部切换工作空间菜单修改
This commit is contained in:
parent
2508965ab3
commit
88b6e742a7
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<el-menu :unique-opened="true" mode="horizontal" router
|
||||
<el-menu :unique-opened="true" mode="horizontal"
|
||||
router
|
||||
class="header-user-menu align-right"
|
||||
:background-color="color"
|
||||
active-text-color="#fff"
|
||||
|
@ -11,10 +12,10 @@
|
|||
'PROJECT_API_DEFINITION:READ','PROJECT_API_SCENARIO:READ','PROJECT_API_REPORT:READ',
|
||||
'PROJECT_PERFORMANCE_TEST:READ','PROJECT_PERFORMANCE_REPORT:READ', 'ORGANIZATION_USER:READ',
|
||||
'WORKSPACE_USER:READ']">
|
||||
<template v-slot:title>{{ $t('commons.organization') }}:
|
||||
<span class="org-ws-name" :title="currentOrganizationName">
|
||||
{{ currentOrganizationName }}
|
||||
</span>
|
||||
<template v-slot:title>
|
||||
<div class="org-ws-name" :title="currentOrganizationName + '-' + currentWorkspaceName">
|
||||
<div>{{ currentWorkspaceName || currentOrganizationName }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-input :placeholder="$t('project.search_by_name')"
|
||||
prefix-icon="el-icon-search"
|
||||
|
@ -23,24 +24,12 @@
|
|||
class="search-input"
|
||||
size="small"/>
|
||||
<div class="org-ws-menu">
|
||||
<el-menu-item @click="changeOrg(item)" v-for="(item,index) in organizationList" :key="index">
|
||||
<span class="title">
|
||||
<el-submenu :index="1+'-'+index" v-for="(item, index) in organizationList" :key="index">
|
||||
<template v-slot:title>
|
||||
<div @click="changeOrg(item)">
|
||||
{{ item.name }}
|
||||
</span>
|
||||
<i class="el-icon-check"
|
||||
v-if="item.id === getCurrentOrganizationId()"></i>
|
||||
</el-menu-item>
|
||||
<i class="el-icon-check" v-if="item.id === getCurrentOrganizationId()"></i>
|
||||
</div>
|
||||
</el-submenu>
|
||||
<el-submenu index="2" popper-class="submenu"
|
||||
v-permission="['PROJECT_TRACK_CASE:READ','PROJECT_TRACK_PLAN:READ','PROJECT_TRACK_REVIEW:READ',
|
||||
'PROJECT_API_DEFINITION:READ','PROJECT_API_SCENARIO:READ','PROJECT_API_REPORT:READ',
|
||||
'PROJECT_PERFORMANCE_TEST:READ','PROJECT_PERFORMANCE_REPORT:READ','WORKSPACE_USER:READ']"
|
||||
>
|
||||
<template v-slot:title>{{ $t('commons.workspace') }}:
|
||||
<span class="org-ws-name" :title="currentWorkspaceName">
|
||||
{{ currentWorkspaceName }}
|
||||
</span>
|
||||
</template>
|
||||
<el-input :placeholder="$t('project.search_by_name')"
|
||||
prefix-icon="el-icon-search"
|
||||
|
@ -49,14 +38,17 @@
|
|||
class="search-input"
|
||||
size="small"/>
|
||||
<div class="org-ws-menu">
|
||||
<el-menu-item @click="changeWs(item)" v-for="(item,index) in workspaceList" :key="index">
|
||||
<el-menu-item :index="1+'-'+index+'-'+index2" @click="changeWs(ws)"
|
||||
v-for="(ws,index2) in item.workspaceList" :key="index2">
|
||||
<span class="title">
|
||||
{{ item.name }}
|
||||
{{ ws.name }}
|
||||
</span>
|
||||
<i class="el-icon-check" v-if="item.id === getCurrentWorkspaceId()"></i>
|
||||
<i class="el-icon-check" v-if="ws.id === getCurrentWorkspaceId()"></i>
|
||||
</el-menu-item>
|
||||
</div>
|
||||
</el-submenu>
|
||||
</div>
|
||||
</el-submenu>
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
|
@ -120,11 +112,28 @@ export default {
|
|||
if (org.length > 0) {
|
||||
this.currentOrganizationName = org[0].name;
|
||||
}
|
||||
this.organizationList.forEach(org => {
|
||||
this.$get("/workspace/list/orgworkspace/" + org.id, response => {
|
||||
let d = response.data;
|
||||
if (d.length === 0) {
|
||||
// org.workspaceList = [{name: this.$t('workspace.none')}];
|
||||
// this.$set(org, 'workspaceList', [{name: this.$t('workspace.none')}]);
|
||||
} else {
|
||||
this.$set(org, 'workspaceList', d);
|
||||
// org.workspaceList = d;
|
||||
org.wsListCopy = d;
|
||||
let workspace = d.filter(r => r.id === getCurrentWorkspaceId());
|
||||
if (workspace.length > 0) {
|
||||
this.currentWorkspaceName = workspace[0].name;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
if (!this.currentUser.lastOrganizationId) {
|
||||
return false;
|
||||
}
|
||||
this.$get("/workspace/list/orgworkspace/" + getCurrentOrganizationId(), response => {
|
||||
/*this.$get("/workspace/list/orgworkspace/" + getCurrentOrganizationId(), response => {
|
||||
let data = response.data;
|
||||
if (data.length === 0) {
|
||||
this.workspaceList = [{name: this.$t('workspace.none')}];
|
||||
|
@ -136,7 +145,7 @@ export default {
|
|||
this.currentWorkspaceName = workspace[0].name;
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
},
|
||||
getCurrentUserInfo() {
|
||||
this.$get("/user/info/" + encodeURIComponent(this.currentUserId), response => {
|
||||
|
@ -167,6 +176,8 @@ export default {
|
|||
}
|
||||
this.$post("/user/switch/source/ws/" + workspaceId, {}, response => {
|
||||
saveLocalStorage(response);
|
||||
|
||||
sessionStorage.setItem(ORGANIZATION_ID, response.data.lastOrganizationId);
|
||||
sessionStorage.setItem(WORKSPACE_ID, workspaceId);
|
||||
sessionStorage.setItem(PROJECT_ID, response.data.lastProjectId);
|
||||
|
||||
|
@ -180,7 +191,10 @@ export default {
|
|||
this.organizationList = queryString ? this.orgListCopy.filter(this.createFilter(queryString)) : this.orgListCopy;
|
||||
}
|
||||
if (sign === 'ws') {
|
||||
this.workspaceList = queryString ? this.wsListCopy.filter(this.createFilter(queryString)) : this.wsListCopy;
|
||||
this.organizationList.forEach(org => {
|
||||
let wsListCopy = org.wsListCopy;
|
||||
org.workspaceList = queryString ? wsListCopy?.filter(this.createFilter(queryString)) : wsListCopy;
|
||||
});
|
||||
}
|
||||
},
|
||||
createFilter(queryString) {
|
||||
|
|
Loading…
Reference in New Issue