Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
qa-platform-ui
Commits
f2827f07
Commit
f2827f07
authored
Jun 29, 2021
by
晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权判断
parent
a47950c9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
8 deletions
+57
-8
index.js
src/directives/index.js
+7
-0
permission.js
src/directives/permission.js
+15
-0
main.js
src/main.js
+2
-0
user.js
src/store/modules/user.js
+8
-4
hasPermission.js
src/utils/hasPermission.js
+8
-0
ProjectList.vue
src/views/auto/ProjectList.vue
+8
-1
Aside.vue
src/views/layout/leftAside/Aside.vue
+9
-3
No files found.
src/directives/index.js
0 → 100644
View file @
f2827f07
import
permission
from
'
./permission
'
export
default
{
install
(
Vue
)
{
Vue
.
directive
(
'
permission
'
,
permission
)
}
}
src/directives/permission.js
0 → 100644
View file @
f2827f07
import
{
hasPermission
}
from
'
../utils/hasPermission
'
export
default
{
inserted
:
function
(
el
,
binding
)
{
let
{
value
,
modifiers
}
=
binding
// 通过|分割开的权限,满足任意一种即可. 此处可以自己拓展&来处理[且]的关系,
// 更复杂的 &| 的关系可以 v-if="hasPerm('a:b') & .. | .." 来实现
let
keys
=
value
&&
value
.
trim
()
!==
''
?
value
.
split
(
'
|
'
)
:
Object
.
keys
(
modifiers
)
if
(
keys
&&
keys
.
length
)
{
let
hasAuth
=
keys
.
some
(
key
=>
hasPermission
(
key
))
!
hasAuth
&&
el
.
parentNode
.
removeChild
(
el
)
}
}
}
src/main.js
View file @
f2827f07
...
@@ -12,6 +12,7 @@ import axios from 'axios'
...
@@ -12,6 +12,7 @@ import axios from 'axios'
import
store
from
'
./store/store
'
import
store
from
'
./store/store
'
import
JsonViewer
from
'
vue-json-viewer
'
import
JsonViewer
from
'
vue-json-viewer
'
import
bus
from
'
../src/utils/bus
'
import
bus
from
'
../src/utils/bus
'
import
directives
from
'
@/directives
'
// import Sortable from 'sortablejs'
// import Sortable from 'sortablejs'
import
{
import
{
...
@@ -97,6 +98,7 @@ Vue.use(Row)
...
@@ -97,6 +98,7 @@ Vue.use(Row)
Vue
.
use
(
Col
)
Vue
.
use
(
Col
)
Vue
.
use
(
JsonViewer
)
Vue
.
use
(
JsonViewer
)
Vue
.
use
(
Tooltip
)
Vue
.
use
(
Tooltip
)
Vue
.
use
(
directives
)
// Vue.use(Sortable)
// Vue.use(Sortable)
/* eslint-disable no-new */
/* eslint-disable no-new */
...
...
src/store/modules/user.js
View file @
f2827f07
const
state
=
{
const
state
=
{
userId
:
'
123
'
,
userId
:
''
,
username
:
''
,
username
:
''
,
menuList
:
[],
menuList
:
[],
roleIds
:
[],
roleIds
:
[],
...
@@ -7,8 +7,8 @@ const state = {
...
@@ -7,8 +7,8 @@ const state = {
}
}
const
mutations
=
{
const
mutations
=
{
SET_USER
:
(
state
,
userInfo
)
=>
{
SET_USER
(
state
,
userInfo
)
{
state
.
userId
=
userInfo
.
i
d
state
.
userId
=
userInfo
.
userI
d
state
.
username
=
userInfo
.
username
state
.
username
=
userInfo
.
username
state
.
menuList
=
userInfo
.
menuList
state
.
menuList
=
userInfo
.
menuList
state
.
roleIds
=
userInfo
.
roleIds
state
.
roleIds
=
userInfo
.
roleIds
...
@@ -25,12 +25,16 @@ const mutations = {
...
@@ -25,12 +25,16 @@ const mutations = {
const
getters
=
{
const
getters
=
{
UserId
:
state
=>
{
UserId
:
state
=>
{
return
state
.
userId
return
state
.
userId
},
PermissionList
:
state
=>
{
return
state
.
permissionCodeList
}
}
}
}
// 异步获取用户信息
const
actions
=
{
const
actions
=
{
userMsg
(
context
,
userInfo
)
{
userMsg
(
context
,
userInfo
)
{
console
.
log
(
'
用户信息
'
,
userInfo
)
console
.
log
(
'
用户信息
'
,
userInfo
)
context
.
commit
(
'
SET_USER
'
,
userInfo
)
context
.
commit
(
'
SET_USER
'
,
userInfo
.
userInfo
)
}
}
}
}
...
...
src/utils/hasPermission.js
0 → 100644
View file @
f2827f07
// import store from '../store/store'
export
function
hasPermission
(
permission
)
{
permission
=
permission
.
trim
()
let
myPermissions
=
this
.
$store
.
user
.
getters
.
PermissionList
console
.
log
(
'
111
'
,
myPermissions
)
return
myPermissions
.
indexOf
(
permission
)
>
-
1
}
src/views/auto/ProjectList.vue
View file @
f2827f07
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<el-button
type=
"primary"
icon=
"el-icon-search"
@
click=
"searchMockList"
>
查询
</el-button>
-->
<el-button
type=
"primary"
icon=
"el-icon-search"
@
click=
"searchMockList"
>
查询
</el-button>
-->
<!--
<el-button
type=
"primary"
icon=
"el-icon-circle-plus"
@
click=
"DialogAddVisible=true"
>
新增
</el-button>
-->
<!--
<el-button
type=
"primary"
icon=
"el-icon-circle-plus"
@
click=
"DialogAddVisible=true"
>
新增
</el-button>
-->
<el-button
type=
"primary"
icon=
"el-icon-circle-plus"
@
click=
"DialogAddVisible=true"
>
新增
</el-button>
<el-button
type=
"primary"
icon=
"el-icon-circle-plus"
@
click=
"DialogAddVisible=true"
v-permission=
"'auto:project:add'"
>
新增
</el-button>
</div>
</div>
<el-table
:data=
"projectList"
border
style=
"width: 100%;margin-top:20px"
>
<el-table
:data=
"projectList"
border
style=
"width: 100%;margin-top:20px"
>
<el-table-column
type=
'index'
width=
"50px"
>
<el-table-column
type=
'index'
width=
"50px"
>
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
</template>
</template>
<
script
>
<
script
>
import
{
mapGetters
}
from
'
vuex
'
import
{
import
{
getProjectList
,
getProjectList
,
addProject
,
addProject
,
...
@@ -112,6 +113,12 @@ export default {
...
@@ -112,6 +113,12 @@ export default {
created
()
{
created
()
{
this
.
getProjectList
()
this
.
getProjectList
()
},
},
computed
:
{
...
mapGetters
({
// 获取权限信息
getPermissionList
:
'
user/PermissionList
'
})
},
methods
:
{
methods
:
{
// 获取项目列表
// 获取项目列表
getProjectList
()
{
getProjectList
()
{
...
...
src/views/layout/leftAside/Aside.vue
View file @
f2827f07
...
@@ -93,9 +93,14 @@ export default {
...
@@ -93,9 +93,14 @@ export default {
// 获取用户详细信息
// 获取用户详细信息
getUserDetail
()
{
getUserDetail
()
{
getUserDetail
().
then
((
resp
)
=>
{
getUserDetail
().
then
((
resp
)
=>
{
this
.
$store
.
dispatch
(
'
user/userMsg
'
,
{
// 异步调用action
userInfo
:
resp
.
data
.
data
// this.$store.dispatch('user/userMsg', {
})
// userInfo: resp.data.data
// })
// 同步赋值mutations
this
.
$store
.
commit
(
'
user/SET_USER
'
,
resp
.
data
.
data
)
console
.
log
(
this
.
getUserId
)
console
.
log
(
this
.
getUserId
)
this
.
menuList
=
resp
.
data
.
data
.
menuList
this
.
menuList
=
resp
.
data
.
data
.
menuList
this
.
getNav
()
this
.
getNav
()
...
@@ -109,6 +114,7 @@ export default {
...
@@ -109,6 +114,7 @@ export default {
},
},
...
mapGetters
({
...
mapGetters
({
getCollapseState
:
'
header/CollapseState
'
,
getCollapseState
:
'
header/CollapseState
'
,
// 获取用户信息
getUserId
:
'
user/UserId
'
getUserId
:
'
user/UserId
'
})
})
},
},
...
...
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