peternameyakj
2025-01-06 4c82733d79b03ee1d5304398b0598d826e6fd0e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<%@ page language="java" pageEncoding="utf-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<jsp:useBean id="security" class="security.web.BaseSecurityAction" scope="page" />
 
<%@ include file="include/pagetop.jsp"%>
 
<!DOCTYPE html>
<html>
 
<head>
<%@ include file="include/head.jsp"%>
</head>
 
<body>
 
    <%@ include file="include/loading.jsp"%>
<%--     <%@ include file="include/top.jsp"%> --%>
<%--     <%@ include file="include/menu_left.jsp"%> --%>
 
    <!-- //////////////////////////////////////////////////////////////////////////// -->
    <!-- START CONTENT -->
    <div class="ifr-dody">
 
        <!-- //////////////////////////////////////////////////////////////////////////// -->
        <!-- START CONTAINER -->
        <div class="ifr-con">
            <h3>角色管理</h3>
            
            <%@ include file="include/alert.jsp"%>
            
            <!-- //////////////////////////////////////////////////////////////////////////// -->
            <!-- START queryForm -->
            <!-- END queryForm -->
            <!-- //////////////////////////////////////////////////////////////////////////// -->
 
            <div class="row">
                <div class="col-md-12">
                    <!-- Start Panel -->
                    <div class="panel panel-default">
                        <div class="panel-title">查询结果</div>
                        
                        <a
                            href="<%=basePath%>normal/adminRoleAuthorityAction!toAdd.action?username_para=${username_para}"
                            class="btn btn-light" style="margin-bottom: 10px"><i
                            class="fa fa-pencil"></i>新增角色</a>
                            
                        <div class="panel-body">
                        
                            <table class="table table-bordered table-striped">
                            
                                <thead>
                                    <tr>
                                        <td>角色</td>
                                        <td>权限</td>
                                        <td width="150px"></td>
                                    </tr>
                                </thead>
                                
                                <tbody>
                                    <!-- <s:iterator value="datas" status="stat"> -->
                                    <c:forEach items="${datas}" var="item" varStatus="stat">
                                        <tr>
                                            <td>${item.roleName}</td>
                                            <td>${item.names}</td>
                                            
                                            <td>
                                            
                                                <c:if test="${item.is_default_role == '0'}">
                                                    <c:if test="${security.isRolesAccessible('ROLE_ROOT,ROLE_ADMIN,ROLE_MAINTAINER')}">
                                            
                                                        <div class="btn-group">
                                                            <button type="button" class="btn btn-light">操作</button>
                                                            <button type="button" class="btn btn-light dropdown-toggle"
                                                                data-toggle="dropdown" aria-expanded="false">
                                                                <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
                                                            </button>
                                                            <ul class="dropdown-menu" role="menu">
                                                                
                                                                <li><a href="javascript:updateResource('${item.id}')">配置权限</a></li>
                                                                
                                                                <li><a href="javascript:del('${item.id}')">删除</a></li>
        
                                                            </ul>
                                                        </div>
                                                    
                                                    </c:if>        
                                                </c:if>
                                            
                                                <c:if test="${item.is_default_role == '1'}">
                                                    <c:if test="${security.isRolesAccessible('ROLE_ROOT,ROLE_ADMIN')}">
                                            
                                                        <div class="btn-group">
                                                            <button type="button" class="btn btn-light">操作</button>
                                                            <button type="button" class="btn btn-light dropdown-toggle"
                                                                data-toggle="dropdown" aria-expanded="false">
                                                                <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
                                                            </button>
                                                            <ul class="dropdown-menu" role="menu">
                                                                
                                                                <li><a href="javascript:updateResource('${item.id}')">配置权限</a></li>
        
                                                            </ul>
                                                        </div>
                                                    
                                                    </c:if>        
                                                </c:if>
                                                
                                            </td>
                                            
                                        </tr>
                                    <!-- </s:iterator> -->
                                    </c:forEach>
                                </tbody>
                                
                            </table>
                            
                            <%@ include file="include/page_simple.jsp"%>
                            
                            <!-- <nav> -->
                        </div>
 
                    </div>
                    <!-- End Panel -->
 
                </div>
            </div>
 
        </div>
        <!-- END CONTAINER -->
        <!-- //////////////////////////////////////////////////////////////////////////// -->
 
        <%@ include file="include/footer.jsp"%>
 
    </div>
    <!-- End Content -->
    <!-- //////////////////////////////////////////////////////////////////////////// -->
    
    <div class="form-group">
    
        <form action="<%=basePath%>normal/adminRoleAuthorityAction!update.action"
            method="post" id="mainform">
            
            <input type="hidden" name="pageNo" id="pageNo" value="${pageNo}"> 
            <input type="hidden" name="id" id="update_role_id" value="${id}" />
            
            <div class="col-sm-1">
                <!-- 模态框(Modal) -->
                <div class="modal fade" id="resources_form" tabindex="-1"
                    role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                        
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"
                                    aria-hidden="true">&times;</button>
                                <h4 class="modal-title" id="myModalLabel">配置权限</h4>
                            </div>
                            
                            <div class="modal-body"
                                style="max-height: 400px; overflow-y: scroll;">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <td>权限</td>
                                        </tr>
                                    </thead>
                                    <tbody id="modal_table">
                                        <%@ include file="include/loading.jsp"%>
                                    </tbody>
                                </table>
                            </div>
                            
                            <div class="col-sm-1 form-horizontal">
                                <!-- 模态框(Modal) -->
                                <div class="modal fade" id="modal_succeeded" tabindex="-1"
                                    role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                        
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal"
                                                    aria-hidden="true">&times;</button>
                                                <h4 class="modal-title" id="myModalLabel">确认新增</h4>
                                            </div>
                                            
                                            <div class="modal-body">
                                            
                                                <div class="form-group">
                                                    <label for="input002"
                                                        class="col-sm-3 control-label form-label">登录人资金密码</label>
                                                    <div class="col-sm-4">
                                                        <input id="login_safeword" type="password"
                                                            name="login_safeword" class="login_safeword"
                                                            placeholder="请输入登录人资金密码">
                                                    </div>
                                                </div>
                                                
                                                <!-- <div class="form-group" style="">
                                                
                                                    <label for="input002" class="col-sm-3 control-label form-label">验证码</label>
                                                    <div class="col-sm-4">
                                                        <input id="email_code" type="text" name="email_code"
                                                        class="login_safeword" placeholder="请输入验证码" >
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <a id="update_email_code_button" href="javascript:updateSendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
                                                    </div>
                                                </div> -->
                                                
                                                <div class="form-group">
                                                    <label for="input002"
                                                        class="col-sm-3 control-label form-label">超级谷歌验证码</label>
                                                    <div class="col-sm-4">
                                                        <input id="super_google_auth_code"
                                                            name="super_google_auth_code" placeholder="请输入超级谷歌验证码">
                                                    </div>
                                                </div>
                                                
                                            </div>
                                            
                                            <div class="modal-footer" style="margin-top: 0;">
                                                <button type="button" class="btn " data-dismiss="modal">关闭</button>
                                                <button id="sub" type="submit" class="btn btn-default">确认</button>
                                            </div>
                                            
                                        </div>
                                        <!-- /.modal-content -->
                                    </div>
                                    <!-- /.modal -->
                                </div>
                            </div>
                            
                            <div class="modal-footer" style="margin-top: 0;">
                                <button type="button" class="btn " data-dismiss="modal">关闭</button>
                                <a href="javascript:submit()" class="btn btn-default">保存</a>
                                <!-- <button id="sub" type="" class="btn btn-default"  onClick="submit();" >保存</button> -->
                            </div>
                            
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal -->
                </div>
            </div>
        </form>
        
    </div>
 
    <%@ include file="include/js.jsp"%>
 
    <script type="text/javascript">
        function update_value(code,snotes,svalue){
            document.getElementById("change_value").value = svalue;
            document.getElementById("titlediv").innerText = snotes;
             $("#code").val(code);
             
            $('#modal_set').modal("show");             
        }
    </script>
    
    <form action="<%=basePath%>normal/adminRoleAuthorityAction!delete.action"
        method="post" id="deleteform">
        
        <input type="hidden" name="pageNo" id="pageNo" value="${pageNo}">
        <input type="hidden" name="id" id="delete_id" value="${id}"/>
        
        <div class="col-sm-1 form-horizontal">
            <!-- 模态框(Modal) -->
            <div class="modal fade" id="modal_delete" tabindex="-1" role="dialog"
                aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                    
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">确认删除</h4>
                        </div>
                        
                        <div class="modal-body">
                        
                            <div class="form-group">
                                <label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
                                <div class="col-sm-4">
                                    <input id="login_safeword" type="password"
                                        name="login_safeword" class="login_safeword"
                                        placeholder="请输入登录人资金密码">
                                </div>
                            </div>
                            
                            <!-- <div class="form-group" style="">
                            
                                <label for="input002" class="col-sm-3 control-label form-label">验证码</label>
                                <div class="col-sm-4">
                                    <input id="email_code" type="text" name="email_code"
                                    class="login_safeword" placeholder="请输入验证码" >
                                </div>
                                <div class="col-sm-4">
                                    <a id="delete_email_code_button" href="javascript:deleteSendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
                                </div>
                            </div> -->
                            
                            <div class="form-group">
                                <label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
                                <div class="col-sm-4">
                                    <input id="super_google_auth_code"
                                        name="super_google_auth_code" placeholder="请输入超级谷歌验证码">
                                </div>
                            </div>
                            
                        </div>
                        
                        <div class="modal-footer" style="margin-top: 0;">
                            <button type="button" class="btn " data-dismiss="modal">关闭</button>
                            <button id="sub" type="submit" class="btn btn-default">确认</button>
                        </div>
                        
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal -->
            </div>
        </div>
    </form>
 
    <script>
        function del(id) {
            $("#delete_id").val(id);
            $('#modal_delete').modal("show");    
        }
    </script>
    
    <script type="text/javascript">
        function updateResource(id){
            $("#resources_form").modal("show");
            $("#update_role_id").val(id);
            
            var url = "<%=basePath%>normal/adminRoleAuthorityAction!resources.action";
            var data = {"id":id};
            goAjaxUrl(url,data,function(tmp){
 
                var str='';
                var content='';
                /* tmp.all_resources */
                console.log(tmp);
                for(var i=0;i<tmp.all_resources.length;i++){
                    
                    
                    content = '<div class="checkbox checkbox-success checkbox-inline">'
                            + '<input type="checkbox" id="inlineCheckbox12_'+tmp.all_resources[i].set_id+'" value="'+tmp.all_resources[i].set_id+'" name="role_resource" >'
                            + '<label for="inlineCheckbox12_'+tmp.all_resources[i].set_id+'">'+tmp.all_resources[i].name+'</label>'
                            + '</div>';
                    str += '<tr>'
                        +'<td>'+content+'</td>'
                        +'</tr>';
                }
                $("#modal_table").html(str);
                
                $.each(tmp.checked_resources.split(","),function(index,value){//默认选中
                    $("#inlineCheckbox12_"+value).prop("checked","checked");
                });
            },function(){
    //             $("#coin_value").val(0);
            });
        }
        function goAjaxUrl(targetUrl,data,Func,Fail){
            console.log(data);
            $.ajax({
                url:targetUrl,
                data:data,
                type : 'get',
                dataType : "json",
                success: function (res) {
//                     var tmp = $.parseJSON(res)
                    var tmp = res;
                    console.log(tmp);
                    if(tmp.code==200){
                        Func(tmp);
                    }else if(tmp.code==500){
                        Fail();
                        swal({
                            title : tmp.message,
                            text : "",
                            type : "warning",
                            showCancelButton : true,
                            confirmButtonColor : "#DD6B55",
                            confirmButtonText : "确认",
                            closeOnConfirm : false
                        });
                    }
                  },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        console.log("请求错误");
                    }
            });
        }
    </script>
    
    <script type="text/javascript">
        function submit() {
            $('#modal_succeeded').modal("show");
        }
    </script>
    
    <script type="text/javascript">
        var setInt = null;//定时器        
        clearInterval(setInt);
        
        function updateSendCode(){
            var url = "<%=basePath%>normal/adminEmailCodeAction!sendCode.action";
             var data = {"code_context":"updateRoleResource","isSuper":true};
             goAjaxUrl(url,data,function(tmp){
             
                 $("#update_email_code_button").attr("disabled","disabled");
                 var timeout = 60;
                 setInt = setInterval(function(){
                         if(timeout<=0){
                             clearInterval(setInt);
                             timeout=60;
                             $("#update_email_code_button").removeAttr("disabled");
                             $("#update_email_code_button").html("获取超级签验证码");
                             return;
                         }
                         timeout--;
                         $("#update_email_code_button").html("获取超级签验证码  "+timeout);
                     },1000);
                 },function(){
             }); 
         }
        function deleteSendCode(){
            var url = "<%=basePath%>normal/adminEmailCodeAction!sendCode.action";
            var data = {
                "code_context" : "deleteRole",
                "isSuper" : true
            };
            goAjaxUrl(url, data,
                    function(tmp) {
 
                        $("#delete_email_code_button").attr("disabled", "disabled");
                        var timeout = 60;
                        setInt = setInterval(
                                function() {
                                    if (timeout <= 0) {
                                        clearInterval(setInt);
                                        timeout = 60;
                                        $("#delete_email_code_button").removeAttr("disabled");
                                        $("#delete_email_code_button").html("获取超级签验证码");
                                        return;
                                    }
                                    timeout--;
                                    $("#delete_email_code_button").html("获取超级签验证码  " + timeout);
                                }, 1000);
                    }, function() {
                    });
        }
        function goAjaxUrl(targetUrl, data, Func, Fail) {
            //         console.log(data);
            $.ajax({
                url : targetUrl,
                data : data,
                type : 'get',
                dataType : "json",
                success : function(res) {
//                     var tmp = $.parseJSON(res)
                    var tmp = res;
                    console.log(tmp);
                    if (tmp.code == 200) {
                        Func(tmp);
                    } else if (tmp.code == 500) {
                        Fail();
                        swal({
                            title : tmp.message,
                            text : "",
                            type : "warning",
                            showCancelButton : true,
                            confirmButtonColor : "#DD6B55",
                            confirmButtonText : "确认",
                            closeOnConfirm : false
                        });
                    }
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    swal({
                        title : "请求错误",
                        text : "请检查管理员邮箱是否配置",
                        type : "warning",
                        showCancelButton : true,
                        confirmButtonColor : "#DD6B55",
                        confirmButtonText : "确认",
                        closeOnConfirm : false
                    });
                    console.log("请求错误");
                }
            });
        }
    </script>
    
</body>
 
</html>