hdw
2019-01-16 cdd5fe1813e63adcddd61581cb886b9d154e5a3c
gx_tieta/WebRoot/mobil/batt-infor-conf-temp1.html
@@ -7,63 +7,13 @@
   <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 href="mobilCss/mobiscroll.core-2.5.2.css" rel="stylesheet" type="text/css" />
   <link href="mobilCss/mobiscroll.animation-2.5.2.css" rel="stylesheet" type="text/css" />
   <link rel="stylesheet" type="text/css" href="css/tbl.css">
   <script type="text/javascript" src="mobilJs/jquery-1.8.2.js"></script>
   <script src="mobilJs/mobiscroll.core-2.5.2.js" type="text/javascript"></script>
   <script src="mobilJs/mobiscroll.core-2.5.2-zh.js" type="text/javascript"></script>
   <script src="mobilJs/mobiscroll.datetime-2.5.1.js" type="text/javascript"></script>
   <script src="mobilJs/mobiscroll.datetime-2.5.1-zh.js" type="text/javascript"></script>
   <script type="text/javascript" src="js/tbl.js"></script>
   <script type="text/javascript" src="mobilJs/base.js"></script>
   <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);
       }
      $("#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>'
            ,allOption=selectedIndex(index)+'</select>'+'</fieldset>'+'</td>'+'</tr>'
            ,battName='<tr>'+'<td>'+'电池组名称'+'</td>'+'<td>'+'<input type="text" '+'id='+'battname'+index+' data-mini="true"'+'value='+'电池组'+count+' />'+'</td>'+'</tr>'+'</tbody>'+'</table>'+'</div>';
        return battTitle+allOption+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]);
   var suoyin = temp[33];
   $(function(){creatAllView(suoyin)});
   </script>
   <script type="text/javascript" src="mobilJs/jquery.mobile-1.4.5.min.js"></script>
   <style type="text/css">     
       input{-webkit-appearance: none;}
      table {
         margin-top:.5em;
         border-collapse:separate; 
@@ -83,14 +33,15 @@
            padding-right: 8.5em;
        }
        .hbg{
            background-color:#ddd9;
            background-color:#ddd;
        }
        #battdata {
            background-color:#dddddd54
            background-color:#eee;
        }
        .ui-select .ui-btn select{
            width:77%;
        }
        table tr td{width:1000em;padding-right:1em;}
   </style>
   <link rel="stylesheet" href="css/fgpanel.css">
</head>
@@ -99,7 +50,7 @@
      
      <!-- 头部内容 -->
      <div data-role="header" data-position="fixed">
         <a href="ele-param1.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>
         <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>
@@ -108,189 +59,137 @@
         <!-- <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>
                                    <input type="text" id="station_name1" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>城市</td>
                                 <td>
                                    <input type="text" id="city" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>区县</td>
                                 <td>
                                    <input type="text" id="county" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>机房名称</td>
                                 <td>
                                    <input type="text" id="StationName3" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>设备名称</td>
                                 <td>
                                    <input type="text" id="StationName4" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>机房IP</td>
                                 <td>
                                    <input type="text" id="StationIp" data-mini="true" />
                                 </td>
                              </tr>
                              <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>
                              <tr>
                                 <td>子网掩码</td>
                                 <td>
                                    <input type="text" id="FbsDeviceIp_YM" class="unable" data-mini="true" value="456"/>
                                 </td>
                              </tr>
                              <tr>
                                 <td>网关</td>
                                 <td>
                                    <input type="text" id="FbsDeviceIp_WG" class="unable"  data-mini="true" value="456"/>
                                 </td>
                              </tr>
                              <tr>
                                 <td>FBS设备名称</td>
                                 <td>
                                    <input type="text" id="FBSDeviceName" data-mini="true" />
                                 </td>
                              </tr>
                                    <input type="hidden" type="text" id="StationId" class="unable" data-mini="true" onfocus="this.blur()"/>
                                    <input type="hidden" type="text" id="FBSDeviceId" class="unable" data-mini="true" />
                           
                                    <input type="hidden" type="text" id="FbsDeviceIp" class="unable" data-mini="true" />
                                    <input type="hidden" type="text" readonly unselectable="on" value="123"class="unable" id="BattGroupId" class="uncheck" data-mini="true" />
                              <tr>
                                 <td>电池组ID</td>
                                 <td>*省</td>
                                 <td>
                                    <input type="text" readonly unselectable="on" value="123"class="unable" id="BattGroupId" class="uncheck" data-mini="true" />
                                    <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>*城市</td>
                                 <td>
                                    <input type="text" readonly unselectable="on" value="123" id="BattGroupNum" class="unable" class="uncheck" data-mini="true" />
                                    <select id="city" data-mini="true">
                                          <option value="">全部</option>
                                       </select>
                                 </td>
                              </tr>
                              <tr>
                                 <td>浮充电压阀值(V)</td>
                                 <td>*区县</td>
                                 <td>
                                    <input type="text" id="FloatVolLevel" data-mini="true" />
                                     <select  id="county" data-mini="true">
                                          <option value="">全部</option>
                                       </select>
                                 </td>
                              </tr>
                              <tr>
                                 <td>离线电压阀值(V)</td>
                                 <td>*机房名称</td>
                                 <td>
                                    <input type="text" id="OfflineVolLevel" class="unable" data-mini="true" />
                                    <textarea id="homeName"  data-mini="true"></textarea>
                                 </td>
                              </tr>
                              <tr>
                                 <td>浮充电流阀值(A)</td>
                                 <td>
                                    <input type="text" id="BattFloatCurrent" class="unable" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>单体数量</td>
                                    <input type="hidden" id="StationName4" data-mini="true" />
                                    <input type="hidden" id="StationIp" data-mini="true" />
                                    <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" />
                                    <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>标称容量(AH)</td>
                                 <td>*标称单体电压(V)</td>
                                 <td>
                                    <input type="text" id="MonCapStd" data-mini="true" />
                                    <input type="text" id="MonVolStd" class="unable" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>标称单体电压(V)</td>
                                 <td>*标称容量(AH)</td>
                                 <td>
                                    <input type="text" id="MonVolStd" data-mini="true" />
                                     <fieldset data-role="controlgroup" >
                                          <select id="MonCapStd" data-mini="true">
                                          </select>
                                      </fieldset>
                                 </td>
                              </tr>
                              </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" />
                                    <input type="hidden" id="fuchongfazhi0" data-mini="true" />
                                    <input type="hidden" id="fuchongfazhi1" data-mini="true" />
                                    <input type="hidden" id="lixiandianyafazhi0" data-mini="true" />
                                    <input type="hidden" id="lixiandianyafazhi1" data-mini="true" />
                              <tr>
                                 <td>标称单体内阻(mΩ)</td>
                                 <td>
                                    <input type="text" id="MonResStd" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>标称单体电导</td>
                                 <td>
                                    <input type="text" id="MonSerStd" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>单体电压次低偏移量(V)</td>
                                 <td>
                                    <input type="text" id="MonVolLowToAvg" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>负载电流(A)</td>
                                 <td>*负载电流(A)</td>
                                 <td>
                                    <input type="text" id="Load_curr" data-mini="true" />
                                 </td>
                              </tr>
                                    <input type="hidden" id="DisCurrMax" data-mini="true" />
                                    <input type="hidden" id="judgeBatt" data-mini="true" />
                              <tr>
                                 <td>最大核容电流(A)</td>
                                 <td>
                                    <input type="text" id="DisCurrMax" data-mini="true" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>基站号码</td>
                                 <td>*基站电话号码</td>
                                 <td>
                                    <input type="text" id="station_phone" data-mini="true" />
                                 </td>
                              </tr>
                                 <input id="startTestrecord"  type="hidden" name="appDate" class="appDatefir"  value="2000-01-01 00:00:00" />
                                 <input id="endTestrecord" type="hidden" name="appDate" class="appDatesec"  value="2017-01-01 00:00:00" />
                              <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>
                              <tr>
                                 <td>电池生产日期</td>
                                 <td>
                                    <input id="startTestrecord"  type="text" name="appDate" class="appDatefir"  value="2000-01-01" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>投入使用日期   </td>
                                 <td>
                                    <input id="endTestrecord" type="text" name="appDate" class="appDatesec"  value="2017-01-01" />
                                 </td>
                              </tr>
                              <tr>
                                 <td>安装人员</td>
                                 <td>*安装人员</td>
                                 <td>
                                    <input type="text" id="install_user" data-mini="true" />
                                 </td>
@@ -299,31 +198,7 @@
                        </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> 
                       
         
@@ -347,10 +222,216 @@
<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 '+'id='+'battproducer'+index+'>'
            ,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>'+'<fieldset data-role="controlgroup"  data-type="horizontal">'+'<select '+ 'id='+'MonCount'+index+'>'
            ,battNumOpt=selectedNum(index)+'</select>'+'</fieldset>'+'</td>'+'</tr>'
            ,MonVolStd='<tr>'+'<td>'+'*标称单体电压(V)'+'</td>'+'<td>'+'<input type="text" '+'id='+'MonVolStd'+index+' data-mini="true"'+' class="unable" '+'/>'+'</td>'+'</tr>'
            ,nomCap='<tr>'+'<td>'+'*标称容量(AH)'+'</td>'+'<td>'+'<fieldset data-role="controlgroup" >'+'<select '+'id='+'MonCapStd'+index+' data-mini="true"'+'>'+creatMonCapOpt()+'</select>'
             +'</fieldset>'+'</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+battNumOpt+MonVolStd+nomCap+battIndex+battName;
  }
  function selectedNum(index){
      var selected='';
    return selected='<option '+'value='+4+' selected=selected' +'>'+'4 个'+'</option>'+'<option '+'value='+24 +'>'+'24个'+'</option>';
  }
 function selectedIndex(index){
   /*    var selected='',
           i=0;
          selected+= '<option '+'value='+'理士'+'>'+'理士'+'</option>';
          selected+= '<option '+'value='+'圣阳'+'>'+'圣阳'+'</option>';
          selected+= '<option '+'value='+'双登'+'>'+'双登'+'</option>';
          selected+= '<option '+'value='+'SENRY'+'>'+'SENRY'+'</option>';
          selected+= '<option '+'value='+'南都'+'>'+'南都'+'</option>';
          selected+= '<option '+'value='+'爱默生'+'>'+'爱默生'+'</option>';
          selected+= '<option '+'value='+'科士达'+'>'+'科士达'+'</option>';
          selected+= '<option '+'value='+'银泰'+'>'+' 银泰'+'</option>';
          selected+= '<option '+'value='+'丰日'+'>'+' 丰日'+'</option>';
          selected+= '<option '+'value='+'中兴能派'+'>'+' 中兴能派'+'</option>';
         selected+= '<option '+'value='+'光宇'+'>'+' 光宇'+'</option>';
         selected+= '<option '+'value='+'艾诺斯华达'+'>'+'艾诺斯华达'+'</option>';
         selected+= '<option '+'value='+'雄韬'+'>'+' 雄韬'+'</option>';
         selected+= '<option '+'value='+'风帆'+'>'+' 风帆'+'</option>';
         selected+= '<option '+'value='+'文隆'+'>'+' 文隆'+'</option>';
         selected+= '<option '+'value='+'风帆'+'>'+' 风帆'+'</option>';
         selected+= '<option '+'value='+'中山'+'>'+' 中山'+'</option>';
         selected+= '<option '+'value='+'美的'+'>'+' 美的'+'</option>';
         selected+= '<option '+'value='+'朗达'+'>'+' 朗达'+'</option>';
         selected+= '<option '+'value='+'烽火'+'>'+' 烽火'+'</option>';*/
      var battproducer = getCookie("producer");
      battproducer = JSON.parse(battproducer);
       var selected='',
           i=0;
       for(var i=1;i<battproducer.length;i++){
             console.info(battproducer[i]);
             selected+= '<option '+'value='+battproducer[i]+'>'+battproducer[i]+'</option>';
       }
       return selected;
  }
     var temp = getCookie("eleparm");
     var test=getCookie("eleparm2newbatt");
     //jifangname = JSON.parse(jifangname);
     console.info(test);
   //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];//电池组个数
   var Page = {
      pageSize:20,             //每页的行数
      pageCurr:1,              //当前页码数
      pageAll:0,
   };
   $(function(){
   creatAllView(suoyin).trigger('create');
   creatMonCapOpt(suoyin);
   });
   //页面加载时查询省
   $.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++)
           {
            arr.push({
                       val:data.data[i].StationName1,
                       txt:data.data[i].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++)
              {
                    arr.push({
                       val:data.data[i].StationName2,
                       txt:data.data[i].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=$("#county");
             $Ostation_name1.text("");
             var arr = new Array();
             for(var i=0;i<data.data.length;i++)
              {
                    arr.push({
                       val:data.data[i].StationName5,
                       txt:data.data[i].StationName5,
                    });
             }
             updataSel($Ostation_name1, arr);
           }
       }
       });
    }
   //当省改变时更新市
   $('#mainteArea').change(function(){
         findCity();
   });
   //当市改变时改变区/县
   $('#city').change(function(){
         findCounty();
   });
   //构造查询条件
   function createSearchParam(){
      var temp = {
         page:Page,
         binf:{
            StationName1:$('#mainteArea').val(),
            StationName2:$('#city').val(),
            StationName5: $('#county').val(),
            StationName:$('#homeName').val(),
         },
      };
      console.info(temp);
      return temp;
   }
   $(function () {
      //setTimes($("#startTestrecord"),'2000-01-01');
      //setTimes($("#endTestrecord"),new Date().format('yyyy-MM-dd'));
      creatgroupid();
      //creatgroupid();//如果检测为NEW ,则执行添加ID,如果为修改,则执行为拿到ID;
      installstartdata(temp);
   });
   
@@ -388,8 +469,10 @@
       console.info(dev_id);
       if(ptn.test(dev_id)) {
          var value = Number(RegExp.$1);
          // console.log(value);
          console.info(value);
          console.info(Math.floor(value/256));
          var intNum = prefixInteger(Math.floor(value/256), 3);
          console.info(intNum);
          var resNum = prefixInteger(value%256, 3);
          ip = '127.000.'+intNum+'.'+resNum;
       }else {
@@ -399,49 +482,53 @@
       return ip;
    }
    // 设置浮充电压阀值/设置离线电压阀值   //
     function setFloatAndoutLine() {
        var vol = $('#MonVolStd').val();
        var monnum = $('#MonCount').val();
     function setFloatAndoutLine(index) {
        var monvolstd = "#MonVolStd"+index;
        var MonCount = "#MonCount" +index;
        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);   // 离线电压阀值
      $("#fuchongfazhi"+index).val(chargeVol);       // 浮充电压阀值
      $("#lixiandianyafazhi"+index).val(outlineVol);   // 离线电压阀值
      console.info(vol);
    }
    
    $('#MonVolStd').change(function(){
 /*   $('#MonVolStd').change(function(){
       setFloatAndoutLine();
    });
     $('#MonCount').change(function(){
        setFloatAndoutLine();
     })
    function prefixInteger(num, length) {
     })*/
   /* function prefixInteger(num, length) {
       return (num/Math.pow(3,length)).toFixed(length).substr(2);
   }*/
   function prefixInteger(num, length) {
       return (Array(length).join('0') + num).slice(-length);
   }
   //导入表格默认数据
   function installstartdata(temp){
      creatgroupid();
   function installstartdata(temp){
      var data = {
                StationId: '4011100'
                ,StationName1: '广西省'
                ,StationName2: '白色市'
                ,StationName5: '乐业县'
                ,StationName3: 'GX百色乐业县立新小区WF'
                ,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: '设备名称'
                ,FBSDeviceName: 'BTS'
                ,GroupIndexInFBSDevice: 1 
                ,BattGroupId: 1000005
                ,BattGroupNum: 2
                ,BattGroupName: '电池组1'
                ,FloatVolLevel: 54
                ,OfflineVolLevel: 42.9 
                ,BattFloatCurrent: 10
                ,BattFloatCurrent: 5
                ,MonCount: 24
                ,MonCapStd: 300
                ,MonVolStd: 2
@@ -455,19 +542,20 @@
                ,BattModel: ''
                ,productDate: '2018-09-18 00:00:00'
                ,useDate: '2018-09-18 00:00:00'
                ,install_user: '呵呵'
                ,install_user: 'test'
            };
            console.info(data.StationId);
      if(temp.length>0){
            setMonVolStd(temp.length);
         creatgroupid();
         document.getElementById("StationId").value = data.StationId;
   //      document.getElementById("station_name1").value = data.StationName1;
   //      document.getElementById("mainteArea").value = data.StationName1;
   //      document.getElementById("city").value = data.StationName2;         //市
   //      document.getElementById("county").value = data.StationName5;         //区县
   //      document.getElementById("StationName3").value = data.StationName3;   //机房名称
   //      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").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;
@@ -475,81 +563,59 @@
         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("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("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("station_name1").value = temp[1];
         document.getElementById("city").value = temp[2];         //市
         document.getElementById("county").value = temp[3];         //区县
         document.getElementById("StationName3").value = temp[4];   //机房名称
         document.getElementById("StationName4").value = temp[5];    //设备名称
         document.getElementById("StationIp").value = temp[6];      //设备IP
         //document.getElementById("FBSDeviceId").value = dev_id;
         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();
         document.getElementById("station_phone").value = data.station_phone;
         //document.getElementById("BattProducer").value = data.BattProducer;
         //document.getElementById("BattModel").value = data.BattModel;
         document.getElementById("startTestrecord").value = data.productDate;
         document.getElementById("endTestrecord").value = data.useDate;
         //setTimes($("#startTestrecord"),data.productDate);
         //setTimes($("#endTestrecord"),data.useDate);
         document.getElementById("install_user").value = data.install_user;
         setFloatAndoutLine(1);
         //setFloatAndoutLine();
   }
   
   // 格式化提交后台信息的对象数组并返回 单个修改,手机方式不修改多个电池组
      function getUpdateArr(){
         mon=$('#MonVolStd').val();
         var moncount = 0;
         if(mon==12){
            moncount=4;
         }else if(mon==2){
            moncount==24;
         }
         var arr = new Array();
         for(var i=0;i<suoyin;i++){
            setFloatAndoutLine(i);
            var battString = "#battname"+i;
            var battModel = "#batttype"+i;
            //var battproducer ="#battproducer"+i;
            var id = $('fieldset div div input[data-cacheval=\'true\']').val();
            var inputVal = $(id).val();
            //var input =$(four).option()
            console.info(inputVal)
            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 : ($("#station_name1").val()+"-"+$("#city").val()+"-"+$("#StationName3").val()+"-"+$("#StationName4").val()),   // 拼接机房名称
                  StationName1 : $("#station_name1").val(),      // 省
                  StationName : ($("#mainteArea").val()+"-"+$("#city").val()+"-"+$("#homeName").val()+"-"+$("#StationName4").val()),   // 拼接机房名称
                  StationName1 : $("#mainteArea").val(),      // 省
                  StationName2 : $("#city").val(),      // 市
                  StationName5 : $("#county").val(),      // 区/县
                  StationName3 : $("#StationName3").val(),      // 机房名称
                  StationName3 : $("#homeName").val(),      // 机房名称
                  StationName4 : $("#StationName4").val(),      // 设备名称
                  StationIp : $("#StationIp").val(),            //机房ip
                  FBSDeviceId : $("#FBSDeviceId").val(),            //设备id
@@ -561,12 +627,12 @@
                  BattGroupId : $("#BattGroupId").val(),            //电池组id
                  BattGroupNum : $("#BattGroupNum").val(),         //机房内电池组编号
                  BattGroupName : $(battString).val(),
                  FloatVolLevel : $("#FloatVolLevel").val(),         //浮充电压阀值
                  OfflineVolLevel : $("#OfflineVolLevel").val(),         //离线电压阀值
                  FloatVolLevel : $("#fuchongfazhi"+i).val(),         //浮充电压阀值
                  OfflineVolLevel : $("#lixiandianyafazhi"+i).val(),         //离线电压阀值
                  BattFloatCurrent : $("#BattFloatCurrent").val(),      //浮充电流阀值
                  MonCount : $("#MonCount").val(),            //单体数量
                  MonCapStd : $("#MonCapStd").val(),            //标称容量
                  MonVolStd : $("#MonVolStd").val(),            //标称电压
                  MonCount :$("#MonCount"+i).val(),            //单体数量
                  MonCapStd : $("#MonCapStd"+i).val(),            //标称容量
                  MonVolStd : $("#MonVolStd"+i).val(),            //标称电压
                  MonResStd : $("#MonResStd").val(),            //标称内阻
                  MonSerStd : $("#MonSerStd").val(),            //标称电导
                  MonVolLowToAvg : $("#MonVolLowToAvg").val(),         //单体电压次低偏移量
@@ -575,10 +641,10 @@
                  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",         //电池使用日期
                  BattProducer : $("#battproducer"+i).find("option:selected").val(),         //电池品牌
                  BattModel : $(battModel).val(),            //电池型号
                  BattProductDate :  $("#startTestrecord").val(),      //电池生产日期
                  BattInUseDate :  $("#endTestrecord").val(),         //电池使用日期
                  install_user : $("#install_user").val(),         //安装人员
               }
            }
@@ -587,22 +653,63 @@
         console.info(arr);
         return arr;
      }
</script> 
<script type="text/javascript">  
   $(function(){
      $(".unable").prop("readonly","readonly").attr("unselectable","on").addClass("uncheck");
      $("#sure").click(function(){
         addBatt();
            //function backpage(){window.location.href="ele-param1.html";}
          // setTimeout(backpage,500);
       $(function(){
      // alert(333);
       })
      $("#sure").click(function(){
         if(nullOrn()){
            creatgroupid();//提交之前再次验证,创建ID
            JudegeBattIn();//提交前验证该电池组在BATTINF表中是否已存在
            //addBattnew();    //提交
         }else{
         }            //验证重要项是否为空,为空则提示;
      });
      $("#cancel").click(function(){
          window.location.href="ele-param1.html";
          window.location.href="ele-param2.html";
      });
   });
    
    function addBatt(){
    function nullOrn(){
       console.info($("#homeName").val());
       console.info($("#station_phone").val());
       if($("#homeName").val!=""&&$("#station_phone").val()!=""&&$("#install_user").val()!=""){
          return true;
       }else{
          alert("请填写*内容");
       }
    }
    function JudegeBattIn(){
       var battinff ={
         StationName: ($("#mainteArea").val()+"-"+$("#city").val()+"-"+$("#homeName").val()+"-"+$("#StationName4").val()),   // 拼接机房名称
       }
       console.info(battinff);
       $.ajax({
          type: 'post',
         async: true,
         url: '../BattInfAction!judgeBatt',
         data: "json="+JSON.stringify(battinff),
         dataType: 'json',
         success:function(data) {
            data = JSON.parse(data.result);
            console.info(data);
            if(data.code!=1){
               addBattnew()
            }else{
               alert("该机房已存在,请返回修改页面修改并重新提交");
               SearchParam();
            }
         }
      });
    }
    function addBattnew(){//新建电池组,添加到申请
       console.info(getUpdateArr());
       var temp = JSON.stringify(getUpdateArr());
       console.info(temp);
       $.ajax({
@@ -616,15 +723,176 @@
             console.info(data);
             if(data.code==1){
                alert("添加成功");
                window.location.href="batt-unapproved.html";
                window.location.href="batt-unapproved-index.html"
             }else{
                alert("添加失败");
                window.location.href="batt-unapproved.html";
                window.location.href="batt-unapproved-index.html";
             }
          }
       });
    }
   function SearchParam(){
         var temp = {
            page:Page,
            binf:{
               StationName1:$('#mainteArea').val(),
               StationName2:$('#city').val(),
               StationName5: $('#county').val(),
               StationName: ($("#mainteArea").val()+"-"+$("#city").val()+"-"+$("#homeName").val()+"-"+$("#StationName4").val()),   // 拼接机房名称
            },
         };
         console.info(temp);
         searchBattLife(temp);
      }
   // 查询内容
   function searchBattLife(temp){
      //var temp = createSearchParam();
      var json = JSON.stringify(temp);
      var num =new Array();
      var groupId = new Array();
      var groupName = new Array();
      var arrdata = new Array();
      console.info(json);
      arrTd = new Array();
      var load;
       $.ajax({
         type:"post",
         url:"BattInfAction!searchInform",
         async:true,
         datatype:'text',
         data:"json="+json,
         success:function(data){
            console.info(data);
            var data = JSON.parse(data.result);
            //layer.close(load);
            console.info(data);
            if(data.code==1&&data.data.length>0){
               data=data.data;
               var index = 0;
               var ArryTb= new Array();
               for(var i=0;i<data.length;i++){
                  arrdata.push(data[i]);//存储数据
               }
            seteditparm(0,arrdata);
            window.location.href="batt-edit2.html";
            }else{
               Page.pageAll = 0;
            }
            //createTbl(tblCon, arrTh, arrTd);
            //getEditButIndex(0);
         }
      });
   }
   function seteditparm(index,arrdata){
       if(arrdata.length>0){   //存入的为所有已查出数据
       console.info(arrdata);
            var arr= creatYanshouObj(arrdata,index);
            return arr;
         }else{
            alert("请等待几秒后再提交申请");
         }
    }
   function creatYanshouObj(arrdata,index){
    console.info(arrdata[0]);
    console.info(index);
         var StationId = arrdata[index].StationId;
         //console.info(StationId);
         var arr = new Array(); //初始化传参数组
         for(var i=0;i<arrdata.length;i++){//一次验收该机房下的所有电池组构建对象 。
            if(StationId == arrdata[i].StationId){
               var obj = {
                  binf:{
                     StationId : arrdata[i].StationId,   // 机房编号
                     StationName : (arrdata[i].StationName1+"-"+ arrdata[i].StationName2+"-"+arrdata[i].StationName5+"-"+arrdata[i].StationName3),   // 拼接机房名称
                     StationName1 :arrdata[i].StationName1,      // 省
                     StationName2 : arrdata[i].StationName2,      // 市
                     StationName5 :  arrdata[i].StationName5,      // 区/县
                     StationName3 :  arrdata[i].StationName3,      // 机房名称
                     StationName4 : arrdata[i].StationName4,      // 设备名称
                     StationIp :arrdata[i].StationIp,            //机房ip
                     FBSDeviceId : arrdata[i].FBSDeviceId,            //设备id
                     FbsDeviceIp : arrdata[i].FbsDeviceIp,            //设备ip
                     FbsDeviceIp_YM :  arrdata[i].FbsDeviceIp_YM,         // 设备掩码
                     FbsDeviceIp_WG : arrdata[i].FbsDeviceIp_WG ,         // 网关
                     FBSDeviceName : arrdata[i].FBSDeviceName,         //设备名称
                     GroupIndexInFBSDevice : arrdata[i].GroupIndexInFBSDevice,   //fbs设备索引
                     BattGroupId : arrdata[i].BattGroupId,            //电池组id
                     BattGroupNum : arrdata[i].BattGroupNum ,         //机房内电池组编号
                     BattGroupName :arrdata[i].BattGroupName,        //电池组索引
                     FloatVolLevel : arrdata[i].FloatVolLevel,         //浮充电压阀值
                     OfflineVolLevel : arrdata[i].OfflineVolLevel,         //离线电压阀值
                     BattFloatCurrent : arrdata[i].BattFloatCurrent,      //浮充电流阀值
                     MonCount : arrdata[i].MonCount,            //单体数量
                     MonCapStd : arrdata[i].MonCapStd,            //标称容量
                     MonVolStd : arrdata[i].MonVolStd,            //标称电压
                     MonResStd : arrdata[i].MonResStd,            //标称内阻
                     MonSerStd : arrdata[i].MonSerStd,            //标称电导
                     MonVolLowToAvg : arrdata[i].MonVolLowToAvg,         //单体电压次低偏移量
                     Load_curr : arrdata[i].Load_curr,            //负载电流
                     DisCurrMax : arrdata[i].DisCurrMax,            //最大核容电流
                     station_phone : arrdata[i].station_phone,         //基站号码
                     BattProducer : arrdata[i].BattProducer,         //电池品牌
                     BattModel : arrdata[i].BattModel,            //电池型号
                     BattProductDate :  arrdata[i].BattProductDate,      //电池生产日期
                     BattInUseDate :  arrdata[i].BattInUseDate,         //电池使用日期
                     install_user : arrdata[i].install_user,         //安装人员
                  }
               }
               arr.push(obj);
            }
         }
         console.info(arr);
         //applyendyanshou(arr);//申请验收方法。
         var json=window.JSON.stringify(arr);
            setCookie("eleparm",json);  //这里setcookie,若有上一条cookie则清空上一笔
         return arr;
      }
   function creatMonCapOpt(suoyin){
       var k,optionStr='',allString
        for(var i=1;i<11;i++){
          k=i*50;
           //optionStr+='<option'+' value='+k+'>'+k+'</option>';
          optionStr+='<option'+' value='+k+'>'+k+'</option>';
          }
        return  allString=optionStr+'<option'+' selected = selected '+' value='+1000+'>'+1000+'</option>';
   }
   function getRadioValue(na){
      var str='input[name='+na+']:checked'
      return $(str).val();
   }
   function setRadioSeleted(v){
       var str='input:radio[value='+v+']';
       return $(str).attr('checked','true');
   }
   function setchangedMonVolStd(suoyin){
         for(var u=0;u<suoyin;u++){
           var id='';
          id='#MonCount'+u;
          (function(u){
              var vol='#MonVolStd'+u;
             $(document).on("change", id, function () {
                    if($(this).find("option:selected").val()==4){$(vol).val(12);}
                    if($(this).find("option:selected").val()==24){$(vol).val(2);}
             })
          })(u)
         }
   }
   setchangedMonVolStd(suoyin);
   function setMonVolStd(index){
          for(var i=0;i<index;i++){
             var s='#MonVolStd'+i;
             $(s).val(12);
          }
    }
    /* 操作成功 
   $('#changeSuc').popup('open');
       操作失败