lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    
   <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />
    <title><s:text    name="Parameter_Set" /></title>
    <link href="css/basic.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="css/paramInstall.css">
    <script type="text/javascript" src="js/frame.js"></script>
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="js/base.js"></script>
    
    <style type="text/css">
        #loading{
            display:none;
            position:fixed;
            width:100px;
            height:100px;
            top:50%;
            left:50%;
            margin-top:-50px;
            margin-left:-50px;
        }
    
        #loading img{
            width:100%;
            height:100%;
        }
    </style>
</head>
<body>
    <!--头部内容开始-->
    <jsp:include page="Top.jsp" flush="true"/>
    <!--头部内容结束-->
    <!-- 主体内容 -->
    <div id="main">
        <!--导航开始-->
        <jsp:include page="nav.jsp" flush="true"/>
        <!--导航结束-->
        <!-- 页面内容 -->
        <div id="content">
            <!-- 左边栏内容 -->
            <div class="left">
                <table>
                    <tr>
                        <td colspan="2">
                            <!-- 服务器连接参数设置 -->
                            <span class="server-param"><strong><s:text    name="Server_Parameters_Set" /></strong></span>
                        </td>
                    </tr>
                    <tr>
                        <!-- 参数设置 -->
                        <td class="fweight"><s:text    name="Parameter_Set" /></td>
                        <td>
                            <select name="" id="server_app_param">
                                <option value="discharge"><s:text name="Batt_discharge" /></option>            <!-- 电池放电 -->
                                <option value="charge"><s:text name="Batt_charging" /></option>            <!-- 电池充电 -->
                                <option value="poweroff"><s:text name="Utility_Failure" /></option>            <!-- 市电停电 -->
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <!-- 测试数据保存时间间隔(5~600秒) -->
                        <td class="fweight"><s:text    name="Test_Savetime_Interval" /></td>
                        <td><input type="text" id="SaveDataTimeInterval" value=""></td>
                    </tr>
                    <tr>
                        <!-- 测试数据有效果性最短测试时间(1~60)分钟 -->
                        <td class="fweight"><s:text    name="Test_data_shortest_test_time" /></td>
                        <td><input type="text" id="TestTimeLongMinimum" value=""></td>
                    </tr>
                    <tr>
                        <!-- 2V单体电压变化存储阀值 -->
                        <td class="fweight"><s:text    name="Voltage_change_threshold" /></td>
                        <td><input type="text" id="MonVolChangeLevel" value=""></td>
                    </tr>
                    <tr>
                        <!-- 数据记录最大笔数(5000~20000) -->
                        <td class="fweight"><s:text    name="Data_record_number" /></td>
                        <td><input type="text" id="TestDataRecordCountMax" value=""></td>
                    </tr>
                    <tr>
                        <!-- 同时充放电测试电池组数(10~350) -->
                        <td class="fweight"><s:text    name="Charge_Discharge_Battery" /></td>
                        <td><input type="text" id="BattTestGroupCountMax" value=""></td>
                    </tr>
                    <tr>
                        <td colspan="2"><input type="button" id="app_param_btn" value="<s:text    name='Determine'/>"></td>        <!-- 确定 -->
                    </tr>
                    <tr>
                        <td colspan="2">
                            <!-- 连接参数设置 -->
                            <span class="connect-param"><strong><s:text    name="Connect_parameter_Set" /></strong></span>
                        </td>
                    </tr>
                    <tr>
                        <!-- 服务器IP地址 -->
                        <td class="fweight"><s:text    name="Server_IP" /></td>
                        <td><input style="width: 50%" type="text" id="ip_value" value="" disabled="disabled" ><input id="ip_param_btn" style="margin-left:6% !important;" type="button" value="<s:text    name='Determine'/>"></td>
                    </tr>
                </table>
            </div>
            <!-- 右边栏内容 -->
            <div class="right">
                <!-- 图表分析显示参数 -->
                <span class="img-param"><strong><s:text    name="Chart_analysis_parameter" /></strong></span>
                <!-- 选项卡内容 -->
                <div class="tab-container">
                    <div class="tab">
                        <!-- 图表显示参数 -->
                        <a href="javascript:" class="head-end action"><s:text    name="Chart_parameter" /></a>
                        <!-- 数据分析参数 -->
                        <a href="javascript:"><s:text    name="Data_analysis_parameter" /></a>
                        <!-- 告警提示参数 -->
                        <a href="javascript:" class="head-end"><s:text    name="Warn_parameter" /></a>
                    </div>
                    <div class="tab-content">
                        <!-- 第一个内容 -->
                        <div class="tab-list show">
                            <table>
                                <tr>
                                    <!-- 机房和电池组名称显示规则 -->
                                    <td colspan="3" class="fweight"><strong><s:text    name="Engine_battery_display" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 显示机房ID号 -->
                                    <td><input type="checkbox"><span><s:text    name="Show_room_ID" /></span></td>
                                    <!-- 树形列表层数(3~9) -->
                                    <td><s:text    name="Tree_number_column" /></td>
                                    <!--树形列表排序关键字 -->
                                    <td><s:text    name="Tree_list_sort_keywords" /></td>
                                </tr>
                                <tr>
                                    <!--显示电池组ID和序号 -->
                                    <td><input type="checkbox"><span><s:text name="Display_batteryID_number" /></span></td>
                                    <td><input type="text" value="3"></td>
                                    <td><input type="text" value="10"></td>
                                </tr>
                                <tr>
                                    <!--     柱状图和曲线参数 -->
                                    <td colspan="3" class="fweight"><strong><s:text    name="Histogram_curve_parameter" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 柱状图高亮 -->
                                    <td rowspan="2"><input type="checkbox"><s:text    name="Histogram_highlight" /></td>
                                    <!-- 曲线头尾时间刻度(0~99M) -->
                                    <td><s:text    name="Tail_calibration_curve" /></td>
                                    <!-- 曲线中断时间间隔(0~99M) -->
                                    <td><s:text    name="Curve_interrupt_interval" /></td>
                                </tr>
                                <tr>
                                    <td><input type="text" value="10"></td>
                                    <td><input type="text" name="" value="5"></td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <!--表格显示参数 -->
                                    <td colspan="4" class="fweight"><strong><s:text    name="Table_parameter" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 自动平铺列 -->
                                    <td rowspan="2"><input type="checkbox"><s:text    name="Automatic_tile_column" /></td>
                                    <!-- 强制平铺列数阀值(2~20) -->
                                    <td><s:text    name="Compulsory_column_threshold" /></td>
                                    <!-- 表格行高度 -->
                                    <td><s:text    name="Table_row_height" /></td>
                                    <!-- 分页行数显示 -->
                                    <td><s:text    name="Page_number_display" /></td>
                                </tr>
                                <tr>
                                    <td><input type="text" value="8"></td>
                                    <td><input type="text" value="32"></td>
                                    <td><input type="text" value="50"></td>
                                </tr>
                            </table>
                        </div>
                        <!-- 第二个内容 -->
                        <div class="tab-list hide">
                            <form id="data_parm_form" method="post">
                            <table>
                                <tr>
                                    <!-- 单体电压分析阀值(0~200%) -->
                                    <td colspan="3" class="fweight"><strong><s:text    name="Threshold_voltage_analysis" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 比平均值次低 -->
                                    <td><s:text    name="Parameter_Set" /><s:text    name="Lowest_Avg" /></td>
                                    <!-- 比平均值低 -->
                                    <td><s:text    name="Parameter_Set" /><s:text    name="Low_Avg" /></td>
                                    <!-- 平均值高(保留) -->
                                    <td><s:text    name="Parameter_Set" /><s:text    name="Height_Avg" /></td>
                                </tr>
                                <tr>
                                    <td><input type="text" value="1.0" id="voltage_subharmonic" name="list[0].low_value"/></td>
                                    <td><input type="text" value="1.0" id="voltage_low" name="list[1].low_value"></td>
                                    <td><input type="text" value="2.0" readonly></td>
                                </tr>
                                <tr>
                                    <!-- 单体内阻/电导分析阀值(0~100%) -->
                                    <td colspan="3" class="fweight"><strong><s:text    name="Parameter_Set" /><s:text    name="Res_analysis_threshold" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 告警 -->
                                    <td><s:text    name="Alarm" /></td>
                                    <!-- 更换 -->
                                    <td><s:text    name="Change" /></td>
                                    <!-- 分析方法 -->
                                    <td><s:text    name="Analysis_method" /></td>
                                </tr>
                                <tr>
                                    <td><input type="text" value="90.0" id="conductance_alarm" name="list[3].low_value"/></td>
                                    <td><input type="text" value="80.0" id="conductance_change" name="list[4].low_value"></td>
                                    <td>
                                        <select name="" id="conductance_method" name="list[3].low_method" name="list[4].low_method">
                                            <option value="1"><s:text    name="Average" /></option>            <!-- 平均值 -->
                                            <option value="0"><s:text    name="Nominal_value" /></option>    <!-- 标称值 -->
                                        </select>
                                    </td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <!-- 单体实际容量分析阀值(0~100%) -->
                                    <td colspan="4" class="fweight"><strong><s:text    name="Cap_analysis_threshold" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 放电有效容量分析阀值 -->
                                    <td><s:text    name="Discharge_threshold_effective" /></td>
                                    <!-- 告警 -->
                                    <td><s:text    name="Alarm" /></td>
                                    <!-- 更换 -->
                                    <td><s:text    name="Change" /></td>
                                    <!-- 分析方式 -->
                                    <td><s:text    name="Analysis_method" /></td>
                                </tr>
                                <tr>
                                    <td><input type="text" value="1.0" id="cap_valid"></td>
                                    <td><input type="text" value="1.0" id="cap_alarm"></td>
                                    <td><input type="text" value="1.0" id="cap_change"></td>
                                    <td>
                                        <select name="" id="cap_method" disabled>
                                            <option value="0"><s:text    name="Average" /></option>            <!-- 标称值 -->
                                            <option value="1"><s:text    name="Nominal_value" /></option>    <!-- 平均值 -->
                                        </select>
                                    </td>
                                </tr>
                            </table>
                            </form>
                        </div>
                        <!-- 第三个内容 -->
                        <div class="tab-list hide">
                            <table>
                                <tr>
                                    <!-- 电池告警提示参数 -->
                                    <td colspan="3" class="fweight"><strong><s:text    name="Battery_alarm_paramter" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 电池告警提示参数 -->
                                    <td><input type="checkbox"><span><s:text    name="Battery_alarm_paramter" /></span></td>
                                    <!-- 告警语音播报 -->
                                    <td><input type="checkbox"><span><s:text    name="Alarm_speech" /></span></td>
                                    <!-- 自动弹出告警窗口 -->
                                    <td><input type="checkbox"><span><s:text    name="Automatic_alarm_Window" /></span></td>
                                </tr>
                                <tr>
                                    <!-- 设备告警提示参数 -->
                                    <td colspan="3" class="fweight"><strong><s:text    name="Battery_alarm_paramter" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 电池告警提示参数 -->
                                    <td><input type="checkbox"><span><s:text    name="Battery_alarm_paramter" /></span></td>
                                    <!-- 告警语音播报 -->
                                    <td><input type="checkbox"><span><s:text    name="Alarm_speech" /></span></td>
                                    <!-- 自动弹出告警窗口 -->
                                    <td><input type="checkbox"><span><s:text    name="Automatic_alarm_Window" /></span></td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <!-- 设备告警提示参数 -->
                                    <td colspan="2" class="fweight"><strong><s:text    name="Device_alarm_paramter" /></strong></td>
                                </tr>
                                <tr>
                                    <!-- 电池告警提示参数 -->
                                    <td><input type="checkbox"><span><s:text    name="Battery_alarm_paramter" /></span></td>
                                    <!-- 告警语音播报 -->
                                    <td><input type="checkbox"><span><s:text    name="Alarm_speech" /></span></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <!-- 选项卡结束 -->
            </div>
            <!-- 清除浮动 -->
            <div class="clear"></div>
            <!-- 按钮容器 -->
            <div class="button-container">
                <input type="button" id="pic_param_btn" value="<s:text    name='Determine'/>">        <!-- 确定 -->
            </div>
        </div>
        <!-- 页面内容 -->
    </div>
    <!-- 主体内容结束 -->
    <div id="loading"><img src="image/loading.gif"></div>
    <!--清除浮动-->
    <div class="clear"></div>
</body>
<script type="text/javascript" src="js/buildNav.js"></script>
<script type="text/javascript">
    var permits;
    <%    Object obj=session.getAttribute("permits");
        if(obj!=null){
            String permits =obj.toString();  %>
            permits=<%=permits%>;
            //console.info(json);
    <%    }    %>
    
    var Batt_param_lowlist;        //所有的阀值
    var parmtitlename;            //单击参数选项的名字
    var appParamlist;            //服务器参数数组
 
    //查询数据分析参数
    $(document).ready(function(){
        setUserName();
        $.post("Batt_param_lowAction_searchAll",null,function(data){
            data=data.result;
            data=eval("("+data+")");
            if(data.code==1 && data.data.length>0){
                data=data.data;
                Batt_param_lowlist=data;
                //console.info(data);
                for(var i=0;i<data.length;i++){
                    //电压比平均阈值次低
                    if(data[i].low_type==1 && data[i].low_nametype==1 && data[i].low_method==1){
                        //console.info(data[i].low_value);
                        $('#voltage_subharmonic').attr('value',((data[i].low_value)*100).toFixed(1));
                        $('#voltage_subharmonic').attr('oldvalue',((data[i].low_value)*100).toFixed(1));
                    }else if(data[i].low_type==1 && data[i].low_nametype==0 && data[i].low_method==1){
                    //电压比平均阈值低
                        $('#voltage_low').attr('value',((data[i].low_value)*100).toFixed(1));
                        $('#voltage_low').attr('oldvalue',((data[i].low_value)*100).toFixed(1));
                    }else if(data[i].low_type==3 && data[i].low_nametype==2){
                        //电导告警
                        //console.info(data[i]);
                        if(data[i].low_method==1){
                            //平均值
                            //$('#conductance_method option').eq(1).prop('selected',false);
                            $('#conductance_method option').eq(1).prop('selected',true);
                            //alert($('#conductance_method option').eq(0).text());
                        }else if(data[i].low_method==0){
                            //标称值
                            //alert();
                            $('#conductance_method option').eq(1).prop('selected',true);
                            //$('#conductance_method option').eq(0).prop('selected',false);
                        }
                        $('#conductance_alarm').attr('value',(data[i].low_value*100).toFixed(1));
                        $('#conductance_alarm').attr('oldvalue',(data[i].low_value*100).toFixed(1));
                    }else if(data[i].low_type==3 && data[i].low_nametype==3){
                        //电导更换
                        if(data[i].low_method==1){
                            $('#conductance_method option').eq(0).prop('selected',true);
                        }else if(data[i].low_method==0){
                            //console.info($('#conductance_method option').eq(0));
                            $('#conductance_method option').eq(1).prop('selected',true);
                        }
                        $('#conductance_change').attr('value',(data[i].low_value*100).toFixed(1));
                        $('#conductance_change').attr('oldvalue',(data[i].low_value*100).toFixed(1));
                    }else if(data[i].low_type==2 && data[i].low_nametype==1 &&  data[i].low_method==0){
                        //电容有效阈值(次低)
                        $('#cap_valid').attr('value',(data[i].low_value*100).toFixed(1));
                        $('#cap_valid').attr('oldvalue',(data[i].low_value*100).toFixed(1));
                    }else if(data[i].low_type==2 && data[i].low_nametype==2 &&  data[i].low_method==0){
                        //console.info(data[i].low_value);
                        //电容告警
                        $('#cap_alarm').attr('value',(data[i].low_value*100).toFixed(1));
                        $('#cap_alarm').attr('oldvalue',(data[i].low_value*100).toFixed(1));
                        
                    }else if(data[i].low_type==2 && data[i].low_nametype==3 &&  data[i].low_method==0){
                        //电容更换
                        $('#cap_change').attr('value',(data[i].low_value*100).toFixed(1));
                        $('#cap_change').attr('oldvalue',(data[i].low_value*100).toFixed(1));
                    }
                }
            }
            
        });
    });
    
    //根据当前的修改选项修改数据
    $('.button-container input[type="button"]').click(function(){
        if(parmtitlename=='<s:text name="Chart_parameter" />'){                        /* 图表显示参数 */
        
        }else if(parmtitlename=='<s:text name="Data_analysis_parameter" />'){        /* 数据分析参数 */
            updataDataParm();                            
        }else if(parmtitlename=='<s:text name="Warn_parameter" />'){                /* 告警提示参数 */
        
        }
    });
    
    function updataDataParm(){
        if(confirm("<s:text name='Confirm_Chage'/>"+parmtitlename+"?")){
            var list=new Array();
            //console.info(list);
            
            var list_index=0;
            list[list_index]=Batt_param_lowlist[list_index];
            list[list_index].low_type=1;
            list[list_index].low_nametype=1;
            list[list_index].low_value=$('#voltage_subharmonic').attr('value')/100;
            list[list_index++].low_method=1;
            
            list[list_index]=Batt_param_lowlist[list_index];
            list[list_index].low_type=1;
            list[list_index].low_nametype=0;
            list[list_index].low_value=$('#voltage_low').attr('value')/100;
            list[list_index++].low_method=1;
            
            list[list_index]=Batt_param_lowlist[list_index];
            list[list_index].low_type=3;
            list[list_index].low_nametype=2;
            list[list_index].low_value=$('#conductance_alarm').attr('value')/100;
            list[list_index++].low_method=$('#conductance_method').attr('value');
            
            list[list_index]=Batt_param_lowlist[list_index];
            list[list_index].low_type=3;
            list[list_index].low_nametype=3;
            list[list_index].low_value=$('#conductance_change').attr('value')/100;
            list[list_index++].low_method=$('#conductance_method').attr('value');
            
            list[list_index]=Batt_param_lowlist[list_index];
            list[list_index].low_type=2;
            list[list_index].low_nametype=1;
            list[list_index].low_value=$('#cap_valid').attr('value')/100;
            list[list_index++].low_method=$('#cap_method').attr('value');
            
            list[list_index]=Batt_param_lowlist[list_index];
            list[list_index].low_type=2;
            list[list_index].low_nametype=2;
            list[list_index].low_value=$('#cap_alarm').attr('value')/100;
            list[list_index++].low_method=$('#cap_method').attr('value');
            
            list[list_index]=Batt_param_lowlist[list_index];
            list[list_index].low_type=2;
            list[list_index].low_nametype=3;
            list[list_index].low_value=$('#cap_change').attr('value')/100;
            list[list_index++].low_method=$('#cap_method').attr('value');
            var blowstr=window.JSON.stringify(list);
            $.post("Batt_param_lowAction_updateAll","blowstr="+blowstr,function(data){
                //console.info(data);
                data=data.result;
                data=eval("("+data+")");
                if(data.code==1){
                    alert("<s:text name='Chage_Success'/>");        /* 更新成功 */
                }else{
                    alert("<s:text name='Chage_failed'/>");            /* 更新失败 */
                }
            });
        }
        
    }
    
    //当输入框失去焦点时触发校验数值函数
    $('#content .tab-list').eq(1).find("input").blur(function(){
        var newvalue=parseFloat($(this).val());
        var oldvalue=$(this).attr('oldvalue');
        //alert($(this).prop('id'));        
        if($(this).prop('id')=='voltage_subharmonic' || $(this).prop('id')=='voltage_low'){
            if(newvalue>0 && newvalue<=200){                
                $(this).attr('oldvalue',newvalue.toFixed(1));
                $(this).attr('value',newvalue.toFixed(1));
            }else{
                alert('<s:text name="Please_enter_the_legitimate_number"/>');
                $(this).attr('value',oldvalue);
            }
        }else{
            if(newvalue>0 && newvalue<=100){
                $(this).attr('oldvalue',newvalue.toFixed(1));
                $(this).attr('value',newvalue.toFixed(1));
            }else{
                alert('<s:text name="Please_enter_the_legitimate_number"/>');
                $(this).attr('value',oldvalue);
            }        
        }
    });
    
        
 
    //点击页面内容的事件
    $(document).ready(function(){
        //点击页面选项卡切换
        $('#content .right .tab-container .tab a').click(function(){
            parmtitlename=$(this).text();
            var aIndex=$(this).index();
            var tabList=$('#content .right .tab-content .tab-list');    //获取选项卡内容集合
            //选项卡响应,去掉下边框
            $('#content .right .tab-container .tab a').removeClass('action');
            $(this).addClass('action');
            //显示对应的选项卡内容
            tabList.slideUp();
            tabList.eq(aIndex).slideDown();
        });
    });
    
    //当切换服务器参数时
    $(document).ready(function(){
        searchAppParam($('#server_app_param').val());
        getIp();
        //当选择的服务器参数类型改变时查询参数
        $('#server_app_param').change(function(){
            searchAppParam($('#server_app_param').val());
        });
        
        //测试数据保存时间间隔
        $('#SaveDataTimeInterval').blur(function(){
            if($(this).val() > 600){
                $(this).val(600);
            }else if($(this).val() < 5){
                $(this).val(5);
            }
            $(this).val(parseFloat($(this).val()).toFixed(0));
        });
        
        //数据有效性最短测试时间
        $('#TestTimeLongMinimum').blur(function(){
            if($(this).val() > 60){
                $(this).val(60);
            }else if($(this).val() < 1){
                $(this).val(1);
            }
            $(this).val(parseFloat($(this).val()).toFixed(0));
        });
        
        //2v单体电压变化存储阀值
        $('#MonVolChangeLevel').blur(function(){
            if($(this).val() > 1){
                $(this).val((1).toFixed(3));
            }else if($(this).val() < 0.01){
                $(this).val((0.01).toFixed(3));
            }
            $(this).val(parseFloat($(this).val()).toFixed(3));
        });
        
        //数据记录最大笔数
        $('#TestDataRecordCountMax').blur(function(){
            if($(this).val() > 20000){
                $(this).val(20000);
            }else if($(this).val() < 5000){
                $(this).val(5000);
            }
            $(this).val(parseFloat($(this).val()).toFixed(0));
        });
        
        //同时充放电测试电池组数
        $('#BattTestGroupCountMax').blur(function(){
            if($(this).val() > 350){
                $(this).val(350);
            }else if($(this).val() < 10){
                $(this).val(10);
            }
            $(this).val(parseFloat($(this).val()).toFixed(0));
        });
        
        //点击修改服务器参数时更新参数
        $('#app_param_btn').click(function(){
            if(confirm("确定更新'服务器参数'吗?")){
                var temp = getUpdateArr();
                if(temp.length > 0){
                    var json=window.JSON.stringify(temp);
                    $.ajax({     
                            type: "post",                 
                            url: "App_ParamAction!update",                
                            async:true,                
                            dataType:'text',
                            data:"json="+json,        
                            success: function(data){ 
                                data=eval("("+data+")");
                                var model = eval("("+data.result+")");
                                if(model.code==1){
                                    alert("更新服务器参数成功!需要重新启动服务器才会生效!");
                                }else{
                                    alert("更新服务器参数失败!");
                                }
                            },
                            error:function(e){
                                console.log(e);
                            }                 
                    });
                }
            }    
        });
        
        var flag=true;
        //检查ip地址的格式
        $('#ip_value').blur(function(){
            var reg =  /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;    
            if(reg.test($(this).val())){
                flag = true;
            }else{
                flag = false;
                alert('您输入的ip地址格式不正确请重启输入');
                $('#ip_value').val($(this).attr('oldvalue'));
            }
        });
        
        /* //点击修改ip地址按钮
        $('#ip_param_btn').click(function(){
            if(flag){
                updateIp();
            }
        }); */
    });
    
    //查询服务器参数
    function searchAppParam(pname){
        var temp={
            param_name:pname
        };
        var json=window.JSON.stringify(temp);
        $.ajax({     
                type: "post",                 
                url: "App_ParamAction!serchByInfo",                
                async:true,                
                dataType:'text',
                data:"json="+json,        
                success: function(data){ 
                    data=eval("("+data+")");
                    var model = eval("("+data.result+")");
                    if(model.code==1){
                        appParamlist = new Array();
                        appParamlist = model.data;
                        console.info(model);
                        setParam(model.data);
                    }
                },
                error:function(e){
                    console.log(e);
                }                 
        });
    }
    
    //获取服务器的ip地址
    function getIp(){
        $.ajax({     
            type: "post",                 
            url: "App_ParamAction!seaechIp",                
            async:true,                
            dataType:'text',
            success: function(data){ 
                data=eval("("+data+")");
                var model = eval("("+data.result+")");
                if(model.code==1){
                    $('#ip_value').val(model.msg);
                    $('#ip_value').attr("oldvalue",model.msg);
                }
            },
            error:function(e){
                console.log(e);
            }                 
        });
    }
    
    //修改服务器ip地址
    function updateIp(){
        var ip = $('#ip_value').val();
        if(confirm("确认修改服务器ip地址为:"+ip+"?,修改成功之后需要重新登陆!")){
            $('#loading').show();
            createAllMask($('body'),0);
            $.ajax({     
                type: "post",                 
                url: "App_ParamAction!updataIp",                
                async:true,
                data:"json="+ip,                
                dataType:'text',
                success: function(data){ 
                    data=eval("("+data+")");
                    var model = eval("("+data.result+")");
                    if(model.code==1){
                        alert("服务器ip地址修改成功,请重新登陆");
                        exitUser();
                        window.location.href="zzlogin1.jsp";
                    }else{
                        alert(model.msg);
                        $('#ip_value').val($('#ip_value').attr('oldvalue'));
                    }
                    $('#loading').hide();
                    $('.mask').remove();
                },
                error:function(e){
                    console.log(e);
                    $('#loading').hide();
                    $('.mask').remove();
                }                 
            });
        }
    }
    
    //根据数组设置服务器参数设置
    function setParam(arr){
        if(arr != undefined && arr.length>0    ){
            for(var i = 0 ;i <arr.length;i++){
                if(arr[i].param_name == 'discharge_SaveDataTimeInterval' || arr[i].param_name == 'charge_SaveDataTimeInterval' || arr[i].param_name == 'poweroff_SaveDataTimeInterval'){
                    $('#SaveDataTimeInterval').val(arr[i].param_value);
                }else if(arr[i].param_name == 'discharge_TestTimeLongMinimum' || arr[i].param_name == 'charge_TestTimeLongMinimum' || arr[i].param_name == 'poweroff_TestTimeLongMinimum'){
                    $('#TestTimeLongMinimum').val(arr[i].param_value/60);
                }else if(arr[i].param_name =='discharge_MonVolChangeLevel' || arr[i].param_name =='charge_MonVolChangeLevel' || arr[i].param_name =='poweroff_MonVolChangeLevel'){
                    $('#MonVolChangeLevel').val(arr[i].param_value.toFixed(3));
                }else if(arr[i].param_name =='discharge_TestDataRecordCountMax' ||arr[i].param_name =='charge_TestDataRecordCountMax' || arr[i].param_name =='poweroff_TestDataRecordCountMax'){
                    $('#TestDataRecordCountMax').val(arr[i].param_value);
                }else if(arr[i].param_name =='discharge_BattTestGroupCountMax' ||arr[i].param_name =='charge_BattTestGroupCountMax' || arr[i].param_name =='poweroff_BattTestGroupCountMax'){
                    $('#BattTestGroupCountMax').val(arr[i].param_value);
                }
            }
        }
    }
    
    //根据文本框获取需要修改的对象数组
    function getUpdateArr(){
        var arr = new Array();
        if(appParamlist != undefined){
            for(var i = 0;i < appParamlist.length;i++){
                if(appParamlist[i].param_name.indexOf('SaveDataTimeInterval')>0){
                    arr.push({
                        num:appParamlist[i].num,
                        param_value:$('#SaveDataTimeInterval').val(),
                    });
                }else if(appParamlist[i].param_name.indexOf('TestTimeLongMinimum')>0){
                    arr.push({
                        num:appParamlist[i].num,
                        param_value:$('#TestTimeLongMinimum').val()*60,
                    });
                }else if(appParamlist[i].param_name.indexOf('MonVolChangeLevel')>0){
                    arr.push({
                        num:appParamlist[i].num,
                        param_value:$('#MonVolChangeLevel').val(),
                    });
                }else if(appParamlist[i].param_name.indexOf('TestDataRecordCountMax')>0){
                    arr.push({
                        num:appParamlist[i].num,
                        param_value:$('#TestDataRecordCountMax').val(),
                    });
                }else if(appParamlist[i].param_name.indexOf('BattTestGroupCountMax')>0){
                    arr.push({
                        num:appParamlist[i].num,
                        param_value:$('#BattTestGroupCountMax').val(),
                    });
                }
            }
        }
        console.info(arr);
        return arr;
    }
</script>
</html>