Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TF-MOM-WEB
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TFMOM
TF-MOM-WEB
Commits
5be2c0ac
Commit
5be2c0ac
authored
Jan 24, 2024
by
jingnan
👀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并产品【测评】添加用户角色信息,区分账号类型
parent
428a77a3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
4 deletions
+70
-4
user.js
applications/architecture-dee/src/api/user.js
+3
-0
getters.js
applications/architecture-dee/src/store/getters.js
+2
-1
user.js
applications/architecture-dee/src/store/modules/user.js
+42
-3
util.js
applications/architecture-dee/src/utils/util.js
+23
-0
No files found.
applications/architecture-dee/src/api/user.js
View file @
5be2c0ac
...
@@ -65,3 +65,6 @@ export function getUserTheme() {
...
@@ -65,3 +65,6 @@ export function getUserTheme() {
export
function
getSecretMatrix
()
{
export
function
getSecretMatrix
()
{
return
get
(
'/SecretCodeMatrix/getSecretMatrix'
)
return
get
(
'/SecretCodeMatrix/getSecretMatrix'
)
}
}
export
function
getUserRole
(
userId
)
{
return
get
(
'/perm/Role/getUserRoleVO?userId='
+
userId
)
}
applications/architecture-dee/src/store/getters.js
View file @
5be2c0ac
...
@@ -59,6 +59,7 @@ const getters = {
...
@@ -59,6 +59,7 @@ const getters = {
tripleManage
:
state
=>
state
.
tripleManage
.
switch
,
tripleManage
:
state
=>
state
.
tripleManage
.
switch
,
getUserSecretMetrix
:
state
=>
state
.
secret
.
userSecretMetrix
,
getUserSecretMetrix
:
state
=>
state
.
secret
.
userSecretMetrix
,
breadcrumb
:
state
=>
state
.
breadcrumb
.
visitePath
,
breadcrumb
:
state
=>
state
.
breadcrumb
.
visitePath
,
viewSearchList
:
state
=>
state
.
viewSearchList
.
list
viewSearchList
:
state
=>
state
.
viewSearchList
.
list
,
ternaryUserInfo
:
state
=>
state
.
user
.
ternaryUserInfo
||
{}
}
}
export
default
getters
export
default
getters
applications/architecture-dee/src/store/modules/user.js
View file @
5be2c0ac
import
{
login
,
logout
}
from
'../../api/user'
import
{
login
,
logout
,
getUserRole
}
from
'../../api/user'
import
{
getAuditThresholeWarning
,
getUserLevel
}
from
'../../api/permission'
import
{
getAuditThresholeWarning
,
getUserLevel
}
from
'../../api/permission'
import
{
getToken
,
setToken
,
removeToken
}
from
'../../utils/auth'
import
{
getToken
,
setToken
,
removeToken
}
from
'../../utils/auth'
import
router
from
'../../router'
import
router
from
'../../router'
import
_get
from
'lodash.get'
import
_get
from
'lodash.get'
import
{
showMessage
,
showNotification
}
from
'../../utils/util'
import
{
showMessage
,
showNotification
,
setUserRoleInfo
,
getUserRoleInfo
}
from
'../../utils/util'
import
{
getUserInfo
,
downloadFileById
}
from
'@/api/usercenter'
import
{
getUserInfo
,
downloadFileById
}
from
'@/api/usercenter'
// import store from '@/store'
// import store from '@/store'
function
base64ToUint8Array
(
base64String
)
{
function
base64ToUint8Array
(
base64String
)
{
...
@@ -23,7 +23,9 @@ function base64ToUint8Array(base64String) {
...
@@ -23,7 +23,9 @@ function base64ToUint8Array(base64String) {
const
state
=
{
const
state
=
{
token
:
getToken
(),
token
:
getToken
(),
userId
:
''
,
userId
:
''
,
userInfo
:
null
userInfo
:
null
,
// 三元用户标识
ternaryUserInfo
:
getUserRoleInfo
()
}
}
const
mutations
=
{
const
mutations
=
{
SET_TOKEN
:
(
state
,
token
)
=>
{
SET_TOKEN
:
(
state
,
token
)
=>
{
...
@@ -34,6 +36,10 @@ const mutations = {
...
@@ -34,6 +36,10 @@ const mutations = {
},
},
SET_USER_ID
:
(
state
,
userId
)
=>
{
SET_USER_ID
:
(
state
,
userId
)
=>
{
state
.
userId
=
userId
state
.
userId
=
userId
},
SET_TERNARY_USER_INFO
:
(
state
,
info
)
=>
{
setUserRoleInfo
(
info
)
state
.
ternaryUserInfo
=
info
}
}
}
}
const
actions
=
{
const
actions
=
{
...
@@ -96,11 +102,43 @@ const actions = {
...
@@ -96,11 +102,43 @@ const actions = {
localStorage
.
setItem
(
'token'
,
token
)
localStorage
.
setItem
(
'token'
,
token
)
showMessage
(
'登录成功!'
,
'success'
)
showMessage
(
'登录成功!'
,
'success'
)
localStorage
.
setItem
(
'org'
,
response
.
items
.
userVO
.
dxOrganizationId
)
localStorage
.
setItem
(
'org'
,
response
.
items
.
userVO
.
dxOrganizationId
)
// localStorage.setItem('org', JSON.stringify(orgInfo))
// 查询当前用户级别
// 查询当前用户级别
getUserLevel
().
then
(
res
=>
{
getUserLevel
().
then
(
res
=>
{
localStorage
.
setItem
(
'userLevel'
,
JSON
.
stringify
(
res
.
items
))
localStorage
.
setItem
(
'userLevel'
,
JSON
.
stringify
(
res
.
items
))
})
})
getUserRole
(
userVO
.
id
)
.
then
(
res
=>
{
const
roles
=
res
.
items
.
content
||
[]
const
syNames
=
[
'sysadmin'
,
'audadmin'
,
'secadmin'
]
// 是管理员
let
isAdmin
=
false
// 是系统管理员
let
isSysAdmin
=
false
// 是审计管理员
let
isAudAdmin
=
false
// 是安全管理员
let
isSecAdmin
=
false
roles
.
forEach
(
m
=>
{
if
(
!
isAdmin
)
{
isAdmin
=
syNames
.
includes
(
m
.
name
)
}
if
(
!
isSysAdmin
)
{
isSysAdmin
=
m
.
name
===
'sysadmin'
}
if
(
!
isAudAdmin
)
{
isAudAdmin
=
m
.
name
===
'audadmin'
}
if
(
!
isSecAdmin
)
{
isSecAdmin
=
m
.
name
===
'secadmin'
}
})
commit
(
'SET_TERNARY_USER_INFO'
,
{
isAdmin
,
isSysAdmin
,
isAudAdmin
,
isSecAdmin
})
})
.
catch
(()
=>
{
commit
(
'SET_TERNARY_USER_INFO'
,
{})
})
// 获取审计日志阈值警告(仅内置用户可见)
// 获取审计日志阈值警告(仅内置用户可见)
if
(
userVO
&&
userVO
.
isInnerUser
)
{
if
(
userVO
&&
userVO
.
isInnerUser
)
{
getAuditThresholeWarning
().
then
(
res
=>
{
getAuditThresholeWarning
().
then
(
res
=>
{
...
@@ -139,6 +177,7 @@ const actions = {
...
@@ -139,6 +177,7 @@ const actions = {
localStorage
.
setItem
(
'org'
,
''
)
localStorage
.
setItem
(
'org'
,
''
)
commit
(
'SET_USER_INFO'
,
null
)
commit
(
'SET_USER_INFO'
,
null
)
commit
(
'SET_USER_ID'
,
''
)
commit
(
'SET_USER_ID'
,
''
)
commit
(
'SET_TERNARY_USER_INFO'
,
{})
resolve
(
response
)
resolve
(
response
)
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
if
(
error
.
items
===
401
)
{
if
(
error
.
items
===
401
)
{
...
...
applications/architecture-dee/src/utils/util.js
View file @
5be2c0ac
...
@@ -1545,6 +1545,27 @@ export function deepClone(obj) {
...
@@ -1545,6 +1545,27 @@ export function deepClone(obj) {
return objClone
return objClone
}
}
// 存储用户角色信息
export function setUserRoleInfo(data) {
localStorage.setItem('userRoleInfo', JSON.stringify(data))
}
// 获取用户角色类型信息
export function getUserRoleInfo(key) {
let data = null
try {
data = JSON.parse(localStorage.getItem('userRoleInfo'))
if (!(data && typeof data === 'object')) {
data = {}
}
} catch (e) {
data = {}
}
if (key) {
return data[key] || false
}
return data
}
export function fileByIdDownload(objName, objId, linkId) {
export function fileByIdDownload(objName, objId, linkId) {
downFileByFileId(objName, objId, linkId).then(res => {
downFileByFileId(objName, objId, linkId).then(res => {
this.downLoadFile(res)
this.downLoadFile(res)
...
@@ -1690,6 +1711,8 @@ export default {
...
@@ -1690,6 +1711,8 @@ export default {
groupBy,
groupBy,
filterParams,
filterParams,
deepClone,
deepClone,
setUserRoleInfo,
getUserRoleInfo,
fileByIdDownload,
fileByIdDownload,
findForm,
findForm,
sumArray,
sumArray,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment