fix(系统设置): 超级管理员项目列表跳转权限问题

--bug=1022460 --user=李玉号 【系统设置】超级管理员权限的用户在系统设置 - 工作空间 -
项目管理列表,点击项目名称,提示没有权限 https://www.tapd.cn/55049933/s/1331705
This commit is contained in:
shiziyuan9527 2023-02-06 15:25:51 +08:00 committed by lyh
parent e5733db8c1
commit 30260b1817
2 changed files with 26 additions and 12 deletions

View File

@ -108,3 +108,7 @@ export function updateSeleniumServer(data) {
export function modifyUserByResourceId(resourceId) { export function modifyUserByResourceId(resourceId) {
return get(`/user/update/current-by-resource/${resourceId}`); return get(`/user/update/current-by-resource/${resourceId}`);
} }
export function isSuperUser(userId) {
return get(`/user/is/super/${userId}`);
}

View File

@ -195,6 +195,7 @@ import {PROJECT_CONFIGS} from "metersphere-frontend/src/components/search/search
import MsRolesTag from "metersphere-frontend/src/components/MsRolesTag"; import MsRolesTag from "metersphere-frontend/src/components/MsRolesTag";
import MsInstructionsIcon from "metersphere-frontend/src/components/MsInstructionsIcon"; import MsInstructionsIcon from "metersphere-frontend/src/components/MsInstructionsIcon";
import AddMember from "../../common/AddMember"; import AddMember from "../../common/AddMember";
import {isSuperUser} from "metersphere-frontend/src/api/user.js";
import { import {
addProjectMember, addProjectMember,
delProjectMember, delProjectMember,
@ -308,21 +309,30 @@ export default {
let {listObject} = res.data; let {listObject} = res.data;
this.memberLineData = listObject; this.memberLineData = listObject;
let arr = this.memberLineData.filter(item => item.id === getCurrentUserId()); let arr = this.memberLineData.filter(item => item.id === getCurrentUserId());
if (arr <= 0) { if (arr.length > 0) {
this.$warning(this.$t("commons.project_permission")); this.doJump(row);
return; } else {
} isSuperUser(getCurrentUserId()).then(r => {
// last_project_id if (r && r.data) {
sessionStorage.setItem(PROJECT_ID, row.id); this.doJump(row);
const loading = fullScreenLoading(this); } else {
switchProject({id: getCurrentUserId(), lastProjectId: row.id}).then(() => { this.$warning(this.$t("commons.project_permission"));
this.$router.push('/track/home').then(() => { }
location.reload();
stopFullScreenLoading(loading);
}); });
}) }
}); });
}, },
doJump(row) {
// last_project_id
sessionStorage.setItem(PROJECT_ID, row.id);
const loading = fullScreenLoading(this);
switchProject({id: getCurrentUserId(), lastProjectId: row.id}).then(() => {
this.$router.push('/track/home').then(() => {
location.reload();
stopFullScreenLoading(loading);
});
})
},
getMaintainerOptions() { getMaintainerOptions() {
getCurrentProjectUserList().then(res => { getCurrentProjectUserList().then(res => {
this.userFilters = res.data.map(u => { this.userFilters = res.data.map(u => {