@@ -26,7 +26,7 @@ <h2 class="header-title">应用管理</h2>
26
26
27
27
<!-- 表单弹窗 -->
28
28
< script type ="text/html " id ="app-model ">
29
- < form id = "app-form" lay-filter = "app-form" class = "layui-form model-form" >
29
+ < form id = "app-form" method = "POST" lay-filter = "app-form" class = "layui-form model-form" >
30
30
< input name = "id" type = "hidden" />
31
31
< div class = "layui-form-item" >
32
32
< label class = "layui-form-label" > 应用标识</ label >
@@ -54,6 +54,35 @@ <h2 class="header-title">应用管理</h2>
54
54
< input name = "webServerRedirectUri" placeholder = "请输入回调地址" type = "text" class = "layui-input" maxlength = "20" />
55
55
</ div >
56
56
</ div >
57
+ < div class = "layui-form-item" >
58
+ < label class = "layui-form-label" > 自动审批</ label >
59
+ < div class = "layui-input-block" >
60
+ < input type = "radio" name = "autoapprove" value = "true" title = "是" checked />
61
+ < input type = "radio" name = "autoapprove" value = "false" title = "否" />
62
+ </ div >
63
+ </ div >
64
+ < div class = "layui-form-item" >
65
+ < label class = "layui-form-label" > 授权模式</ label >
66
+ < div class = "layui-input-block" >
67
+ < input type = "checkbox" name = "authorizedGrantTypes" lay-skin = "primary" title = "授权码模式" value = "authorization_code" checked >
68
+ < input type = "checkbox" name = "authorizedGrantTypes" lay-skin = "primary" title = "密码模式" value = "password" checked >
69
+ < input type = "checkbox" name = "authorizedGrantTypes" lay-skin = "primary" title = "客户端模式" value = "client_credentials" checked >
70
+ < input type = "checkbox" name = "authorizedGrantTypes" lay-skin = "primary" title = "简化模式" value = "implicit" checked >
71
+ < input type = "checkbox" name = "authorizedGrantTypes" lay-skin = "primary" title = "刷新Token" value = "refresh_token" checked >
72
+ </ div >
73
+ </ div >
74
+ < div class = "layui-form-item" >
75
+ < label class = "layui-form-label" > 令牌时效(s)</ label >
76
+ < div class = "layui-input-block" >
77
+ < input name = "accessTokenValiditySeconds" lay-verify = "number" type = "text" class = "layui-input" maxlength = "20" value = "18000" />
78
+ </ div >
79
+ </ div >
80
+ < div class = "layui-form-item" >
81
+ < label class = "layui-form-label" > 刷新时效(s)</ label >
82
+ < div class = "layui-input-block" >
83
+ < input name = "refreshTokenValiditySeconds" lay-verify = "number" type = "text" class = "layui-input" maxlength = "20" value = "28800" />
84
+ </ div >
85
+ </ div >
57
86
< div class = "layui-form-item model-form-footer" >
58
87
< button class = "layui-btn layui-btn-primary" ew-event = "closeDialog" type = "button" > 取消</ button >
59
88
< button class = "layui-btn" lay-filter = "app-form-submit" lay-submit > 保存</ button >
@@ -81,11 +110,15 @@ <h2 class="header-title">应用管理</h2>
81
110
cols : [ [
82
111
{ type : 'numbers' } ,
83
112
{ field : 'clientId' , width :180 , sort : true , title : '应用标识' } ,
84
- { field : 'clientName' , width :200 , sort : true , title : '应用名称' } ,
85
- { field : 'clientSecretStr' , width :180 , sort : true , title : '应用密钥' } ,
86
- { field : 'webServerRedirectUri' , sort : true , title : '回调地址' } ,
113
+ { field : 'clientName' , width :180 , sort : true , title : '应用名称' } ,
114
+ { field : 'webServerRedirectUri' , width :250 , sort : true , title : '回调地址' } ,
87
115
{ field : 'authorizedGrantTypes' , width :250 , sort : true , title : 'oauth授权方式' } ,
88
- { align : 'center' , width :150 , toolbar : '#app-table-bar' , title : '操作' }
116
+ { width :110 , sort : true , title : '自动审批' , templet :function ( d ) {
117
+ return d . autoapprove == 'true' ?"是" :"否"
118
+ } } ,
119
+ { field : 'accessTokenValiditySeconds' , width :130 , sort : true , title : '令牌时效(s)' } ,
120
+ { field : 'refreshTokenValiditySeconds' , width :130 , sort : true , title : '刷新时效(s)' } ,
121
+ { fixed : 'right' , align : 'center' , width :150 , toolbar : '#app-table-bar' , title : '操作' }
89
122
] ]
90
123
} ) ;
91
124
@@ -132,29 +165,44 @@ <h2 class="header-title">应用管理</h2>
132
165
type : 1 ,
133
166
title : data ? '修改应用' : '添加应用' ,
134
167
area : '450px' ,
135
- offset : '120px ' ,
168
+ offset : '80px ' ,
136
169
content : $ ( '#app-model' ) . html ( ) ,
137
170
success : function ( ) {
138
171
$ ( '#app-form' ) [ 0 ] . reset ( ) ;
139
- $ ( '#app-form' ) . attr ( 'method' , 'POST' ) ;
140
172
if ( data ) {
141
173
$ ( "input[name='clientId']" ) . attr ( 'disabled' , true ) ;
142
174
$ ( "input[name='clientId']" ) . attr ( 'class' , "layui-input layui-disabled" ) ;
143
175
$ ( "input[name='webServerRedirectUri']" ) . attr ( 'disabled' , true ) ;
144
176
$ ( "input[name='webServerRedirectUri']" ) . attr ( 'class' , "layui-input layui-disabled" ) ;
145
177
form . val ( 'app-form' , data ) ;
146
- $ ( '#app-form' ) . attr ( 'method' , 'POST' ) ;
178
+
179
+ let authorizedGrantTypesArr = data . authorizedGrantTypes . split ( "," ) ;
180
+ $ ( 'input[type=checkbox][name=authorizedGrantTypes]' ) . each ( function ( ) {
181
+ let typeValue = $ ( this ) . val ( ) ;
182
+ let isCheck = false ;
183
+ for ( var i = 0 ; i < authorizedGrantTypesArr . length ; i ++ ) {
184
+ if ( typeValue === authorizedGrantTypesArr [ i ] ) {
185
+ isCheck = true ;
186
+ break ;
187
+ }
188
+ }
189
+ $ ( this ) . prop ( "checked" , isCheck ) ;
190
+ } ) ;
147
191
}
148
192
}
149
193
} ) ;
150
194
} ;
151
195
152
196
// 表单提交事件
153
197
form . on ( 'submit(app-form-submit)' , function ( data ) {
198
+ let authorizedGrantTypesArr = [ ] ;
199
+ $ ( 'input[type=checkbox][name=authorizedGrantTypes]:checked' ) . each ( function ( ) {
200
+ authorizedGrantTypesArr . push ( $ ( this ) . val ( ) ) ;
201
+ } ) ;
202
+ data . field . authorizedGrantTypes = authorizedGrantTypesArr . join ( "," ) ;
154
203
layer . load ( 2 ) ;
155
204
admin . req ( 'api-uaa/clients/saveOrUpdate' , JSON . stringify ( data . field ) , function ( data ) {
156
205
layer . closeAll ( 'loading' ) ;
157
- console . log ( data ) ;
158
206
if ( data . resp_code == 0 ) {
159
207
layer . msg ( data . resp_msg , { icon : 1 , time : 500 } ) ;
160
208
table . reload ( 'app-table' ) ;
0 commit comments