星伟
2018-09-30 fd1f11f6d7a75c52a7c2db5fe9a39e129216b96a
gx_tieta/WebRoot/index.jsp
@@ -75,6 +75,12 @@
      .ui-resizable-s, .ui-resizable-se {
         display: none !important;
      }
      .ui-autocomplete {
         height: 200px;
         overflow-y: auto;
         overflow-x: hidden;
       }
   </style>
   <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
   
@@ -93,9 +99,6 @@
      <div id="content">
         <div class="nav-map small">
            <!-- 电池分布图 -->
            <div class="side-bar abs">
               <div class="lside"></div>
            </div>
            <div class="china-map" id="map">
               <div class="img-change" style="display:none;">
                  <div class="img-list">
@@ -600,7 +603,6 @@
               
               flushFourPie();      //更新四种饼状图
            });
            // 设置右键菜单
            var menu = new BMap.ContextMenu();
            var txtMenuItem = [
@@ -635,17 +637,7 @@
                        enparams:[e]
                     });
                  }
               },
               /* {
                  text: '机房定位',
                  callback: function(e) {
                     panel.setPanelLayout();
                     panel.showPanel();
                     $('#map .panel-mask').bind('click', function() {
                        panel.hidePanel();
                     });
                  }
               } */
               }
            ];
            //console.info(getPermit('taskchange_edit_permit', permits)+"*******");
            if(getPermit('batt_map_edit_permit', permits)) {
@@ -1347,15 +1339,6 @@
      });
   });
   
   //  点击地图的搜索按钮定位地址
   $(function() {
      $('#map').on('click', '.search .search-btn', function() {
         var posTxt = $('#map .search .pos-txt').val();
         addrAnalyze(posTxt);
      });
   });
   $(window).resize(function() {
      getMapHt();
   });
@@ -1600,11 +1583,10 @@
      
      // 遍历查询内容生成对应的图标
      for(var i = 0; i < dotList.length; i++) {
         var dotIcon = new BMap.Icon(getMapStateImg(mapImages, dotList[i].msg), new BMap.Size(36, 30));   // 设置图片
         var dotIcon = new BMap.Icon(getMapStateImg(mapImages, dotList[0].msg), new BMap.Size(36, 30));   // 设置图片
         var pt = new BMap.Point(dotList[i].lng, dotList[i].lat);
         
         var mk = new BMap.Marker(pt, {icon:dotIcon});   // 定义marker点
         var mk = new BMap.Marker(pt, {icon: dotIcon});   // 定义marker点
         addMenu(mk, mapDel);
         deletePoint(map, dotList[i].title);
         // 向mk点添加label
@@ -1629,6 +1611,11 @@
         map.addOverlay(mk);
      }
   }
   //
   
   // 删除地图上的指定点
   function deletePoint(map, msg){
@@ -1969,12 +1956,123 @@
      }
   }
   
   searchStation();
   // 设置页面中的可视区域图标
   ;(function($, window, document, gl, undefined) {
      // 设置命名空间
      gl.namespace('BMap');
      // 根据可视范围显示坐标点
      var dots = [];
      var currMarkers = {};
      // 查询当前范围内容的图标
      function queryInRect(map, callback) {
         var cp = map.getBounds(); // 返回map可视区域,以地理坐标表示
           var sw = cp.getSouthWest(); // 返回矩形区域的西南角
           var ne = cp.getNorthEast(); // 返回矩形区域的东北角
           //var zoom = map.getZoom(); //当前缩放级别
           //console.log(dots);
           var mapDots = getDotsList(sw, ne);
           callback(map, mapDots);
      }
      // 获取dots的集合
      function getDotsList(sw, ne) {
         var rs = [];
            swlng=sw.lng,
               swlat=sw.lat,
               nelng=ne.lng,
               nelat=ne.lat;
               var maxLng = sw.lng>ne.lng?sw.lng:ne.lng;
               var minLng = sw.lng<ne.lng?sw.lng:ne.lng;
               var maxLat = sw.lat>ne.lat?sw.lat:ne.lat;
               var minLat = sw.lat<ne.lat?sw.lat:ne.lat;
               for(var i=0; i<dots.length; i++) {
                  var dot = dots[i];
                  var lat = dot.lat;
                  var lng = dot.lng;
                  var sId = dot.binformation.StationId;
                  var isExist = checkMarker(sId);
                  // 未被添加过
                  if(!isExist) {
                     // 判断经纬度是否存在该区域
                     if(lng<maxLng && lng>minLng && lat<maxLat && lat>minLat) {
                        currMarkers['markers'+sId] = sId;
                        rs.push(dot);
                     }
                  }
               }
               return rs;
      }
      // 检测当前点是否已经被添加过
      function checkMarker(id) {
         var flag = false;
         // 遍历已经添加的点返回是否已经被添加过
         Object.keys(currMarkers).forEach(function(key) {
            if(currMarkers[key] == id) {
               flag = true;
            }
         });
         return flag;
      }
      // 设置dots集合的值
      function setDots(data) {
         dots = data;
      }
      // 将变量绑定到命名空间下
      gl.BMap.setDots = setDots;
      // 将函数绑定到命名空间下
      gl.BMap.queryInRect = queryInRect;
   })(jQuery, window, document, GLOBAL);
   // 地图机房搜索模块
   ;(function($, window, document, gl, undefined) {
      // 设置命名空间BMap.Search模块
      gl.namespace('BMap.Search');
      var homeInfor = [];
      // 设置homeInfor的值
      function setHomeInfor(data) {
         homeInfor = data;
      }
      // 将函数绑定到命名空间下
      gl.BMap.Search.setHomeInfor = setHomeInfor;
      // 根据homeInfor的值返回home列表
      function getHomeList() {
         var rs = [];
         // 遍历homeInfor的值
         for(var i=0; i<homeInfor.length; i++) {
            rs.push(homeInfor[i].title);
         }
         return rs;
      }
      // 将函数绑定到命名空间下
      gl.BMap.Search.getHomeList = getHomeList;
   })(jQuery, window, document, GLOBAL);
   // 查询并设置机房的图标
   $(function () {
      searchStation(true);
   });
   var allStation;
   //查询机房
   function searchStation(){
   function searchStation(setRect){
      var temp = createSearchParam();
      var json = JSON.stringify(temp);
      var bmap = GLOBAL.BMap;      // BMap的命名空间
      var bmap_s = bmap.Search;   // Search的命名空间
      commonDot = new Array();
      warnDotList = new Array();
      dischargeDotList = [];
@@ -1983,18 +2081,16 @@
           type: "post",             
           //url: "BattMap_informationAction!searchAll",            
           url: "BattMap_informationAction!searchUserManageStation",            
           async:true,
           async: true,
           dataType:'text',
           data:"json="+json,      
           success: function(data){ 
            data = eval('('+data+')');
            var list = eval('('+data.result+')');
            //console.info(list);
            console.log(list.length);
            allStation = new Array();
            if(list!=undefined && list.length>0){
               for(var i=0;i<list.length;i++){
                  //console.info("第"+i+"次:"+model.data[i].binformation.num);
                  //setAllStation(model.data[i],allStation);
                  var tmp = {
                     binformation:list[i].data,
                     alarm_num:list[i].code,      //告警数目
@@ -2004,32 +2100,18 @@
                  };
                  allStation.push(analyzeData(tmp));
               }
               //console.info(allStation);
               createMapDot(map, allStation);
               //setTimeout(searchStation, 4000);
            }
            /* for(var i=0;i<allStation.length;i++){
               if(allStation[i].low_num>0){                     //落后数目
                  behindCellList.push(analyzeData(allStation[i]));
                  //console.info(analyzeData(allStation[i]));
               }else if(allStation[i].alarm_num>0){               //告警数目
                  warnDotList.push(analyzeData(allStation[i]));
               }else if(allStation[i].delay_num > 0){               //延时数目
                  dischargeDotList.push(analyzeData(allStation[i]));
               }else{
                  commonDot.push(analyzeData(allStation[i]));
               // 显示区域的图标
               bmap.setDots(allStation);
               bmap.queryInRect(map,createMapDot);
               // 是否设置拖到和缩放
               if(setRect) {
                  map.addEventListener("moveend", bmap.queryInRect.bind({},map, createMapDot));  // 拖动
                  map.addEventListener("zoomend", bmap.queryInRect.bind({},map, createMapDot)); // 缩放
               }
               //createMapDot(map, allStation);
            }
            // 清空覆盖物和对应的mk点
            map.clearOverlays();
            mkList = [];
            addCommonDotHome(commonDot);
            createWarnDot(map, warnDotList);
            dischargeTimeOut(map, dischargeDotList);
            behindDotCell(map, behindCellList); */
           }             
      });
   }
@@ -3065,74 +3147,13 @@
          img.attr('src', navImg);
       }
    }
    // siderbar模块
    //  点击地图的搜索按钮定位地址
   $(function() {
      var TreeView = GLOBAL.pages.TreeView;
      var first = GLOBAL.pages.siderbar.first;   // 一级导航
      var second = GLOBAL.pages.siderbar.second;   // 二级导航
      var thirdFile = GLOBAL.pages.siderbar.thirdFile;   // 三级导航
      var treeView = new TreeView($('.side-bar .lside'));
      // 设置容器可拖动
      $('.side-bar').resizable({
         handles: 'e',
         maxWidth: 520,
         minWidth: 200,
         alsoResize: $('.side-bar .lside'),
         resize:function() {
            treeView.setContainer();
         }
      $('#map').on('click', '.search .search-btn', function() {
         var posTxt = $('#map .search .pos-txt').val();
         addrAnalyze(posTxt);
      });
      // 生成一级导航-省
      first(treeView, treeView.container);
      // 省->市
      treeView.ele.on('click', '.province', function() {
         var province = $(this).data('attr');
         second(treeView, $(this).parent(), province);
      });
      // 市->机房
      treeView.ele.on('click', '.city', function() {
         var city = $(this).data('attr');
         thirdFile(treeView, $(this).parent(), city);
      });
      // 点击机房定位
      treeView.ele.on('click', '.home', function() {
         var home = $(this).data('attr');
         var dev_id = home.FBSDeviceId;
         searchStationById(home.StationId);
         // 根据设备id设置不同的图标
         if(eType.regType(dev_id, eType.type.equip61850)) {
            changeMapImgDesc($('#mapImgDesc'), '61850');
         }else {
            changeMapImgDesc($('#mapImgDesc'));
         }
      });
      $('#map').on('dblclick', function() {
         setLside();
         treeView.setContainer();
      });
      // 设置lside的高度
      setLside();
      treeView.setContainer();
      setLside();
      $(window).resize(function() {
         setLside();
      });
      // 设置lside的高度函数
      function setLside() {
         var sideBar = $('.side-bar');
         var lside = $('.side-bar .lside');
         // 设置宽高
         lside.width(sideBar.width());
         lside.height(sideBar.height());
      }
   });
   </script> 
</html>