refactor: 页面切换去掉组织这一项
This commit is contained in:
parent
9374b38035
commit
75c8407ac6
|
@ -6,13 +6,15 @@ import io.metersphere.base.mapper.GroupMapper;
|
||||||
import io.metersphere.base.mapper.ProjectMapper;
|
import io.metersphere.base.mapper.ProjectMapper;
|
||||||
import io.metersphere.base.mapper.UserGroupMapper;
|
import io.metersphere.base.mapper.UserGroupMapper;
|
||||||
import io.metersphere.base.mapper.WorkspaceMapper;
|
import io.metersphere.base.mapper.WorkspaceMapper;
|
||||||
import io.metersphere.base.mapper.ext.*;
|
import io.metersphere.base.mapper.ext.ExtOrganizationMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtUserGroupMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtUserMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtWorkspaceMapper;
|
||||||
import io.metersphere.commons.constants.UserGroupConstants;
|
import io.metersphere.commons.constants.UserGroupConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.controller.request.WorkspaceRequest;
|
import io.metersphere.controller.request.WorkspaceRequest;
|
||||||
import io.metersphere.dto.RelatedSource;
|
import io.metersphere.dto.RelatedSource;
|
||||||
import io.metersphere.dto.UserRoleHelpDTO;
|
|
||||||
import io.metersphere.dto.WorkspaceDTO;
|
import io.metersphere.dto.WorkspaceDTO;
|
||||||
import io.metersphere.dto.WorkspaceMemberDTO;
|
import io.metersphere.dto.WorkspaceMemberDTO;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
|
@ -40,8 +42,6 @@ public class WorkspaceService {
|
||||||
@Resource
|
@Resource
|
||||||
private ExtWorkspaceMapper extWorkspaceMapper;
|
private ExtWorkspaceMapper extWorkspaceMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtUserRoleMapper extUserRoleMapper;
|
|
||||||
@Resource
|
|
||||||
private GroupMapper groupMapper;
|
private GroupMapper groupMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtOrganizationMapper extOrganizationMapper;
|
private ExtOrganizationMapper extOrganizationMapper;
|
||||||
|
@ -195,15 +195,14 @@ public class WorkspaceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Workspace> getWorkspaceListByUserId(String userId) {
|
public List<Workspace> getWorkspaceListByUserId(String userId) {
|
||||||
List<UserRoleHelpDTO> userRoleHelpList = extUserRoleMapper.getUserRoleHelpList(userId);
|
List<RelatedSource> relatedSource = extUserGroupMapper.getRelatedSource(userId);
|
||||||
List<String> workspaceIds = new ArrayList<>();
|
List<String> wsIds = relatedSource
|
||||||
userRoleHelpList.forEach(r -> {
|
.stream()
|
||||||
if (!StringUtils.isEmpty(r.getParentId())) {
|
.map(RelatedSource::getWorkspaceId)
|
||||||
workspaceIds.add(r.getSourceId());
|
.distinct()
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
});
|
|
||||||
WorkspaceExample workspaceExample = new WorkspaceExample();
|
WorkspaceExample workspaceExample = new WorkspaceExample();
|
||||||
workspaceExample.createCriteria().andIdIn(workspaceIds);
|
workspaceExample.createCriteria().andIdIn(wsIds);
|
||||||
return workspaceMapper.selectByExample(workspaceExample);
|
return workspaceMapper.selectByExample(workspaceExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1,38 @@
|
||||||
alter table test_plan drop column principal;
|
ALTER TABLE test_plan
|
||||||
|
DROP COLUMN principal;
|
||||||
|
|
||||||
|
-- 组织用户组配置到工作空间上
|
||||||
|
DROP PROCEDURE IF EXISTS test_cursor;
|
||||||
|
DELIMITER //
|
||||||
|
CREATE PROCEDURE test_cursor()
|
||||||
|
BEGIN
|
||||||
|
DECLARE sourceId VARCHAR(64);
|
||||||
|
DECLARE userId VARCHAR(64);
|
||||||
|
DECLARE groupId VARCHAR(64);
|
||||||
|
DECLARE done INT DEFAULT 0;
|
||||||
|
DECLARE cursor1 CURSOR FOR (SELECT user_id, source_id, group_id
|
||||||
|
FROM user_group
|
||||||
|
WHERE group_id IN ('org_admin', 'org_member'));
|
||||||
|
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||||
|
OPEN cursor1;
|
||||||
|
outer_loop:
|
||||||
|
LOOP
|
||||||
|
FETCH cursor1 INTO userId, sourceId, groupId;
|
||||||
|
IF done
|
||||||
|
THEN
|
||||||
|
LEAVE outer_loop;
|
||||||
|
END IF;
|
||||||
|
INSERT INTO user_group (id, user_id, group_id, source_id, create_time, update_time)
|
||||||
|
SELECT UUID(), userId, REPLACE(groupId, 'org', 'ws'), id, create_time, update_time
|
||||||
|
FROM workspace
|
||||||
|
WHERE organization_id = sourceId;
|
||||||
|
END LOOP;
|
||||||
|
CLOSE cursor1;
|
||||||
|
END
|
||||||
|
//
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
CALL test_cursor();
|
||||||
|
DROP PROCEDURE IF EXISTS test_cursor;
|
|
@ -1,57 +1,19 @@
|
||||||
<template>
|
<template>
|
||||||
<el-menu :unique-opened="true" mode="horizontal"
|
<el-dropdown size="medium" @command="changeWs" class="align-right">
|
||||||
class="header-user-menu align-right"
|
<span class="dropdown-link">
|
||||||
:background-color="color"
|
{{ currentWorkspaceName }}<i class="el-icon-caret-bottom el-icon--right"/>
|
||||||
active-text-color="#fff"
|
</span>
|
||||||
default-active="1"
|
<template v-slot:dropdown>
|
||||||
text-color="#fff">
|
<el-dropdown-menu v-permission="['PROJECT_TRACK_CASE:READ','PROJECT_TRACK_PLAN:READ','PROJECT_TRACK_REVIEW:READ',
|
||||||
<el-menu-item index="1" v-show="false">Placeholder</el-menu-item>
|
|
||||||
<el-submenu index="1" popper-class="org-ws-submenu"
|
|
||||||
:popper-append-to-body="true"
|
|
||||||
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_API_DEFINITION:READ','PROJECT_API_SCENARIO:READ','PROJECT_API_REPORT:READ',
|
||||||
'PROJECT_PERFORMANCE_TEST:READ','PROJECT_PERFORMANCE_REPORT:READ', 'ORGANIZATION_USER:READ',
|
'PROJECT_PERFORMANCE_TEST:READ','PROJECT_PERFORMANCE_REPORT:READ', 'ORGANIZATION_USER:READ',
|
||||||
'WORKSPACE_USER:READ']">
|
'WORKSPACE_USER:READ']">
|
||||||
<template v-slot:title>
|
<el-dropdown-item :command="item" v-for="(item, index) in workspaceList" :key="index">
|
||||||
<div class="org-ws-name" :title="currentOrganizationName + '-' + currentWorkspaceName">
|
{{ item.name }} <i class="el-icon-check" v-if="getCurrentWorkspaceId === item.id"/>
|
||||||
{{ currentWorkspaceName || currentOrganizationName }}
|
</el-dropdown-item>
|
||||||
</div>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
<el-input :placeholder="$t('project.search_by_name')"
|
</el-dropdown>
|
||||||
prefix-icon="el-icon-search"
|
|
||||||
v-model="searchOrg"
|
|
||||||
clearable
|
|
||||||
class="search-input"
|
|
||||||
size="small"/>
|
|
||||||
<div class="org-ws-menu">
|
|
||||||
<el-submenu :index="1+'-'+index" v-for="(item, index) in organizationList"
|
|
||||||
:popper-append-to-body="true"
|
|
||||||
:key="index">
|
|
||||||
<template v-slot:title>
|
|
||||||
<el-menu-item @click="changeOrg(item)">
|
|
||||||
{{ item.name }}
|
|
||||||
<i class="el-icon-check" v-if="item.id === getCurrentOrganizationId()"></i>
|
|
||||||
</el-menu-item>
|
|
||||||
</template>
|
|
||||||
<el-input :placeholder="$t('project.search_by_name')"
|
|
||||||
prefix-icon="el-icon-search"
|
|
||||||
v-model="searchWs"
|
|
||||||
clearable
|
|
||||||
class="search-input"
|
|
||||||
size="small"/>
|
|
||||||
<div class="org-ws-menu">
|
|
||||||
<el-menu-item @click="changeWs(ws)"
|
|
||||||
v-for="(ws,index2) in item.workspaceList" :key="index2">
|
|
||||||
<span class="title">
|
|
||||||
{{ ws.name }}
|
|
||||||
</span>
|
|
||||||
<i class="el-icon-check" v-if="ws.id === getCurrentWorkspaceId()"></i>
|
|
||||||
</el-menu-item>
|
|
||||||
</div>
|
|
||||||
</el-submenu>
|
|
||||||
</div>
|
|
||||||
</el-submenu>
|
|
||||||
</el-menu>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -60,7 +22,8 @@ import {
|
||||||
getCurrentOrganizationId,
|
getCurrentOrganizationId,
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
getCurrentWorkspaceId,
|
getCurrentWorkspaceId,
|
||||||
saveLocalStorage, stopFullScreenLoading
|
saveLocalStorage,
|
||||||
|
stopFullScreenLoading
|
||||||
} from "@/common/js/utils";
|
} from "@/common/js/utils";
|
||||||
import {ORGANIZATION_ID, PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
|
import {ORGANIZATION_ID, PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
|
||||||
|
|
||||||
|
@ -77,12 +40,9 @@ export default {
|
||||||
organizationList: [
|
organizationList: [
|
||||||
{name: this.$t('organization.none')},
|
{name: this.$t('organization.none')},
|
||||||
],
|
],
|
||||||
workspaceList: [
|
workspaceList: [],
|
||||||
{name: this.$t('workspace.none')},
|
|
||||||
],
|
|
||||||
currentUserId: getCurrentUser().id,
|
currentUserId: getCurrentUser().id,
|
||||||
workspaceIds: [],
|
workspaceIds: [],
|
||||||
currentOrganizationName: '',
|
|
||||||
currentWorkspaceName: '',
|
currentWorkspaceName: '',
|
||||||
searchOrg: '',
|
searchOrg: '',
|
||||||
searchWs: '',
|
searchWs: '',
|
||||||
|
@ -110,48 +70,13 @@ export default {
|
||||||
getCurrentOrganizationId,
|
getCurrentOrganizationId,
|
||||||
getCurrentWorkspaceId,
|
getCurrentWorkspaceId,
|
||||||
initMenuData() {
|
initMenuData() {
|
||||||
this.$get("/organization/list/userorg/" + encodeURIComponent(this.currentUserId), response => {
|
this.$get("/workspace/list/userworkspace/" + encodeURIComponent(this.currentUserId), response => {
|
||||||
let data = response.data;
|
this.workspaceList = response.data;
|
||||||
this.organizationList = data;
|
let workspace = response.data.filter(r => r.id === getCurrentWorkspaceId());
|
||||||
this.orgListCopy = data;
|
|
||||||
let org = data.filter(r => r.id === getCurrentOrganizationId());
|
|
||||||
if (org.length > 0) {
|
|
||||||
this.currentOrganizationName = org[0].name;
|
|
||||||
}
|
|
||||||
this.organizationList.forEach(org => {
|
|
||||||
this.$get("/workspace/list/orgworkspace/" + encodeURIComponent(this.currentUserId) + "/" + 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) {
|
if (workspace.length > 0) {
|
||||||
this.currentWorkspaceName = workspace[0].name;
|
this.currentWorkspaceName = workspace[0].name;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
if (!this.currentUser.lastOrganizationId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/*this.$get("/workspace/list/orgworkspace/" + getCurrentOrganizationId(), response => {
|
|
||||||
let data = response.data;
|
|
||||||
if (data.length === 0) {
|
|
||||||
this.workspaceList = [{name: this.$t('workspace.none')}];
|
|
||||||
} else {
|
|
||||||
this.workspaceList = data;
|
|
||||||
this.wsListCopy = data;
|
|
||||||
let workspace = data.filter(r => r.id === getCurrentWorkspaceId());
|
|
||||||
if (workspace.length > 0) {
|
|
||||||
this.currentWorkspaceName = workspace[0].name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
},
|
},
|
||||||
getRedirectUrl(user) {
|
getRedirectUrl(user) {
|
||||||
// console.log(user);
|
// console.log(user);
|
||||||
|
@ -288,4 +213,17 @@ export default {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-link {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgb(245, 245, 245);
|
||||||
|
line-height: 40px;
|
||||||
|
padding-right: 10px;
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.align-right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue