Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
9fb6f094ad
|
@ -51,7 +51,7 @@
|
|||
TokenKey,
|
||||
WORKSPACE_ID
|
||||
} from '../../../../common/js/constants';
|
||||
import {hasRoles, saveLocalStorage} from "../../../../common/js/utils";
|
||||
import {getCurrentUser, hasRoles, saveLocalStorage} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsUser",
|
||||
|
@ -68,7 +68,7 @@
|
|||
{index: '2-1', name: '无工作空间'},
|
||||
],
|
||||
currentUserInfo: {},
|
||||
currentUserId: JSON.parse(localStorage.getItem(TokenKey)).id,
|
||||
currentUserId: getCurrentUser().id,
|
||||
workspaceIds: [],
|
||||
currentOrganizationName: '选择组织',
|
||||
currentWorkspaceName: '选择工作空间'
|
||||
|
@ -76,9 +76,7 @@
|
|||
},
|
||||
computed: {
|
||||
currentUser: () => {
|
||||
let user = localStorage.getItem(TokenKey);
|
||||
// window.console.log(user);
|
||||
return JSON.parse(user);
|
||||
return getCurrentUser();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -44,11 +44,11 @@
|
|||
<script>
|
||||
import MsCreateBox from "../settings/CreateBox";
|
||||
import {Message} from "element-ui";
|
||||
import {TokenKey} from "../../../common/js/constants";
|
||||
import MsTablePagination from "../common/pagination/TablePagination";
|
||||
import MsTableHeader from "../common/components/MsTableHeader";
|
||||
import MsTableOperator from "../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../common/components/MsDialogFooter";
|
||||
import {getCurrentUser} from "../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsProject",
|
||||
|
@ -97,8 +97,7 @@
|
|||
},
|
||||
computed: {
|
||||
currentUser: () => {
|
||||
let user = localStorage.getItem(TokenKey);
|
||||
return JSON.parse(user);
|
||||
return getCurrentUser();
|
||||
}
|
||||
},
|
||||
destroyed() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {TokenKey} from "../../../common/js/constants";
|
||||
import {getCurrentUser} from "../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsCurrentUser",
|
||||
|
@ -30,8 +30,7 @@
|
|||
},
|
||||
computed: {
|
||||
currentUser: () => {
|
||||
let user = localStorage.getItem(TokenKey);
|
||||
return JSON.parse(user);
|
||||
return getCurrentUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,12 +95,12 @@
|
|||
|
||||
<script>
|
||||
import MsCreateBox from "../CreateBox";
|
||||
import {TokenKey} from "../../../../common/js/constants";
|
||||
import MsTablePagination from "../../common/pagination/TablePagination";
|
||||
import MsTableHeader from "../../common/components/MsTableHeader";
|
||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentUser} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsOrganizationMember",
|
||||
|
@ -134,8 +134,7 @@
|
|||
},
|
||||
methods: {
|
||||
currentUser: () => {
|
||||
let user = localStorage.getItem(TokenKey);
|
||||
return JSON.parse(user);
|
||||
return getCurrentUser();
|
||||
},
|
||||
initTableData() {
|
||||
let param = {
|
||||
|
|
|
@ -145,13 +145,13 @@
|
|||
<script>
|
||||
import MsCreateBox from "../CreateBox";
|
||||
import {Message} from "element-ui";
|
||||
import {DEFAULT, TokenKey} from "../../../../common/js/constants";
|
||||
import {DEFAULT} from "../../../../common/js/constants";
|
||||
import MsTablePagination from "../../common/pagination/TablePagination";
|
||||
import MsTableHeader from "../../common/components/MsTableHeader";
|
||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentWorkspaceId, refreshSessionAndCookies} from "../../../../common/js/utils";
|
||||
import {getCurrentUser, getCurrentWorkspaceId, refreshSessionAndCookies} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsOrganizationWorkspace",
|
||||
|
@ -161,8 +161,7 @@
|
|||
},
|
||||
computed: {
|
||||
currentUser: () => {
|
||||
let user = localStorage.getItem(TokenKey);
|
||||
return JSON.parse(user);
|
||||
return getCurrentUser();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
<script>
|
||||
import {TokenKey} from "../../../../common/js/constants";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentUser} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
@ -152,8 +153,7 @@
|
|||
},
|
||||
methods: {
|
||||
currentUser: () => {
|
||||
let user = localStorage.getItem(TokenKey);
|
||||
return JSON.parse(user);
|
||||
return getCurrentUser();
|
||||
},
|
||||
edit(row) {
|
||||
this.updateVisible = true;
|
||||
|
|
|
@ -97,12 +97,12 @@
|
|||
|
||||
<script>
|
||||
import MsCreateBox from "../CreateBox";
|
||||
import {TokenKey} from "../../../../common/js/constants";
|
||||
import MsTablePagination from "../../common/pagination/TablePagination";
|
||||
import MsTableHeader from "../../common/components/MsTableHeader";
|
||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentUser} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsMember",
|
||||
|
@ -136,8 +136,7 @@
|
|||
},
|
||||
methods: {
|
||||
currentUser: () => {
|
||||
let user = localStorage.getItem(TokenKey);
|
||||
return JSON.parse(user);
|
||||
return getCurrentUser();
|
||||
},
|
||||
initTableData() {
|
||||
if (this.currentUser().lastWorkspaceId === null) {
|
||||
|
|
|
@ -9,13 +9,13 @@ import {
|
|||
import axios from "axios";
|
||||
|
||||
export function hasRole(role) {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
let user = getCurrentUser();
|
||||
let roles = user.roles.map(r => r.id);
|
||||
return roles.indexOf(role) > -1;
|
||||
}
|
||||
|
||||
export function hasRoles(...roles) {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
let user = getCurrentUser();
|
||||
let rs = user.roles.map(r => r.id);
|
||||
for (let item of roles) {
|
||||
if (rs.indexOf(item) > -1) {
|
||||
|
@ -26,24 +26,24 @@ export function hasRoles(...roles) {
|
|||
}
|
||||
|
||||
export function checkoutCurrentOrganization() {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
let user = getCurrentUser();
|
||||
// 查看当前用户是否是 lastOrganizationId 的组织管理员
|
||||
return user.userRoles.filter(ur => hasRole(ROLE_ORG_ADMIN) && user.lastOrganizationId === ur.sourceId).length > 0;
|
||||
}
|
||||
|
||||
export function checkoutCurrentWorkspace() {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
let user = getCurrentUser();
|
||||
// 查看当前用户是否是 lastWorkspaceId 的工作空间用户
|
||||
return user.userRoles.filter(ur => hasRoles(ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER) && user.lastWorkspaceId === ur.sourceId).length > 0;
|
||||
}
|
||||
|
||||
export function getCurrentOrganizationId() {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
let user = getCurrentUser();
|
||||
return user.lastOrganizationId;
|
||||
}
|
||||
|
||||
export function getCurrentWorkspaceId() {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
let user = getCurrentUser();
|
||||
return user.lastWorkspaceId;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue