Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart
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
wangqinghua
smart
Commits
015269c8
Commit
015269c8
authored
Dec 12, 2018
by
wangqinghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
0a769e8f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
36 deletions
+107
-36
select-role.component.html
...n/webapp/app/modal/select-role/select-role.component.html
+5
-20
select-role.component.ts
...ain/webapp/app/modal/select-role/select-role.component.ts
+71
-15
group.component.html
src/main/webapp/app/system/group/group.component.html
+1
-1
group.component.ts
src/main/webapp/app/system/group/group.component.ts
+25
-0
system.service.ts
src/main/webapp/app/system/system.service.ts
+5
-0
No files found.
src/main/webapp/app/modal/select-role/select-role.component.html
View file @
015269c8
<!--添加资源-->
<!--添加资源-->
<nz-modal
[
nzWidth
]="
10
80
"
[(
nzVisible
)]="
isVisible
"
[
nzTitle
]="
title
"
(
nzOnCancel
)="
handleEditCancel
()"
(
nzOnOk
)="
handEditleOk
()"
>
<nz-modal
[
nzWidth
]="
7
80
"
[(
nzVisible
)]="
isVisible
"
[
nzTitle
]="
title
"
(
nzOnCancel
)="
handleEditCancel
()"
(
nzOnOk
)="
handEditleOk
()"
>
<nz-table
#
basicTable
[
nzData
]="
dataSet
"
>
<nz-table
#
basicTable
[
nzData
]="
dataSet
"
nzPageSize=
"5"
>
<thead>
<thead>
<tr>
<tr>
<th
nzShowCheckbox
[(
nzChecked
)]="
allChecked
"
[
nzIndeterminate
]="
indeterminate
"
(
nzCheckedChange
)="
checkAll
($
event
)"
></th>
<th>
角色名称
</th>
<th>
角色名称
</th>
<th>
说明
</th>
<th>
角色说明
</th>
<th>
权限模块
</th>
<th>
资源权限
</th>
<th>
有效
</th>
<th>
操作
</th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<tr
*
ngFor=
"let data of basicTable.data"
>
<tr
*
ngFor=
"let data of basicTable.data"
>
<td
nzShowCheckbox
(
nzCheckedChange
)="
selectItem
($
event
,
data
)"
[(
nzChecked
)]="
data
.
checked
"
></td>
<td>
{{data.name}}
</td>
<td>
{{data.name}}
</td>
<td>
{{data.comments}}
</td>
<td>
{{data.comments}}
</td>
<td>
{{data.key3}}
</td>
<td>
{{data.key4}}
</td>
<td>
<ng-container
*
ngIf=
"data.status == 0"
>
<i
class=
"anticon anticon-check"
></i>
</ng-container>
</td>
<td
class=
"handle"
>
<span
(
click
)="
grantUser
(
data
)"
>
授予用户
</span>
<span>
查看
</span>
<span
(
click
)="
showEditModal
(
data
.
id
)"
>
编辑
</span>
<span
(
click
)="
deleteRole
(
data
)"
>
删除
</span>
</td>
</tr>
</tr>
</tbody>
</tbody>
</nz-table>
</nz-table>
...
...
src/main/webapp/app/modal/select-role/select-role.component.ts
View file @
015269c8
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
EventEmitter
,
OnInit
,
Output
}
from
'@angular/core'
;
import
{
SystemService
}
from
'../../system/system.service'
;
@
Component
({
@
Component
({
selector
:
'smart-select-role'
,
selector
:
'smart-select-role'
,
templateUrl
:
'./select-role.component.html'
,
templateUrl
:
'./select-role.component.html'
,
styles
:
[]
styles
:
[]
})
})
export
class
SelectRoleComponent
implements
OnInit
{
export
class
SelectRoleComponent
implements
OnInit
{
@
Output
()
done
=
new
EventEmitter
<
any
>
();
title
;
dataSet
:
any
=
[];
isVisible
=
false
;
title
;
constructor
()
{
}
selectList
=
[];
isVisible
=
false
;
allChecked
=
false
;
checkedNumber
=
0
;
disabledButton
=
true
;
indeterminate
=
false
;
displayData
:
Array
<
{
key1
:
string
;
key2
:
number
;
key3
:
string
;
key4
:
string
;
checked
:
boolean
}
>
=
[];
constructor
(
private
systemSer
:
SystemService
)
{
}
ngOnInit
()
{
checkAll
(
value
:
boolean
):
void
{
}
this
.
displayData
.
forEach
(
data
=>
data
.
checked
=
value
);
this
.
refreshStatus
();
}
showModal
(
title
){
currentPageDataChange
(
$event
:
Array
<
{
key1
:
string
;
key2
:
number
;
key3
:
string
;
key4
:
string
;
checked
:
boolean
}
>
):
void
{
this
.
title
=
title
;
this
.
displayData
=
$event
;
this
.
isVisible
=
true
;
}
}
getRoleList
(){
selectItem
(
event
,
item
){
if
(
event
){
this
.
selectList
.
push
(
item
);
}
else
{
this
.
selectList
.
forEach
((
value
,
index
)
=>
{
if
(
value
.
id
==
item
.
id
){
this
.
selectList
.
splice
(
index
,
1
)
}
})
}
this
.
refreshStatus
()
}
}
refreshStatus
():
void
{
const
allChecked
=
this
.
displayData
.
every
(
value
=>
value
.
checked
===
true
);
const
allUnChecked
=
this
.
displayData
.
every
(
value
=>
!
value
.
checked
);
this
.
allChecked
=
allChecked
;
this
.
indeterminate
=
(
!
allChecked
)
&&
(
!
allUnChecked
);
this
.
disabledButton
=
!
this
.
dataSet
.
some
(
value
=>
value
.
checked
);
this
.
checkedNumber
=
this
.
dataSet
.
filter
(
value
=>
value
.
checked
).
length
;
}
ngOnInit
()
{
}
showModal
(
title
)
{
this
.
title
=
title
;
this
.
isVisible
=
true
;
this
.
getRole
();
}
getRole
()
{
this
.
systemSer
.
role
().
subscribe
(
(
res
)
=>
{
this
.
dataSet
=
res
.
data
;
}
);
}
handleEditCancel
(){
this
.
isVisible
=
false
;
}
handEditleOk
(){
console
.
log
(
this
.
selectList
);
this
.
done
.
emit
(
this
.
selectList
);
this
.
isVisible
=
false
;
}
}
}
src/main/webapp/app/system/group/group.component.html
View file @
015269c8
...
@@ -83,5 +83,5 @@
...
@@ -83,5 +83,5 @@
<!--新增部门-->
<!--新增部门-->
<smart-group-modal
#
smartGroupModal
></smart-group-modal>
<smart-group-modal
#
smartGroupModal
></smart-group-modal>
<!--授予角色-->
<!--授予角色-->
<smart-select-role
#
smartSelectRole
></smart-select-role>
<smart-select-role
#
smartSelectRole
(
done
)="
setRole
($
event
)"
></smart-select-role>
src/main/webapp/app/system/group/group.component.ts
View file @
015269c8
...
@@ -25,6 +25,7 @@ export class GroupComponent implements OnInit {
...
@@ -25,6 +25,7 @@ export class GroupComponent implements OnInit {
checkedNumber
=
0
;
checkedNumber
=
0
;
nodes
:
any
[];
nodes
:
any
[];
isVisible
=
true
;
isVisible
=
true
;
userId
;
displayData
:
Array
<
{
key1
:
string
;
key2
:
number
;
key3
:
string
;
key4
:
string
;
checked
:
boolean
}
>
=
[];
displayData
:
Array
<
{
key1
:
string
;
key2
:
number
;
key3
:
string
;
key4
:
string
;
checked
:
boolean
}
>
=
[];
constructor
(
private
systemSer
:
SystemService
,
private
message
:
NzMessageService
,
constructor
(
private
systemSer
:
SystemService
,
private
message
:
NzMessageService
,
...
@@ -145,7 +146,31 @@ export class GroupComponent implements OnInit {
...
@@ -145,7 +146,31 @@ export class GroupComponent implements OnInit {
//授予角色
//授予角色
grantRole
(
data
){
grantRole
(
data
){
this
.
userId
=
data
.
id
;
this
.
smartSelectRole
.
showModal
(
"选择角色"
);
this
.
smartSelectRole
.
showModal
(
"选择角色"
);
}
}
setRole
(
event
){
console
.
log
(
event
);
let
str
=
""
;
event
.
forEach
(
res
=>
{
str
+=
res
.
id
+
","
;
});
str
=
str
.
substring
(
0
,
str
.
length
-
1
);
const
data
=
{
userId
:
this
.
userId
,
roleIds
:
str
};
this
.
systemSer
.
batchGrantRoleToUser
(
data
).
subscribe
(
(
res
)
=>
{
if
(
res
.
errCode
==
10000
){
this
.
message
.
success
(
"授予角色成功"
);
}
else
{
this
.
message
.
error
(
res
.
errMsg
);
}
}
)
}
}
}
src/main/webapp/app/system/system.service.ts
View file @
015269c8
...
@@ -74,4 +74,9 @@ export class SystemService {
...
@@ -74,4 +74,9 @@ export class SystemService {
batchGrantUserToRole
(
data
):
Observable
<
any
>
{
batchGrantUserToRole
(
data
):
Observable
<
any
>
{
return
this
.
http
.
post
(
SERVER_API_URL
+
'/role/batchGrantUserToRole'
,
data
);
return
this
.
http
.
post
(
SERVER_API_URL
+
'/role/batchGrantUserToRole'
,
data
);
}
}
//对单一用户批量授权角色
batchGrantRoleToUser
(
data
):
Observable
<
any
>
{
return
this
.
http
.
post
(
SERVER_API_URL
+
'/role/batchGrantRoleToUser'
,
data
);
}
}
}
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