From 1dfc2c2708fba01b771a2edd24c83363ee7c84d0 Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Thu, 09 Apr 2020 14:32:09 +0800
Subject: [PATCH] update设备跳转到实时界面

---
 src/main/webapp/js/moralmap.js |  106 +++++++++++++++++++++++++----------------------------
 1 files changed, 50 insertions(+), 56 deletions(-)

diff --git a/src/main/webapp/js/moralmap.js b/src/main/webapp/js/moralmap.js
index 6031fd8..0ad00e8 100644
--- a/src/main/webapp/js/moralmap.js
+++ b/src/main/webapp/js/moralmap.js
@@ -70,6 +70,11 @@
         var myGeo = new BMap.Geocoder();
         myGeo.getPoint(address, function (point) {
             if (point) {
+                if ("���������" == cityName) {
+                    var longitude = 113.30640743;
+                    var latitude = 40.08256467;
+                    var point = new BMap.Point(longitude, latitude);
+                }
                 map.centerAndZoom(point, showZoom);
             } else {
                 alert("������������������������������������!");
@@ -310,26 +315,25 @@
             return;
         }
         var equ = {
-            methodName: 'chart' == select ? 'showChart' : 'showDeviceMonitor',
+            methodName: 'showVoc' == select ? 'showVoc' : 'showDeviceMonitor',
             name: row['name'],
             mac: (row['mac']).toLowerCase(),
             longitude: row['longitude'],
             latitude: row['latitude'],
             monitorPointId: row['monitorPointId'],
-            version: row['deviceVersion']['version']
+            version: row['deviceVersion']['version'],
+            provinceCode: row['monitorPoint']['provinceCode']
         };
         !!select ? equ['monitorPointId'] = row["monitorPointId"] : null;
         var equStr = JSON.stringify(equ);
         if (window["console"] != undefined) {
-            console.log(equStr);
+            // console.log(equStr);
         }
         if (!!window['external'] && !!window['external']['callWin']) {
             window['external'].callWin(equStr);
         } else {
-            if (!!select && select === 'chart' && !!window['external'] && !!window['external']['showChartInfo']) {
+            if (!!select && select === 'showVoc' && !!window['external'] && !!window['external']['showVocInfo']) {
                 window['external'].showChartInfo(equStr);
-            } else if (!!window['external'] && !!window['external']['showMonitorInfo']) {
-                window['external'].showMonitorInfo(equStr);
             } else {
                 alert(equStr);
             }
@@ -426,7 +430,7 @@
                 var url = option['url'];
                 url += "&pageNo=" + pageNo;
                 url += "&pageSize=" + pageSize;
-                console.log(url);
+                // console.log(url);
                 $.ajax({
                     type: "get",
                     cache: false,
@@ -447,6 +451,15 @@
                                 var state = 'state01';
                                 var stateName = '';
                                 var s = e['state'] == undefined ? 0 : e['state'];
+                                if (deviceStates) {
+                                    for (var j in deviceStates) {
+                                        var deviceState = deviceStates[j];
+                                        if (deviceState.mac == e['mac']) {
+                                            s = deviceState.state;
+                                            break;
+                                        }
+                                    }
+                                }
                                 var stateObj = _getStateMap(s);
                                 state = stateObj["state"];
                                 stateName = stateObj["stateName"];
@@ -466,9 +479,9 @@
                                     }
                                     name = name.substring(0, stop1) + "..." + name.substring(stop2, name.length);
                                 }
-                                var li = "<li id='listview_item_" + e['mac'] + "'><span class='list-chart-span' onclick=moralMap.onItermClick(\"" + i + "\",'chart')><img src='/img/chart.png'></span>"
+                                var li = "<li id='listview_item_" + e['mac'] + "'><span class='list-chart-span' onclick=moralMap.onItermClick(\"" + i + "\",'showVoc')><img src='/img/list.png' width='20px'></span>"
                                     + "<span id='listview_state_" + e['mac'] + "'class='" + state + "'>" + stateName + "</span>" +
-                                    "<div style='cursor: pointer;'  onclick=moralMap.onItermClick(\"" + i + "\")>" + name + "</div></li>";
+                                    "<div>" + name + "</div></li>";
                                 outHtml += li;
                             }
                             outHtml += "</ul>";
@@ -572,56 +585,35 @@
         var moralMarker = new moralMap.MoralMarker(option);
         //	    var mark =new BMap.Marker(pointObj,{icon:iconObj});
         //==================infoWindow-start============================
-        var infoWindow = (function () {
-            //���������������
-            var winOpts = {
-                width: 110, // ������������������
-                height: 80, // ������������������
-                title: getTitleOutHtml(), // ������������������
-                offset: new BMap.Size(-8, -5) //���������������������
-            }
-
-            function getTitleOutHtml() {
-                //title���������������...
-                var title = (option["name"] == null) ? "" : option["name"];
-                if (title.length > 13) {
-                    title = title.slice(0, 13) + "...";
-                }
-                var titleOutHtml = "";
-                titleOutHtml += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'"
-                titleOutHtml += "title='" + option["name"] + "'>";
-                titleOutHtml += title + "</p>";
-                return titleOutHtml;
-            }
-
-            function getAdressOutHtml() {
-                var address = (option["address"] == null) ? "" : option["address"];
-                if (address.length > 18) {
-                    address = address.slice(0, 18) + "...";
-                }
-                var adressOutHtml = "";
-                adressOutHtml += "<div onmouseover='moralMap.clearCloseInfoWindow()'";
-                adressOutHtml += "onmouseout='moralMap.closeInfoWindow()'";
-                adressOutHtml += " style='font:12px arial,sans-serif;margin-top:12px'><table cellspacing='0' style='overflow:hidden;table-layout:fixed;width:100%;font:12px arial,sans-serif'>";
-                adressOutHtml += "<tbody><tr><td style='vertical-align:top;width:38px;white-space:nowrap;word-break:keep-all'>���������&nbsp;</td><td style='line-height:16px'>";
-                adressOutHtml += address + "&nbsp;";
-                adressOutHtml += "</td></tr>";
-                //adressOutHtml += "<tr><td style='width:98%;padding-top:10px;'colspan='2'><a href='javascript:void(0);' style='display:block;position: relative;float: right;' onclick='moralMap.showPointMonitor("+option.id+")'>������������>></a></td></tr>";
-                adressOutHtml += "</tbody></table></div>";
-                return adressOutHtml;
-            }
-
-            return new BMap.InfoWindow(getAdressOutHtml(), winOpts);
-        })();
+        var infoWindow;
         if (moralMarker["infoWindow"] == undefined) {
             moralMarker["infoWindow"] = infoWindow;
         }
+
         //���������������������
-        moralMarker.addEventListener("mouseover", function () {
+        moralMarker.addEventListener("click", function () {
+            var winOpts = {
+                width: 250, // ������������������
+                height: 160, // ������������������
+                // title: getTitleOutHtml(), // ������������������
+                offset: new BMap.Size(-8, -5) //���������������������
+            }
+            var winfowText = "<div style='width:250px'>";
+            var title = (option["name"] == null) ? "" : option["name"];
+            if (title.length > 13) {
+                title = title.slice(0, 13) + "...";
+            }
+            winfowText += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'"
+            winfowText += "title='" + option["name"] + "'>";
+            winfowText += title + "</p>";
+            var listText = '<div id="equ_list" class="listview" style="min-height:50px;overflow:auto;max-height:140px;" ></div>';
+            winfowText = winfowText + listText + "</div>";
+            var infoWindow = new BMap.InfoWindow(winfowText, winOpts);
             moralMap.openInfoWindow(infoWindow, this._point); //������������������
         });
+
         moralMarker.addEventListener("mouseout", function () {
-            moralMap.closeInfoWindow();
+            // moralMap.closeInfoWindow();
         });
         //==================infoWindow-end============================
         //���������������
@@ -650,7 +642,6 @@
         }
 
     }
-
     //���������mac���key������
     //��������������� ������MoralMark������
     moralMap.Equipment = function (option) {
@@ -836,10 +827,10 @@
             }
 
             moralMap.showSensors = function (jsonData) {
-                if(!jsonData.hasOwnProperty('mac')){
+                if (!jsonData.hasOwnProperty('mac')) {
                     infoWindow.setContent("");
                     infoWindow.redraw();
-                }else{
+                } else {
                     var adressOutHtml = '<div style="min-height:20px;overflow:auto;max-height:400px;font-size: 12px;" onmouseover="moralMap.clearCloseInfoWindow()" onmouseout="moralMap.closeInfoWindow()">';
                     var y, m, d, h, mm, s;
                     var date = new Date(jsonData['time']);
@@ -861,6 +852,9 @@
                             for (var key in sensorsUnitMap) {
                                 if (prop == key) {
                                     var sensorsUnit = sensorsUnitMap[key];
+                                    if (sensorsUnit == null) {
+                                        sensorsUnit = "";
+                                    }
                                 }
                             }
                             adressOutHtml += ('<p style="height: 18px;line-height: 18px">' + sensorsDescription + "���" + jsonData[prop] + sensorsUnit + "</p>");
@@ -1087,4 +1081,4 @@
     }
 
     window.moralMap = moralMap;
-})(jQuery, BMap, window);
\ No newline at end of file
+})(jQuery, BMap, window);

--
Gitblit v1.8.0