廖井涛
2024-03-04 9304249873268653bc6acd58538506e34933af9d
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
<%@page import="javax.swing.text.html.HTML"%>
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>权限设置</title>
 
<style>
 
  body,html{
        width:99%;
        height:95%
    }
 
 
#shangpin  {
            width: 99%;
            margin-left: 10px;
            
            margin-right: 10px;
                 border-collapse:separate;              
border-spacing: 0px;
        }
 
        #shangpin input {
            width: 97%;
            height: 20px;
            text-align: center;
            outline: none;
            
            
        }
 #tbody1 input
          {
              height:20px; width:100%; overflow:hidden;  border: 0;
          outline: 0;readyOnly:readyOnly;
          
          }
          
           #menu{
             position:absolute;
  top:55px;
           }
         
         
          #shangpin{
          left:190px;
             position:absolute;
  top:55px;
           }
           
            #xinzeng{
          right:290px;
             position:absolute;
  top:55px;
           }
           
           
            #fanhui{
          right:100px;
             position:absolute;
  top:55px;
           }
</style>
<script src="../../js/jquery-3.4.1.min.js"></script>
<link rel="stylesheet" href="../../css/quanxiang.css">
<link rel="shortcut icon" href="../../img/3.ico" />
 
</head>
 
 
<%@include file="../mysqlconnect.jsp"%>
<body  style='background-color:#D5EAFF'>
 
 
     <form action=""   method="post"   >
        
    <!--主页面左侧菜单栏实现-->
    
    <div class='menu' id='menu' >
        <%
 String adminid=request.getParameter("adminid");
        String erjibianhao=request.getParameter("erjibianhao1");
String anquanma=request.getParameter("anquanma");
System.out.println(adminid);
String cn="cn";
int mid=0;
//连接数据库
Class.forName(driverClass);{
    Connection con=DriverManager.getConnection( urlglass,user,password);
    
 //通过connection数据库链接对象 创建一个statement对象数据库操作对象
     Statement stmts=con.createStatement();
    //执行sql语句
     String anquan="select * from anquanbiao where anquanma = '"+request.getParameter("anquanma")+"' ";
     ResultSet rss = stmts.executeQuery(anquan);
     int coun=0;
     while(rss.next())
     {
      coun++;
     }
     if(coun==0){
      
     out.print("<script type='text/javascript'>alert('请先登录后操作');window.parent.location.href='../index.jsp'; </script>");
     }
     con.close();
}
 
 
 
%>
 
 
      </form>
      
         </div>
      <form  action=""   method="post" >
      
     
     
        
        
       <div id="chuanshu"   style="display:none;">
                        <input type="text" >
                         <input type="text"  name="id2">
                       <input type="text" name='mid'>
                      <input type="text" name='caidanid'>
                        <input type="text"  name='gongnengid' >
                        <input type="text" name='zhuangtai' > 
                        
                     
                   </div>
         <div id="data"  class='data'  align="center">
        
            <table  style='width:50%;' id="shangpin"  border="1" align="center" class='shangpin'> 
            <thead>
                <tr>
                     <th style="width:2px;">序号</th> 
                    
                    <th style="width:2px;display:none;">用户名id</th>
                    <th style="width:30px;display:none;">模块id</th>
                    <th style="width:30px;display:none;">菜单id</th>
                    <th style="width:30px;display:none;">功能id</th>
                    <th style="width:30px;" >选择 <input style="width:15px;right:500px;position:absolute;" type="checkbox"  id='all'  > </th>
                    <th style="width:30px;">用户名</th>
                    <th style="width:30px;">功能</th>
                    <th style="width:30px;display:none;">状态</th>
                    
                    
                </tr>
                </thead>
               
                <tbody id='tbody1'>
                   
               <%
 
               String erjibianhao1=request.getParameter("erjibianhao1");
               String caidanid=request.getParameter("erjibianhao1");
             
              
                      //装载一个类并且对其进行实例化的操作
                            Class.forName(driverClass);{
                                Connection con=DriverManager.getConnection( urlglass,user,password);
                                
                                //调用存储过程
                                CallableStatement cs = con.prepareCall("{call quanxiangongengchaxun(?,?)}");
                                
                                /* if(erjibianhao1==""){
                                    cs.setString(2, erjibianhao1);
                                    
                                }else{
                                    cs.setString(2, erjibianhao1);
                                    
                                } */
                                cs.setString(1, adminid);
                                cs.setString(2, erjibianhao1);
                                //判断订单日期是否为null
                                ResultSet rs = cs.executeQuery();
                                
                                int i=1;
                                 while(rs.next())
                                { 
                                     if(i%2!=0){
                                       out.println("<tr class='one1' >");    
                                       }
                                       else
                                       {
                                           out.println("<tr class='double1' >");      
                                       }
                                    out.print("<td style='text-align:center;'><input type='text' readOnly='readOnly'   style=' background:#D5EAFF;border:none;' value='"+i+"'></td>"); 
                                    out.print("<td style='display:none;'><input type='text'    value='"+adminid+"'></td>");
                                    out.print("<td style='display:none;'><input type='text'     value='"+rs.getString(5)+"'></td>");
                                    out.print("<td style='display:none;'><input type='text'     value='"+caidanid+"'></td>");
                                    out.print("<td style='display:none;'><input type='text'     value='"+rs.getString(1)+"'></td>");
                                    out.print("<td><input  type='checkbox' onclick='join(this)'  class='checkbox_1' id=''  value='0' ></td>");    
                                    out.print("<td><input type='text' readOnly='readOnly'   style=' background:#D5EAFF;border:none;'  value='"+rs.getString(3)+"'></td>");
                                    out.print("<td  ><input type='text' readOnly='readOnly'   style=' background:#D5EAFF;border:none;'  value='"+rs.getString(2)+"'></td>");
                                    out.print("<td style='display:none;'><input type='text'  class='zhuangtai'   value='"+rs.getString(4)+"'></td>");
                                     out.println("</tr>");    
                                    i++;
                                    
                                    }
                                 
                                 con.close();  
                                    
                                } 
                            
                             
                                
                                    
                   %> 
                  
                 
        
        
        
        
<% 
         
try{
         String    id3 =request.getParameter("id2"); 
         String    mid2 =request.getParameter("mid");
        String    gongnengid2 =request.getParameter("gongnengid");
         String    caidanid1 =request.getParameter("caidanid");
         String    zhuangtai2 =request.getParameter("zhuangtai");
        if(request.getParameter("tj")!=null){
//装载一个类并且对其进行实例化的操作
                             Class.forName(driverClass);{
                                Connection con=DriverManager.getConnection( urlglass,user,password);
                                
                                
                                    CallableStatement cs = con.prepareCall("{call shezhiquanxian(?,?,?,?,?,?,?,?)}");
                                    
                                    cs.setString(1, id3);
                                    
                                    cs.setString(2, mid2);
                                    cs.setString(3, caidanid1);
                                    cs.setString(4, gongnengid2);
                                    cs.setString(5, zhuangtai2);
                                    cs.setString(6, request.getRemoteAddr());
                                    cs.setString(7, request.getParameter("adminid"));
                         
                                    cs.registerOutParameter(8 , java.sql.Types.INTEGER);
                                    cs.execute();
                                    int fanhui=cs.getInt(8);
                                    if(fanhui==5000){    
                                        out.print("<script type='text/javascript'>alert('设置权限成功!');window.history.back(-1); </script>");
                                        
                                    }else{
                                        out.print("<script type='text/javascript'>alert('设置权限失败!');window.history.back(-1); </script>");
                                    }
                                    con.close();
                            }                        
                            }
}catch(Exception e){
    out.print("<script type='text/javascript'>alert('设置权限失败,出现未知错误!'); console.log(\""+ e.toString() +"\")</script>");     
}  
                            
                            %>  
                          
                            
                   <tbody>
                   </table>
                     <div id="bc">
                                <button type="submit" name="tj" style="float: right;width: 10%; height: 30px;;outline: 0;border: 0; background-color:#5CADFE;"  id="xinzeng" onclick="zhenghe()" value='0'  >确定</button>
                        </div>
                        
                        
                         <div id="fh">
                                <button  id='fanhui' type="button"  style="float: right;width: 10%; height: 30px;;outline: 0;border: 0; background-color:#5CADFE;"   onClick="window.history.back(-1);" value='0'  >返回</button>
                        </div>
                   </form>
        </div>             
    <script>
    
    
    
    window.onload=function()
    {  
        
        
        
         var btn = document.getElementById("all");
         btn.onclick = function() {
             var flag = this.checked;
             var items = document.getElementsByClassName("checkbox_1");
             for (var i = 0; i < items.length; i++) {
                 items[i].checked = flag;
                 items[i].value=1;
                 //将所有item的状态设为全选按钮的状态
                 if(items[i].checked==false){
                     items[i].value=0; 
                     
                 }
             }
             
         }
 
 
         var items = document.getElementsByClassName("checkbox_1");
         for (var i = 0; i < items.length; i++) {
             items[i].onclick = function() {//对每个item设置点击
                 var number = 0;//记录选中的个数
                 for (var j = 0; j < items.length; j++) {
                     if (items[j].checked) {
                         number++;
                         items[j].value=1;
                     }
                     
                     
                 }
                 
                 
                 for (var j = 0; j < items.length; j++) {
                     if(items[j].checked==false){
                         items[j].value=0; 
                         
                     }
                     
                     
                 }
                 document.getElementById("all").checked = (items.length == number);
             }
         }
 
 
        var cells=$('#shangpin').find('tr');
        for(var i=1;i<cells.length;i++)
        {
            
            var zhuangtai= $('#shangpin').find("tr").eq(i).find("input[class='zhuangtai']").val();
            const check=$('#shangpin').find('tr').eq(i).find('.checkbox_1');
              const lls=($('#shangpin').find("tr").eq(i).find("input[class='checkbox_1']").val());
              if(zhuangtai == 1){
                  check[0].checked=true;
                  check[0].value=1;
              }
            
        }
        
    }
       
    
    
     /*    $('#all').click(function(){
      $('.shangpin input').prop('checked',$(this).prop('checked'));
 
   });
   $('.shangpin input').click(function(){
   //each 便利每一个元素,让其执行该函数
   $('.shangpin input').each(function(){
    if(!$(this).prop('checked')){
    $('#all').prop('checked',false);
    
    //有一个不满足就 跳出该循环,避免执行下面
    return false;
    }
   })
   }) */
   
   
   /* 
    var cksAll=document.getElementById('all');
    var cks = document.getElementById('shangpin').getElementsByClassName("checkbox_1");
    cksAll.onclick=function() {
      for (var i = 0; i < cks.length; i++) {
        cks[i].checked=this.checked;
        cks[i].value=1;
      }
    };
    var cks = document.getElementById('shangpin').getElementsByClassName("checkbox_1");
    for(var i=0;i<cks.length;i++){
        
        
      cks[i].onclick=function(){
        
      
       var flag=true;
       for(var j=0;j<cks.length;j++){
           
           cks[j].value=0;
        if(!cks[j].checked){
          flag=false;
          
         
          break;
        }
       }
       cksAll.checked=flag;
       
      };
    } */
    
    
    
    function zhenghe()
    {
        var tiaoshu=$('#data').find('tr').length;
       
         var lieshu=$("#data").find('th').length ;
         var cars = [];
         cars[0]=1;
         var value1=document.getElementById('shangpin');
         
         for(var i=0;i<lieshu;i++)
         { 
             cars[i]='';
            
             for(var j=1;j<tiaoshu;j++)
             {  
                 
                 
               /*   alert(value1.rows[j].cells[i].getElementsByTagName("input")[0].value); */
                 var value2=value1.rows[j].cells[i].getElementsByTagName("input")[0].value;
                
                    
                    
                   
                      
                 
                
                    cars[i]+=value2+'~';
                        
                    /* alert('i:'+i+'j:'+j); */
                
             }
             
         }
   
 
    var chuanshu_count=$("#chuanshu").find('input');
    for(p=0;p<chuanshu_count.length;p++)
    {
        chuanshu_count[p].value=cars[p];
        
    }
 
    }
    
    
    
    function join(e){
            if(e.checked==true ){
                e.value=1;
                }else{
            e.value=0;
        }
        }
    
   
      
        /* function tiaoz(n){
            n=n+window.parent.location.search.substr(1);
            window.open(n);} */
    </script>
</body>
</html>