gai
didiyu
2018-12-25 83341b9c8c9baaae53533d597fa2fe4426f756f1
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
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>电池组安装提交申请</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="mobilCss/jquery.mobile-1.4.5.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/tbl.css">
    <script type="text/javascript" src="mobilJs/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="js/tbl.js"></script>
    <script type="text/javascript" src="mobilJs/base.js"></script>
    <script type="text/javascript" src="mobilJs/jquery.mobile-1.4.5.min.js"></script>
    <style type="text/css">     
       
        table {
            margin-top:.5em;
            border-collapse:separate; 
            border-spacing:0 .5em;
        }
        
        tbody tr td{
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
        }
        .uncheck{
            background-color: #dddddd38!important;
            color: #bdbdbdc4!important;
        }
        .ui-btn-icon-right {
            padding-right: 8.5em;
        }
        .hbg{
            background-color:#ddd9;
        }
        #battdata {
            background-color:#dddddd54
        }
        .ui-select .ui-btn select{
            width:77%;
        }
    </style>
    <link rel="stylesheet" href="css/fgpanel.css">
</head>
<body>
    <div data-role="page">
        
        <!-- 头部内容 -->
        <div data-role="header" data-position="fixed">
            <a href="ele-param2.html" target="_top" class="ui-btn ui-corner-all ui-shadow ui-icon-back ui-btn-icon-left" style="padding-top: 0.7em; padding-bottom: 0.7em;">返回</a>
            <h1>电池组申请安装</h1>
            
        </div>
        <!-- 主体内容 -->
        <div data-role="main">
            <!-- <div class="set-option"> -->
                                <table class="layout-set">
                                    <tbody>
                                        <tr>
                                            <td>机房编号</td>
                                            <td>
                                                <input type="text" id="StationId" class="unable" data-mini="true" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>省</td>
                                            <td>
                                                <select id="mainteArea" data-mini="true">
                                                  <option value="">全部</option>
                                                  <option value="">一枢纽</option>
                                                  <option value="">二枢纽</option>
                                                  <option value="">枢纽楼</option>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>城市</td>
                                            <td>
                                                <select id="city" data-mini="true">
                                                    <option value="">全部</option>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>区县</td>
                                            <td>
                                                 <select id="country" data-mini="true">
                                                    <option value="">全部</option>
                                                 </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>机房名称</td>
                                            <td>
                                                <select id="homeName" data-mini="true">
                                                    <option value="">全部</option>
                                                </select>
                                            </td>
                                        </tr>
                                        
                                            
                                                <input type="hidden" id="StationName4" data-mini="true" />
                                            
                                        
                                                <input type="hidden" id="StationIp" data-mini="true" />
                                            
                                        
                                        <tr>
                                            <td>FBS设备ID(重要)</td>
                                            <td>
                                                <input type="text" id="FBSDeviceId" class="unable" data-mini="true" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>FBS设备IP(重要)</td>
                                            <td>
                                                <input type="text" id="FbsDeviceIp" class="unable" data-mini="true" />
                                            </td>
                                        </tr>
                                        
                                            
                                                <input type="hidden" id="FbsDeviceIp_YM" class="unable" data-mini="true" value="456"/>    
                                                <input type="hidden" id="FbsDeviceIp_WG" class="unable"  data-mini="true" value="456"/>
                                                <input type="hidden" id="FBSDeviceName" data-mini="true" />
                                            
                                        
                                    
                                        <tr>
                                            <td>电池组ID</td>
                                            <td>
                                                <input type="text" readonly unselectable="on" value="123"class="unable" id="BattGroupId" class="uncheck" data-mini="true" />
                                            </td>
                                        </tr>
                                        
                                            
                                                <input type="hidden" readonly unselectable="on" value="123" id="BattGroupNum" class="unable" class="uncheck" data-mini="true" />
                                            
                                        
                                                <input type="hidden" id="FloatVolLevel" data-mini="true" />
                                            
                                        
                                            
                                                <input type="hidden" id="OfflineVolLevel" class="unable" data-mini="true" />
                                            
                                        
                                            
                                                <input type="hidden" id="BattFloatCurrent" class="unable" data-mini="true" />
                                            
                                        
                                        <tr>
                                            <td>*单体数量</td>
                                            <td>
                                                <!-- <input type="text" id="MonCount" data-mini="true" /> -->
                                                
                                                  <fieldset data-role="controlgroup" data-type="horizontal">
                                                    <label for="four">4 个</label>
                                                    <input type="radio" name="battnum" id="four" value="4">
                                                    <label for="twentyfour">24个</label>
                                                    <input type="radio" name="battnum" id="twentyfour" value="24"> 
                                                  </fieldset>
                                                    
                                                
                                                
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>标称单体电压(V)</td>
                                            <td>
                                                <input type="text" id="MonVolStd" class="unable" data-mini="true" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>*标称容量(AH)</td>
                                            <td>
                                                <fieldset data-role="controlgroup" >
                                                    <select id="MonCapStd" data-mini="true">
                                                     
                                                    </select>
                                                </fieldset>
                                            </td>
                                        </tr>
                                        
                                                <input type="hidden" id="MonResStd" data-mini="true" />    
                                                <input type="hidden" id="MonSerStd" data-mini="true" />
                                                <input type="hidden" id="MonVolLowToAvg" data-mini="true" />
                                        
                                        <tr>
                                            <td>*负载电流(A)</td>
                                            <td>
                                                <input type="text" id="Load_curr" data-mini="true" />
                                            </td>
                                        </tr>
                                        
                                                <input type="hidden" id="DisCurrMax" data-mini="true" />
                                            
                                        
                                        <tr>
                                            <td>基站电话号码</td>
                                            <td>
                                                <input type="text" id="station_phone" data-mini="true" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>电池品牌</td>
                                            <td>
                                                <input type="text" id="BattProducer" data-mini="true" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>*电池型号</td>
                                            <td>
                                                <input type="text" id="BattModel" data-mini="true" />
                                            </td>
                                        </tr>
                                        
                                                <input id="startTestrecord"  type="hidden" name="appDate" class="appDatefir"  value="2000-01-01" />
                                            
                                                <input id="endTestrecord" type="hidden" name="appDate" class="appDatesec"  value="2017-01-01" />
                                            
                                        <tr>
                                            <td>*安装人员</td>
                                            <td>
                                                <input type="text" id="install_user" data-mini="true" />
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            <!-- </div> -->
                                <div id="battdata">
                                     <!-- <div>
                                    <h1 class="hbg">电池组1</h1>
                                      <table class="layout-set">   
                                        <tbody>
                                            <tr>
                                                <td>设备索引</td>
                                                <td>
                                                     <fieldset data-role="controlgroup" data-type="horizontal">  
                                                            <select>
                                                              <option value="">0</option>
                                                              <option value="mon">1</option>
                                                              <option value="mon">2</option>
                                                              <option value="mon">3</option>
                                                              
                                                            </select>
                                                      </fieldset>      
                                                </td>    
                                            </tr>
                                            <tr>
                                                 <td>电池组名称</td>
                                                 <td><input type="text" id="" data-mini="true" /></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                   </div>      -->
                                </div> 
                              
            
        </div>
        
        <div data-role="footer" data-position="fixed" data-theme="a">    
            <div data-role="navbar">
                <ul>
                  <li><a href="#yourPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all operat-but ui-btn-icon-check" data-position-to="window" data-icon="check" data-role="button">确定</a></li>
                  <li><a href="" id="cancel" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all operat-but ui-btn-icon-delete" data-position-to="window" data-icon="delete" data-role="button">取消</a></li>
                </ul>
            </div>        
        </div>   
        <div data-role="popup" id="yourPopup" class="ui-content" data-overlay-theme="b">
        <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right">关闭</a>
        <a href="" data-rel="back" id="sure" class="ui-btn ui-corner-all ui-shadow  ui-btn-icon-left ui-icon-check" >提交</a>
        <a href="" data-rel="back" class="ui-btn ui-corner-all ui-shadow  ui-btn-icon-left ui-icon-delete" >放弃</a>
    </div>        
    </div>
</body>
 
 
<script type="text/javascript">    
function creatAllView(num){
        var allString=''
           ,i=0;
       if(num>4){return false}
       for(i=0;i<num;i++){
         allString+=creatBattView(i);
       }
     return $("#battdata").html(allString);   
  } 
    
    
  function creatBattView(index){
         var count=index+1
            ,battTitle='<div>'+'<h1 class="hbg">'+'电池组'+count+'</h1>'+
             '<table class="layout-set">'+'<tbody>'+'<tr>'+'<td>'+'电池品牌'+'</td>'+'<td>'+'<fieldset data-role="controlgroup" data-type="horizontal">'+'<select>'
            ,battBrand=selectedIndex(index)+'</select>'+'</fieldset>'+'</td>'+'</tr>' 
            ,battType='<tr>'+'<td>'+'电池型号'+'</td>'+'<td>'+'<input type="text" '+'id='+'batttype'+index+' data-mini="true"'+'value='+'电池型号'+count+' />'+'</td>'+'</tr>' 
            ,battNum='<tr>'+'<td>'+'电池数量'+'</td>'+'<td>'+'<input type="text" '+'id='+'battnum'+index+' data-mini="true"'+'value='+'电池数量'+count+' />'+'</td>'+'</tr>' 
            ,nomCap='<tr>'+'<td>'+'标称容量'+'</td>'+'<td>'+'<input type="text" '+'id='+'nomCap'+index+' data-mini="true"'+'value='+'标称容量'+count+' />'+'</td>'+'</tr>' 
            ,battIndex='<tr>'+'<input type="hidden" '+'id='+'battindex'+index+' data-mini="true"'+'value='+count+' />'+'</tr>' 
            ,battName='<tr>'+'<input type="hidden" '+'id='+'battname'+index+' data-mini="true"'+'value='+'电池组'+count+' />'+'</tr>'+'</tbody>'+'</table>'+'</div>';
        return battTitle+battBrand+battType+battNum+nomCap+battIndex+battName; 
               
  }    
 
  function selectedIndex(index){
       var selected='',
           i=0;
       for(i=0;i<4;i++){  
          if(i==index){selected+='<option '+'value='+i+' selected'+'>'+'电池品牌'+i+'</option>';continue;}
          selected+='<option value='+i+'>'+'电池品牌'+i+'</option>';
          
       }
       
       return selected; 
  }    
      var temp = getCookie("eleparm");
    //console.info(temp);
    temp=JSON.parse(temp);
    console.info(temp);
    console.info(temp[30]);
    console.info(temp[33]);
    console.info(temp[34]);
    var suoyin = temp[33];
    
   $(function(){creatAllView(suoyin).trigger('create')});
 
    
   //页面加载时查询省
    $.post("BattInfAction_serchByStation",null,function(data){
        data = data.result;
        data = eval("("+data+")");
        if(data.code==1&&data.data.length>0){
               var $Ostation_name1=$("#mainteArea");
            $Ostation_name1.text("");
            var arr = new Array();
            for(var i=0;i<=data.data.length;i++)
            {
                   if(i == 0){
                       arr.push({
                           val:"",
                           txt:"全部(共"+data.sum+"个)", 
                       });
                   }else{
                       arr.push({
                           val:data.data[i-1].StationName1,
                           txt:data.data[i-1].StationName1,
                       });
                   }
            }
            updataSel($Ostation_name1, arr);
        }
         findCity();
    });
 
  
//当省改变时更新市
    function findCity(){
        var data = {
            StationName1: $("#mainteArea").val()
        };
            $.ajax({     
            type: "post",                 
            url: "BattInfAction!serchStationName2",                
            async:true,                
            dataType:'json',
            data:"json = "+JSON.stringify(data),    
            success: function(data){
            data = data.result;
            data = eval("("+data+")");
            //console.info(data);
            //console.info(data.code);       
            if(data.code==1&&data.data.length>0){
                   var $Ostation_name1=$("#city");
                $Ostation_name1.text("");
                var arr = new Array();
                for(var i=0;i<=data.data.length;i++)
                {
                       if(i == 0){
                           arr.push({
                               val:"",
                               txt:"全部(共"+data.data.length+"个)",
                           });
                       }else{
                           arr.push({
                               val:data.data[i-1].StationName2,
                               txt:data.data[i-1].StationName2,
                           });
                       }
                }
                updataSel($Ostation_name1, arr);
            }
             findCounty();
        }
        });
    }
    
//当市改变时更新区/县
    function findCounty(){
        var data = {
            StationName1: $("#mainteArea").val(),
            StationName2:$("#city").val(),
        };
        //console.info(data);
        $.ajax({     
            type: "post",                 
            url: "BattInfAction!serchStationName5",                
            async:true,                
            dataType:'json',
            data:"json = "+JSON.stringify(data),    
            success: function(data){
            data = data.result;
            data = eval("("+data+")");
            //console.info(data);
            //console.info(data.code);       
            if(data.code==1&&data.data.length>0){
                   var $Ostation_name1=$("#country");
                $Ostation_name1.text("");
                var arr = new Array();
                for(var i=0;i<=data.data.length;i++)
                {
                       if(i == 0){
                           arr.push({
                               val:"",
                               txt:"全部(共"+data.data.length+"个)",
                           });
                       }else{
                           arr.push({
                               val:data.data[i-1].StationName5,
                               txt:data.data[i-1].StationName5,
                           });
                       }
                }
                updataSel($Ostation_name1, arr);
            }
          findStationNamebyStationname1();   
        }
        });
    }
  
 //当区县更新时更新机房  
    function findStationNamebyStationname1(){
        var data = {
            StationName1: $("#mainteArea").val(),
            StationName2:$("#city").val(),
            StationName5:$("#country").val()
        };
        //console.info(data);
        $.ajax({     
            type: "post",                 
            url: "BattInfAction!serchStationName3",                
            async:true,                
            dataType:'json',
            data:"json = "+JSON.stringify(data),    
            success: function(data){
            data = data.result;
            data = eval("("+data+")");
            //console.info(data);
            //console.info(data.code);       
            if(data.code==1&&data.data.length>0){
                   var $Ostation_name1=$("#homeName");
                $Ostation_name1.text("");
                var arr = new Array();
                for(var i=0;i<=data.data.length;i++)
                {
                       if(i == 0){
                           arr.push({
                               val:"",
                               stationid:"",
                               txt:"全部(共"+data.data.length+"个)",
                           });
                       }else{
                           arr.push({
                               val:data.data[i-1].StationName3,
                               stationid:data.data[i-1].StationId,
                               txt:data.data[i-1].StationName3,
                           });
                       }
                }
                //console.info(111111111111111);
                updataSelStation($Ostation_name1, arr);
            }
           
           
        }
        });
    }
 
 
    
   //当省改变时更新市
   $('#mainteArea').change(function(){
           findCity();    
   });
   //当市改变时改变区/县
   $('#city').change(function(){
           findCounty();    
   });
   //当区/县改变时改变机房
   $('#country').change(function(){
           findStationNamebyStationname1();     
   });       
    
    //构造查询条件
        function createSearchParam(){
            var temp = {                            
                page:Page,
                binf:{
                    StationName1:$('#mainteArea').val(),
                    StationName2:$('#city').val(),
                    StationName5: $('#country').val(),
                    StationName:$('#homeName').val(),
                },
            };
            console.info(temp);
            return temp;
            
        }     
   
 
 
 
 
    $(function () {
        //setTimes($("#startTestrecord"),'2000-01-01');
        //setTimes($("#endTestrecord"),new Date().format('yyyy-MM-dd'));
        console.info()
        if(temp[34]!="edit")
        {
        //console.warn("sssss")
            creatgroupid();//如果检测为NEW ,则执行添加ID,如果为修改,则执行为拿到ID
        }else{
        }
        installstartdata(temp);
    });
    
    function creatgroupid(){
        var dev_id ='';
        $.ajax({
                type: 'post'
                ,async: true
                ,url: 'BattInfAction!searchmaxdev_id'
                ,data: null
                ,dataType: 'json'
                ,success:function(res) {
                    console.info(res);
                    var data = JSON.parse(res.result);
                    console.info(data);
                    if(data.length!=0){
                        data = data.data;
                        dev_id = data;
                        //console.info(dev_id);
                        document.getElementById("FBSDeviceId").value = dev_id;
                        var ip = getDevIp(dev_id);
                        //console.info(ip);
                        document.getElementById("FbsDeviceIp").value = ip;
                    }else{
                        alert("groupid生成失败");
                    }
                }   
        
        });    
    }
    // 根据设备id计算设备ip
    function getDevIp(dev_id) {
        var ptn = /^91([0-9]{7})$/;
        var ip = '';
        console.info(dev_id);
        if(ptn.test(dev_id)) {
            var value = Number(RegExp.$1);
            // console.log(value);
            var intNum = prefixInteger(Math.floor(value/256), 3);
            var resNum = prefixInteger(value%256, 3);
            ip = '127.000.'+intNum+'.'+resNum;
        }else {
            ip = '设备ID格式不正确';
        }
        console.info(ip);
        return ip;
    }
    // 设置浮充电压阀值/设置离线电压阀值   //
      function setFloatAndoutLine() {
          var vol = $('#MonVolStd').val();
          var monnum = $('#MonCount').val();
          var chargeVol = (vol*1.117*monnum).toFixed(1);        // 浮充电压阀值
        var outlineVol = (vol*1.073*monnum).toFixed(1);        // 离线电压阀值
    
        $('#BattFloatCurrent').val(chargeVol);        // 浮充电压阀值
        $('#OfflineVolLevel').val(outlineVol);    // 离线电压阀值
     }
     
     $('#MonVolStd').change(function(){
         setFloatAndoutLine();
     });
      $('#MonCount').change(function(){
          setFloatAndoutLine();
      })
    function prefixInteger(num, length) {
         return (num/Math.pow(3,length)).toFixed(length).substr(2);
    }
    
    //导入表格默认数据
    function installstartdata(temp){
        
        var data = {
                StationId: '4011100'
                ,StationName1: '广西省'
                ,StationName2: '白色市'
                ,StationName5: '乐业县'
                ,homeName: 'GX百色乐业县立新小区WF'
                ,StationName4: 'BTS设备'
                ,StationIp: '192.168.0.1'
                ,FBSDeviceId: '960000111'
                ,FbsDeviceIp: '127.0.0.1'
                ,FbsDeviceIp_YM: '255.255.255.0'
                ,FbsDeviceIp_WG: '127.0.0.1'
                ,FBSDeviceName: 'BTS'
                ,GroupIndexInFBSDevice: 1 
                ,BattGroupId: 1000005
                ,BattGroupNum: 2
                ,BattGroupName: '电池组1'
                ,FloatVolLevel: 54
                ,OfflineVolLevel: 42.9 
                ,BattFloatCurrent: 10
                ,MonCount: 24
                ,MonCapStd: 300
                ,MonVolStd: 2
                ,MonResStd: 0.2
                ,MonSerStd: 5000
                ,MonVolLowToAvg: 0.05 
                ,Load_curr: 15
                ,DisCurrMax: '0'
                ,station_phone: 12345678912
                ,BattProducer: '升阳'
                ,BattModel: ''
                ,productDate: '2018-09-18 00:00:00'
                ,useDate: '2018-09-18 00:00:00'
                ,install_user: '呵呵'
            };
            console.info(data.StationId);
        if(temp[34]!="edit"){
            creatgroupid();
            document.getElementById("StationId").value = data.StationId;
    //        document.getElementById("mainteArea").value = data.StationName1;
    //        document.getElementById("city").value = data.StationName2;            //市
    //        document.getElementById("county").value = data.StationName5;            //区县
    //        document.getElementById("homeName").value = data.homeName;   //机房名称
            document.getElementById("StationName4").value = data.StationName4;    //设备名称
            document.getElementById("StationIp").value = data.StationIp;        //设备IP
            //document.getElementById("FBSDeviceId").value = dev_id;    
            document.getElementById("FbsDeviceIp").value = data.FbsDeviceIp;
            document.getElementById("FbsDeviceIp_YM").value = data.FbsDeviceIp_YM;
            document.getElementById("FbsDeviceIp_WG").value = data.FbsDeviceIp_WG;
            document.getElementById("FBSDeviceName").value = data.FBSDeviceName;
            //document.getElementById("GroupIndexInFBSDevice").value = temp[12];
            document.getElementById("BattGroupId").value = data.BattGroupId;
            document.getElementById("BattGroupNum").value = data.BattGroupNum;
            //document.getElementById("BattGroupName").value = temp[15];
    //        document.getElementById("FloatVolLevel").value = data.FloatVolLevel;
    //        document.getElementById("OfflineVolLevel").value = data.OfflineVolLevel;
    //        document.getElementById("BattFloatCurrent").value = data.BattFloatCurrent;
    //        document.getElementById("MonCount").value = data.MonCount;
    //        document.getElementById("MonCapStd").value = data.MonCapStd;
    //        document.getElementById("MonVolStd").value = data.MonVolStd;
            document.getElementById("MonResStd").value = data.MonResStd;
            document.getElementById("MonSerStd").value = data.MonSerStd;
            document.getElementById("MonVolLowToAvg").value = data.MonVolLowToAvg;
    //        document.getElementById("Load_curr").value = data.Load_curr;
            document.getElementById("DisCurrMax").value = data.DisCurrMax;
    //        document.getElementById("station_phone").value = data.station_phone;
    //        document.getElementById("BattProducer").value = data.BattProducer;
            document.getElementById("BattModel").value = data.BattModel;
            //document.getElementById("startTestrecord").value = temp[30];
            //document.getElementById("endTestrecord").value = temp[31];
            setTimes($("#startTestrecord"),data.productDate);
            setTimes($("#endTestrecord"),data.useDate);
    //        document.getElementById("install_user").value = data.install_user;            
        }else{
            document.getElementById("StationId").value = temp[0];
            document.getElementById("mainteArea").value = temp[1];
            document.getElementById("city").value = temp[2];            //市
            document.getElementById("county").value = temp[3];            //区县
            document.getElementById("homeName").value = temp[4];   //机房名称
            document.getElementById("StationName4").value = temp[5];    //设备名称
            document.getElementById("StationIp").value = temp[6];        //设备IP
            document.getElementById("FBSDeviceId").value = temp[7];    
            document.getElementById("FbsDeviceIp").value = temp[8];
            document.getElementById("FbsDeviceIp_YM").value = temp[9];
            document.getElementById("FbsDeviceIp_WG").value = temp[10];
            document.getElementById("FBSDeviceName").value = temp[11];
            //document.getElementById("GroupIndexInFBSDevice").value = temp[12];
            document.getElementById("BattGroupId").value = temp[13];
            document.getElementById("BattGroupNum").value = suoyin;
            //document.getElementById("BattGroupName").value = temp[15];
            document.getElementById("FloatVolLevel").value = temp[16];
            document.getElementById("OfflineVolLevel").value = temp[17];
            document.getElementById("BattFloatCurrent").value = temp[18];
            document.getElementById("MonCount").value = temp[19];
            document.getElementById("MonCapStd").value = temp[20];
            document.getElementById("MonVolStd").value = temp[21];
            document.getElementById("MonResStd").value = temp[22];
            document.getElementById("MonSerStd").value = temp[23];
            document.getElementById("MonVolLowToAvg").value = temp[24];
            document.getElementById("Load_curr").value = temp[25];
            document.getElementById("DisCurrMax").value = temp[26];
            document.getElementById("station_phone").value = temp[27];
            document.getElementById("BattProducer").value = temp[28];
            document.getElementById("BattModel").value = temp[29];
            //document.getElementById("startTestrecord").value = temp[30];
            //document.getElementById("endTestrecord").value = temp[31];
            setTimes($("#startTestrecord"),temp[30]);
            setTimes($("#endTestrecord"),temp[31]);
            document.getElementById("install_user").value = temp[32];
        }
        setFloatAndoutLine();
    }
    
    // 格式化提交后台信息的对象数组并返回 单个修改,手机方式不修改多个电池组
        function getUpdateArr(){
            var arr = new Array();
            for(var i=0;i<suoyin;i++){
                var battString = "#battname"+i;
                var index = String(i);
                console.info(battString);
                var obj = {
                    apply_date : new Date().format("yyyy-MM-dd hh:mm:ss"),
                    binf:{
                        StationId : $("#StationId").val(),    // 机房编号
                        StationName : ($("#mainteArea").val()+"-"+$("#city").val()+"-"+$("#homeName").val()+"-"+$("#StationName4").val()),    // 拼接机房名称
                        StationName1 : $("#mainteArea").val(),        // 省
                        StationName2 : $("#city").val(),        // 市
                        StationName5 : $("#county").val(),        // 区/县
                        homeName : $("#homeName").val(),        // 机房名称
                        StationName4 : $("#StationName4").val(),        // 设备名称
                        StationIp : $("#StationIp").val(),                //机房ip
                        FBSDeviceId : $("#FBSDeviceId").val(),                //设备id
                        FbsDeviceIp : $("#FbsDeviceIp").val(),                //设备ip
                        FbsDeviceIp_YM : $("#FbsDeviceIp_YM").val(),            // 设备掩码
                        FbsDeviceIp_WG : $("#FbsDeviceIp_WG").val(),            // 网关
                        FBSDeviceName : $("#FBSDeviceName").val(),            //设备名称
                        GroupIndexInFBSDevice : i,    //fbs设备索引
                        BattGroupId : $("#BattGroupId").val(),                //电池组id
                        BattGroupNum : $("#BattGroupNum").val(),            //机房内电池组编号
                        BattGroupName : $(battString).val(),
                        FloatVolLevel : $("#FloatVolLevel").val(),            //浮充电压阀值
                        OfflineVolLevel : $("#OfflineVolLevel").val(),            //离线电压阀值
                        BattFloatCurrent : $("#BattFloatCurrent").val(),        //浮充电流阀值
                        MonCount : $("#MonCount").val(),                //单体数量
                        MonCapStd : $("#MonCapStd").val(),                //标称容量
                        MonVolStd : $("#MonVolStd").val(),                //标称电压
                        MonResStd : $("#MonResStd").val(),                //标称内阻
                        MonSerStd : $("#MonSerStd").val(),                //标称电导
                        MonVolLowToAvg : $("#MonVolLowToAvg").val(),            //单体电压次低偏移量
                
                        Load_curr : $("#Load_curr").val(),                //负载电流
                        DisCurrMax : $("#DisCurrMax").val(),                //最大核容电流
                        station_phone : $("#station_phone").val(),            //基站号码
                                        
                        BattProducer : $("#BattProducer").val(),            //电池品牌
                        BattModel : $("#BattModel").val(),                //电池型号
                        BattProductDate :  $("#startTestrecord").val()+" 00:00:00",        //电池生产日期
                        BattInUseDate :  $("#endTestrecord").val()+" 00:00:00",            //电池使用日期
                        install_user : $("#install_user").val(),            //安装人员
                    }
                }
                arr.push(obj);
            }
            console.info(arr);
            return arr;
        }
        
        function getUpdateArredit(){
            var arr = new Array();
            for(var i=0;i<suoyin;i++){
                var battString = "#battname"+i;
                var index = String(i);
                console.info(battString);
                var obj = {
                        StationId : $("#StationId").val(),    // 机房编号
                        StationName : ($("#mainteArea").val()+"-"+$("#city").val()+"-"+$("#homeName").val()+"-"+$("#StationName4").val()),    // 拼接机房名称
                        StationName1 : $("#mainteArea").val(),        // 省
                        StationName2 : $("#city").val(),        // 市
                        StationName5 : $("#county").val(),        // 区/县
                        homeName : $("#homeName").val(),        // 机房名称
                        StationName4 : $("#StationName4").val(),        // 设备名称
                        StationIp : $("#StationIp").val(),                //机房ip
                        FBSDeviceId : $("#FBSDeviceId").val(),                //设备id
                        FbsDeviceIp : $("#FbsDeviceIp").val(),                //设备ip
                        FbsDeviceIp_YM : $("#FbsDeviceIp_YM").val(),            // 设备掩码
                        FbsDeviceIp_WG : $("#FbsDeviceIp_WG").val(),            // 网关
                        FBSDeviceName : $("#FBSDeviceName").val(),            //设备名称
                        GroupIndexInFBSDevice : i,    //fbs设备索引
                        BattGroupId : $("#BattGroupId").val(),                //电池组id
                        BattGroupNum : $("#BattGroupNum").val(),            //机房内电池组编号
                        BattGroupName : $(battString).val(),
                        FloatVolLevel : $("#FloatVolLevel").val(),            //浮充电压阀值
                        OfflineVolLevel : $("#OfflineVolLevel").val(),            //离线电压阀值
                        BattFloatCurrent : $("#BattFloatCurrent").val(),        //浮充电流阀值
                        MonCount : $("#MonCount").val(),                //单体数量
                        MonCapStd : $("#MonCapStd").val(),                //标称容量
                        MonVolStd : $("#MonVolStd").val(),                //标称电压
                        MonResStd : $("#MonResStd").val(),                //标称内阻
                        MonSerStd : $("#MonSerStd").val(),                //标称电导
                        MonVolLowToAvg : $("#MonVolLowToAvg").val(),            //单体电压次低偏移量
                
                        Load_curr : $("#Load_curr").val(),                //负载电流
                        DisCurrMax : $("#DisCurrMax").val(),                //最大核容电流
                        station_phone : $("#station_phone").val(),            //基站号码
                                        
                        BattProducer : $("#BattProducer").val(),            //电池品牌
                        BattModel : $("#BattModel").val(),                //电池型号
                        BattProductDate :  $("#startTestrecord").val()+" 00:00:00",        //电池生产日期
                        BattInUseDate :  $("#endTestrecord").val()+" 00:00:00",            //电池使用日期
                        install_user : $("#install_user").val(),            //安装人员
                }
                arr.push(obj);
            }
            console.info(arr);
            return arr;
        }
</script> 
<script type="text/javascript">  
    $(function(){
        $(".unable").prop("readonly","readonly").attr("unselectable","on").addClass("uncheck");
        $("#sure").click(function(){
            if(nullOrn()){
                if(temp[34]!="edit"){
                    creatgroupid();//提交之前再次验证,创建ID
                    addBattnew();     //提交
                }else{
                    addBattnew();
                }    
            }else{
            }                //验证重要项是否为空,为空则提示;   
               //function backpage(){window.location.href="ele-param1.html";}
             // setTimeout(backpage,500); 
        });
        $("#cancel").click(function(){
            window.location.href="ele-param2.html";
        });
    });
     
     function nullOrn(){
         if($("#BattFloatCurrent").val()&&$("#MonCount").val()&&$("#MonCapStd").val()){
             return true;
         }else{
             alert("*项为必填项,不能为空,请重新输入");
             return false;
         }    
     
     }
     
     function addBattnew(){//新建电池组,添加到申请
         var temp = JSON.stringify(getUpdateArr());
         console.info(temp);
         $.ajax({
             type: 'post',
            async: true,
            url: 'Battinf_applyAction!add',
            data: "json="+temp,
            dataType: 'json',
            success:function(data) {
                data = JSON.parse(data.result);
                 console.info(data);
                 if(data.code==1){
                     alert("添加成功");
                     window.location.href="batt-unapproved.html";
                 }else{
                     alert("添加失败");
                     window.location.href="batt-unapproved.html";
                 }
             }
         });
     }
    
      //修改电池组,添加到BATTINF
    function editBatt(){
           var parm = getUpdateArredit();
           console.info(parm);    
           $.ajax({
                type: "post",                 
                url: "BattInfAction!update",                
                async:true,                
                dataType:'text',
                data:"json="+JSON.stringify(parm),    
                success: function(data){                                        
                    data = eval('('+data+')');
                    var model = eval('('+data.result+')');
                    console.info(model);
                    if(model.code ==1){
                        alert("修改成功");
                    }else{
                        alert("修改失败!");
                    }        
                },
                error:function(){
                    alert("修改电池组失败!");
                }
         });
   }   
   
   
   $('input:radio[name="battnum"]').click(function(){
         var $this=$(this)
             , $mon=$('#MonVolStd') ;
        if ($this.attr("checked")) { 
        if($this.val()==4){
               $mon.val("12");
              
           };
         if($this.val()==24){$mon.val("2");}  
    }
   });
   
   function creatMonCapOpt(){
       var k,optionStr='';
     for(var i=1;i<11;i++){
          k=i*50;
          optionStr+='<option'+' value='+k+'>'+k+'</option>'; 
     }
   $("#MonCapStd").html(optionStr);
   }
   creatMonCapOpt();
    /* 操作成功 
   $('#changeSuc').popup('open');
       操作失败
   $('#changeErr').popup('open'); */
   </script>
</html>