Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
op-web-service
Project
Project
Details
Activity
Releases
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
bp
op-web-service
Commits
7d8954cd
Commit
7d8954cd
authored
Jul 26, 2021
by
Qingyu Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add authentication control
parent
1fe1f517
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
61 deletions
+94
-61
RoleList.vue
src/components/Roles/RoleList.vue
+40
-38
index.vue
src/components/UserList/index.vue
+4
-2
manage-role.vue
src/pages/Withdrawal/Role/manage-role.vue
+1
-0
config.js
src/pages/Withdrawal/components/PageHeader/config.js
+9
-6
index.vue
src/pages/Withdrawal/components/PageHeader/index.vue
+23
-13
index.js
src/store/index.js
+17
-2
No files found.
src/components/Roles/RoleList.vue
View file @
7d8954cd
...
@@ -141,31 +141,33 @@ import {
...
@@ -141,31 +141,33 @@ import {
getUpdate_role
as
reqGetUpdate_role
,
getUpdate_role
as
reqGetUpdate_role
,
get_role_info
as
reqGet_role_info
,
get_role_info
as
reqGet_role_info
,
getDelete_role
as
reqGetDelete_role
,
getDelete_role
as
reqGetDelete_role
,
getAdd_role
as
reqGetAdd_role
getAdd_role
as
reqGetAdd_role
,
}
from
"../../service/role"
;
}
from
"../../service/role"
;
export
default
{
export
default
{
name
:
"RoleList"
,
name
:
"RoleList"
,
props
:
[
"appId"
,
"detailPath"
],
props
:
[
"appId"
,
"detailPath"
,
"rolePermissionId"
],
components
:
{
components
:
{
page
page
,
},
},
computed
:
{
computed
:
{
permission
()
{
permission
()
{
let
rolePermissionId
=
this
.
role
||
"role"
;
let
appId
=
this
.
appId
||
""
;
const
modulePermissions
=
const
modulePermissions
=
this
.
$store
.
getters
.
moduleSubPermissions
(
"role"
)
||
[];
this
.
$store
.
getters
.
moduleSubPermissions
(
rolePermissionId
,
appId
)
||
[];
return
new
Map
(
modulePermissions
.
map
(
ele
=>
[
ele
.
name
,
true
]));
return
new
Map
(
modulePermissions
.
map
(
(
ele
)
=>
[
ele
.
name
,
true
]));
}
}
,
},
},
data
()
{
data
()
{
return
{
return
{
searchForm
:
{
searchForm
:
{
roleName
:
""
,
roleName
:
""
,
roleStatus
:
""
roleStatus
:
""
,
},
},
formLabelWidth
:
"120px"
,
formLabelWidth
:
"120px"
,
params
:
{
params
:
{
page
:
1
,
page
:
1
,
page_size
:
20
page_size
:
20
,
},
},
totalNum
:
null
,
totalNum
:
null
,
roleTitle
:
""
,
roleTitle
:
""
,
...
@@ -175,7 +177,7 @@ export default {
...
@@ -175,7 +177,7 @@ export default {
multiple
:
true
,
//设置为多选
multiple
:
true
,
//设置为多选
value
:
"id"
,
//value值和哪个值绑定
value
:
"id"
,
//value值和哪个值绑定
label
:
"desc"
,
//label值和哪个值绑定
label
:
"desc"
,
//label值和哪个值绑定
children
:
"sub_permissions"
//children值和哪个值绑定
children
:
"sub_permissions"
,
//children值和哪个值绑定
},
},
selectedOptions
:
[],
selectedOptions
:
[],
dialogVisible
:
false
,
dialogVisible
:
false
,
...
@@ -184,11 +186,11 @@ export default {
...
@@ -184,11 +186,11 @@ export default {
role_info_detail
:
{
role_info_detail
:
{
//详情非编辑项
//详情非编辑项
role_id
:
""
,
role_id
:
""
,
role_name
:
""
role_name
:
""
,
},
},
permissionsAll
:
[],
permissionsAll
:
[],
currenPermissionsUpdate
:
[],
currenPermissionsUpdate
:
[],
currentRolePrivilege
:
[]
currentRolePrivilege
:
[]
,
};
};
},
},
beforeMount
()
{
beforeMount
()
{
...
@@ -212,12 +214,12 @@ export default {
...
@@ -212,12 +214,12 @@ export default {
toRoleDetail
(
row
)
{
toRoleDetail
(
row
)
{
this
.
$router
.
push
({
this
.
$router
.
push
({
path
:
this
.
detailPath
,
path
:
this
.
detailPath
,
query
:
{
roleId
:
row
.
role_id
}
query
:
{
roleId
:
row
.
role_id
}
,
});
});
},
},
getPermissionsAll
()
{
getPermissionsAll
()
{
let
{
email
}
=
this
.
$store
.
state
.
userInfo
;
let
{
email
}
=
this
.
$store
.
state
.
userInfo
;
reqGetAll_role_list
(
email
,
this
.
appId
).
then
(
res
=>
{
reqGetAll_role_list
(
email
,
this
.
appId
).
then
(
(
res
)
=>
{
this
.
permissionsAll
=
res
.
permissions
;
this
.
permissionsAll
=
res
.
permissions
;
});
});
},
},
...
@@ -228,9 +230,9 @@ export default {
...
@@ -228,9 +230,9 @@ export default {
page
,
page
,
page_size
,
page_size
,
role_status
:
this
.
searchForm
.
roleStatus
,
role_status
:
this
.
searchForm
.
roleStatus
,
role_name
:
this
.
searchForm
.
roleName
role_name
:
this
.
searchForm
.
roleName
,
};
};
reqGetRole_list
(
paramsRole_list
,
this
.
appId
).
then
(
res
=>
{
reqGetRole_list
(
paramsRole_list
,
this
.
appId
).
then
(
(
res
)
=>
{
this
.
managementList
=
res
.
result
;
this
.
managementList
=
res
.
result
;
this
.
totalNum
=
res
.
count
;
this
.
totalNum
=
res
.
count
;
});
});
...
@@ -255,7 +257,7 @@ export default {
...
@@ -255,7 +257,7 @@ export default {
this
.
$confirm
(
`
${
this
.
dialogText
}
是否继续?`
,
"提示"
,
{
this
.
$confirm
(
`
${
this
.
dialogText
}
是否继续?`
,
"提示"
,
{
confirmButtonText
:
"确定"
,
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
type
:
"warning"
,
})
})
.
then
(()
=>
{
.
then
(()
=>
{
if
(
type
===
"disable"
)
{
if
(
type
===
"disable"
)
{
...
@@ -267,23 +269,23 @@ export default {
...
@@ -267,23 +269,23 @@ export default {
.
catch
(()
=>
{
.
catch
(()
=>
{
this
.
$message
({
this
.
$message
({
type
:
"info"
,
type
:
"info"
,
message
:
"已取消"
message
:
"已取消"
,
});
});
});
});
},
},
//删除
//删除
delete
(
role_id
)
{
delete
(
role_id
)
{
reqGetDelete_role
(
role_id
,
this
.
appId
).
then
(
res
=>
{
reqGetDelete_role
(
role_id
,
this
.
appId
).
then
(
(
res
)
=>
{
if
(
res
.
status
==
"success"
)
this
.
getGetRole_list
();
if
(
res
.
status
==
"success"
)
this
.
getGetRole_list
();
});
});
},
},
//角色详情数据
//角色详情数据
getRole_info_detail
(
type
,
role_id
)
{
getRole_info_detail
(
type
,
role_id
)
{
reqGet_role_info
(
role_id
,
this
.
appId
).
then
(
res
=>
{
reqGet_role_info
(
role_id
,
this
.
appId
).
then
(
(
res
)
=>
{
const
{
role_id
,
role_name
,
permissions
}
=
res
.
result
;
const
{
role_id
,
role_name
,
permissions
}
=
res
.
result
;
this
.
role_info_detail
=
{
this
.
role_info_detail
=
{
role_id
,
role_id
,
role_name
role_name
,
};
};
this
.
roleName
=
role_name
;
this
.
roleName
=
role_name
;
// this.permissionsUpdate = permissions
// this.permissionsUpdate = permissions
...
@@ -306,10 +308,10 @@ export default {
...
@@ -306,10 +308,10 @@ export default {
//遍历回显值selectedOptions
//遍历回显值selectedOptions
editEchoData
(
permissions
)
{
editEchoData
(
permissions
)
{
let
selectData
=
[];
let
selectData
=
[];
permissions
.
map
(
item
=>
{
permissions
.
map
(
(
item
)
=>
{
let
one
=
{
id
:
item
.
id
};
let
one
=
{
id
:
item
.
id
};
if
(
item
.
sub_permissions
)
{
if
(
item
.
sub_permissions
)
{
item
.
sub_permissions
.
map
(
info
=>
{
item
.
sub_permissions
.
map
(
(
info
)
=>
{
let
selectId
=
[
one
.
id
,
info
.
id
];
let
selectId
=
[
one
.
id
,
info
.
id
];
selectData
.
push
(
selectId
);
selectData
.
push
(
selectId
);
});
});
...
@@ -322,7 +324,7 @@ export default {
...
@@ -322,7 +324,7 @@ export default {
if
(
row
.
role_status
==
1
)
{
if
(
row
.
role_status
==
1
)
{
this
.
$message
({
this
.
$message
({
type
:
"info"
,
type
:
"info"
,
message
:
"该条数据已启用"
message
:
"该条数据已启用"
,
});
});
return
false
;
return
false
;
}
}
...
@@ -333,7 +335,7 @@ export default {
...
@@ -333,7 +335,7 @@ export default {
if
(
row
.
role_status
==
2
)
{
if
(
row
.
role_status
==
2
)
{
this
.
$message
({
this
.
$message
({
type
:
"info"
,
type
:
"info"
,
message
:
"该条数据已禁用"
message
:
"该条数据已禁用"
,
});
});
return
false
;
return
false
;
}
}
...
@@ -346,9 +348,9 @@ export default {
...
@@ -346,9 +348,9 @@ export default {
role_name
:
role_name
,
role_name
:
role_name
,
role_id
,
role_id
,
role_status
,
role_status
,
permissions
permissions
,
};
};
reqGetUpdate_role
(
paramsUpdate_role
,
this
.
appId
).
then
(
res
=>
{
reqGetUpdate_role
(
paramsUpdate_role
,
this
.
appId
).
then
(
(
res
)
=>
{
if
(
res
.
status
===
"success"
)
{
if
(
res
.
status
===
"success"
)
{
this
.
dialogVisible
=
false
;
this
.
dialogVisible
=
false
;
this
.
getGetRole_list
();
this
.
getGetRole_list
();
...
@@ -356,7 +358,7 @@ export default {
...
@@ -356,7 +358,7 @@ export default {
this
.
dialogVisible
=
false
;
this
.
dialogVisible
=
false
;
this
.
$message
({
this
.
$message
({
type
:
"info"
,
type
:
"info"
,
message
:
`
${
res
.
reason
}
`
message
:
`
${
res
.
reason
}
`
,
});
});
}
}
});
});
...
@@ -383,7 +385,7 @@ export default {
...
@@ -383,7 +385,7 @@ export default {
if
(
!
(
this
.
roleName
&&
checkRolePrivilege
.
length
>
0
))
{
if
(
!
(
this
.
roleName
&&
checkRolePrivilege
.
length
>
0
))
{
this
.
$message
({
this
.
$message
({
type
:
"error"
,
type
:
"error"
,
message
:
"请完善信息"
message
:
"请完善信息"
,
});
});
return
false
;
return
false
;
}
}
...
@@ -408,16 +410,16 @@ export default {
...
@@ -408,16 +410,16 @@ export default {
getAdd_role
()
{
getAdd_role
()
{
let
paramsAdd_role
=
{
let
paramsAdd_role
=
{
role_name
:
this
.
roleName
,
role_name
:
this
.
roleName
,
permissions
:
this
.
currenPermissionsUpdate
permissions
:
this
.
currenPermissionsUpdate
,
};
};
reqGetAdd_role
(
paramsAdd_role
,
this
.
appId
).
then
(
res
=>
{
reqGetAdd_role
(
paramsAdd_role
,
this
.
appId
).
then
(
(
res
)
=>
{
this
.
dialogVisible
=
false
;
this
.
dialogVisible
=
false
;
if
(
res
.
status
===
"success"
)
{
if
(
res
.
status
===
"success"
)
{
this
.
getGetRole_list
();
this
.
getGetRole_list
();
}
else
{
}
else
{
this
.
$message
({
this
.
$message
({
type
:
"info"
,
type
:
"info"
,
message
:
`
${
res
.
reason
}
`
message
:
`
${
res
.
reason
}
`
,
});
});
}
}
});
});
...
@@ -427,13 +429,13 @@ export default {
...
@@ -427,13 +429,13 @@ export default {
},
},
getSelectedOptions
(
selectedOptions
)
{
getSelectedOptions
(
selectedOptions
)
{
let
oldDataRule
=
[];
let
oldDataRule
=
[];
selectedOptions
.
forEach
(
el
=>
{
selectedOptions
.
forEach
(
(
el
)
=>
{
let
oldObj
=
{
let
oldObj
=
{
id
:
el
[
0
],
id
:
el
[
0
],
sub_permissions
:
[]
sub_permissions
:
[]
,
};
};
let
btnObj
=
{
let
btnObj
=
{
id
:
el
[
1
]
id
:
el
[
1
]
,
};
};
oldObj
.
sub_permissions
.
push
(
btnObj
);
oldObj
.
sub_permissions
.
push
(
btnObj
);
oldDataRule
.
push
(
oldObj
);
oldDataRule
.
push
(
oldObj
);
...
@@ -445,11 +447,11 @@ export default {
...
@@ -445,11 +447,11 @@ export default {
newData
.
push
(
el
);
newData
.
push
(
el
);
newObj
[
el
.
id
]
=
true
;
newObj
[
el
.
id
]
=
true
;
}
else
{
}
else
{
newData
.
forEach
(
el
=>
{
newData
.
forEach
(
(
el
)
=>
{
if
(
el
.
id
===
oldDataRule
[
i
].
id
)
{
if
(
el
.
id
===
oldDataRule
[
i
].
id
)
{
el
.
sub_permissions
=
[
el
.
sub_permissions
=
[
...
el
.
sub_permissions
,
...
el
.
sub_permissions
,
...
oldDataRule
[
i
].
sub_permissions
...
oldDataRule
[
i
].
sub_permissions
,
];
];
}
}
});
});
...
@@ -457,8 +459,8 @@ export default {
...
@@ -457,8 +459,8 @@ export default {
});
});
this
.
currentRolePrivilege
=
newData
;
this
.
currentRolePrivilege
=
newData
;
this
.
currenPermissionsUpdate
=
newData
;
this
.
currenPermissionsUpdate
=
newData
;
}
}
,
}
}
,
};
};
</
script
>
</
script
>
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
...
...
src/components/UserList/index.vue
View file @
7d8954cd
...
@@ -119,7 +119,7 @@ import {
...
@@ -119,7 +119,7 @@ import {
export
default
{
export
default
{
name
:
"UserList"
,
name
:
"UserList"
,
props
:
[
"appId"
],
props
:
[
"appId"
,
"userPermissionId"
],
components
:
{
components
:
{
page
,
page
,
UserInfoModal
,
UserInfoModal
,
...
@@ -150,8 +150,10 @@ export default {
...
@@ -150,8 +150,10 @@ export default {
},
},
computed
:
{
computed
:
{
permission
()
{
permission
()
{
const
appId
=
this
.
appId
||
""
;
const
userPermissionId
=
this
.
userPermissionId
||
"user"
;
const
modulePermissions
=
const
modulePermissions
=
this
.
$store
.
getters
.
moduleSubPermissions
(
"user"
)
||
[];
this
.
$store
.
getters
.
moduleSubPermissions
(
userPermissionId
,
appId
)
||
[];
console
.
log
(
"Current page func-permissions:"
,
modulePermissions
);
console
.
log
(
"Current page func-permissions:"
,
modulePermissions
);
return
new
Map
(
modulePermissions
.
map
(
ele
=>
[
ele
.
name
,
true
]));
return
new
Map
(
modulePermissions
.
map
(
ele
=>
[
ele
.
name
,
true
]));
},
},
...
...
src/pages/Withdrawal/Role/manage-role.vue
View file @
7d8954cd
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<role-list
<role-list
appId=
"merchant-op-auditing"
appId=
"merchant-op-auditing"
detailPath=
"/op/withdrawal/roleRoleDetail"
detailPath=
"/op/withdrawal/roleRoleDetail"
rolePermissionId=
"role_management"
></role-list>
></role-list>
</layout>
</layout>
</
template
>
</
template
>
...
...
src/pages/Withdrawal/components/PageHeader/config.js
View file @
7d8954cd
...
@@ -4,14 +4,17 @@ const headerConfig = [
...
@@ -4,14 +4,17 @@ const headerConfig = [
path
:
"/op/withdrawal/examine"
path
:
"/op/withdrawal/examine"
},
},
{
{
path
:
'/op/withdrawal/roleManageRole'
,
path
:
"/op/withdrawal/roleManageRole"
,
name
:
'角色管理'
name
:
"角色管理"
,
requireAuthentication
:
true
,
requiredPermission
:
"role_management"
},
},
{
{
path
:
'/op/withdrawal/user'
,
path
:
"/op/withdrawal/user"
,
name
:
'用户管理'
name
:
"用户管理"
,
requireAuthentication
:
true
,
requiredPermission
:
"user_management"
}
}
];
];
export
default
headerConfig
;
export
default
headerConfig
;
\ No newline at end of file
src/pages/Withdrawal/components/PageHeader/index.vue
View file @
7d8954cd
...
@@ -15,13 +15,15 @@
...
@@ -15,13 +15,15 @@
v-for=
"item in headerConfig"
v-for=
"item in headerConfig"
:index=
"item.path"
:index=
"item.path"
:key=
"item.path"
:key=
"item.path"
v-show=
"
!item.requireAuthentication ||
(item.requireAuthentication &&
hasPermission(item.requiredPermission))
"
>
>
{{
item
.
name
}}
{{
item
.
name
}}
</el-menu-item>
</el-menu-item>
<el-menu-item
<el-menu-item
key=
"usermenu"
class=
"user-menu"
>
key=
"usermenu"
class=
"user-menu"
>
<user></user>
<user></user>
</el-menu-item>
</el-menu-item>
</el-menu>
</el-menu>
...
@@ -35,22 +37,30 @@ import User from "./User.vue";
...
@@ -35,22 +37,30 @@ import User from "./User.vue";
export
default
{
export
default
{
name
:
"PageHeader"
,
name
:
"PageHeader"
,
components
:
{
components
:
{
User
User
,
},
},
data
()
{
data
()
{
return
{
return
{
headerConfig
headerConfig
,
};
};
},
},
computed
:
{
computed
:
{
activeMenu
()
{
activeMenu
()
{
return
this
.
$route
.
path
;
return
this
.
$route
.
path
;
}
},
},
beforeMount
()
{},
methods
:
{
hasPermission
(
permissionId
)
{
return
(
this
.
$store
.
getters
.
moduleSubPermissions
(
permissionId
,
"merchant-op-auditing"
).
length
!==
0
);
},
},
},
beforeMount
()
{
},
methods
:
{}
};
};
</
script
>
</
script
>
<
style
lang=
"less"
>
<
style
lang=
"less"
></
style
>
</
style
>
src/store/index.js
View file @
7d8954cd
...
@@ -32,7 +32,16 @@ export default createStore({
...
@@ -32,7 +32,16 @@ export default createStore({
async
fetchPermission
({
commit
},
{
email
,
appId
})
{
async
fetchPermission
({
commit
},
{
email
,
appId
})
{
if
(
appId
===
"merchant-op-auditing"
)
{
if
(
appId
===
"merchant-op-auditing"
)
{
const
permissions
=
await
getRolesForUser
(
email
);
const
permissions
=
await
getRolesForUser
(
email
);
commit
(
"updatePermissionForApp"
,
{
appId
,
permissions
});
if
(
!
permissions
)
{
return
;
}
const
permissionMap
=
permissions
.
reduce
((
prev
,
permission
)
=>
{
prev
[
permission
.
name
]
=
permission
;
return
prev
;
});
commit
(
"updatePermissionForApp"
,
{
appId
,
permissionMap
});
return
;
return
;
}
}
console
.
error
(
"无 appId 注册"
,
appId
);
console
.
error
(
"无 appId 注册"
,
appId
);
...
@@ -56,7 +65,13 @@ export default createStore({
...
@@ -56,7 +65,13 @@ export default createStore({
*/
*/
moduleSubPermissions
:
state
=>
(
module
,
appId
=
""
)
=>
{
moduleSubPermissions
:
state
=>
(
module
,
appId
=
""
)
=>
{
if
(
appId
!==
""
)
{
if
(
appId
!==
""
)
{
return
;
if
(
!
state
.
permissionsForApp
[
appId
])
{
return
[];
}
if
(
!
state
.
permissionsForApp
[
appId
][
module
])
{
return
[];
}
return
state
.
permissionsForApp
[
appId
][
module
].
sub_permissions
;
}
}
const
permissionCol
=
{};
const
permissionCol
=
{};
...
...
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