From 5dcd63bfa4498971727ba222365a3050f7df86cb Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期日, 07 十一月 2021 17:13:30 +0800
Subject: [PATCH] 添加 勾选框,多点定位

---
 widgetsTS/widget_summary/view.js |   84 +++++++++++++++++++++++++++++------------
 1 files changed, 59 insertions(+), 25 deletions(-)

diff --git a/widgetsTS/widget_summary/view.js b/widgetsTS/widget_summary/view.js
index 534196e..1bbd612 100644
--- a/widgetsTS/widget_summary/view.js
+++ b/widgetsTS/widget_summary/view.js
@@ -2,6 +2,8 @@
 var current_selected_monitor_name = "鍥芥帶鐐�";
 var current_selected_monitor_qindex = "pm25";
 
+var tmpTopListQueryResult;
+
 //瀵瑰簲widget.js涓璏yWidget瀹炰緥鍖栧悗鐨勫璞�
 var thisWidget
 
@@ -18,6 +20,18 @@
         current_selected_monitor_name = $(this).attr("_name");
         changeQindexSelection();
         reloadData();
+    });
+
+    $("#selectedALL").click(function() { 
+        if (this.checked){ 
+            $("input[name='selectedItem']:checkbox").each(function(){ 
+                  $(this).prop("checked", true);  
+            });
+        } else {   
+            $("input[name='selectedItem']:checkbox").each(function() {   
+                  $(this).prop("checked", false);  
+            });
+        }  
     });
 
 
@@ -57,7 +71,7 @@
 
 }
 function changeQindexSelection() {
-
+    current_selected_monitor_qindex = "pm25";  // 閲嶈qindex
     $("#qindex_selection").empty();
     var options = [];
     if (current_selected_monitor_type == 1001) {
@@ -66,6 +80,7 @@
         options = Object.keys(qindex_range_list_1002);
     } else if (current_selected_monitor_type == 1003) {
         options = Object.keys(qindex_range_list_1003);
+        current_selected_monitor_qindex = "tsp";
     } else {
         options = Object.keys(qindex_range_list_1004_and_other);
     }
@@ -76,7 +91,7 @@
 
 function reloadData() {
     $("#top10Tb").empty();
-    var backend_url = thisWidget.nodejs_url_predix + "dataapi/Bdata?bid=get_" + current_selected_monitor_type + "_list&datatype=" + thisWidget.datatype + "&datatime=" + thisWidget.datatime + "&qindex=" + current_selected_monitor_qindex + "&pageno=1&pagesize="+default_system_params.summary_topN_count;
+    var backend_url = thisWidget.nodejs_url_predix + "dataapi/Bdata?bid=get_" + current_selected_monitor_type + "_list&datatype=" + thisWidget.datatype + "&datatime=" + thisWidget.datatime + "&qindex=" + current_selected_monitor_qindex + "&pageno=1&pagesize=" + default_system_params.summary_topN_count;
     //鍔犲叆cntId
     $.ajax({
         type: 'get',
@@ -86,26 +101,25 @@
         async: true,//鍚屾
         url: backend_url,
         success: function (data) {
-            var tableData = data.data.result;
-            //console.log(tableData);
-            if (tableData != null && tableData.length>0) {
-                for (var i = 0; length = tableData.length, i < length ; i++) {
+            tmpTopListQueryResult = data.data.result;;
+            if (tmpTopListQueryResult != null && tmpTopListQueryResult.length > 0) {
+                for (var i = 0; length = tmpTopListQueryResult.length, i < length; i++) {
                     var j = i + 1;
-                    var topObj = tableData[i];
-                    if(topObj[current_selected_monitor_qindex] == null){
-                        var _tr = "<tr _siteid='" + topObj.code + "' _lon='" + topObj.lon + "' _lat='" + topObj.lat + "' onclick='locateAndShowDetail(this)' onmouseover='over(this)' onmouseout='out(this)' ><td>" + j + "</td><td>" + topObj.code + "</td><td>" + topObj.name + "</td><td><font color='" + getLayerPointColorByQindexandValue(current_selected_monitor_type, current_selected_monitor_qindex, topObj[current_selected_monitor_qindex]) + "'>" + "/" + "</font></td></tr>"
+                    var topObj = tmpTopListQueryResult[i];
+                    if (topObj[current_selected_monitor_qindex] == null) {
+                        var _tr = "<tr _siteid='" + topObj.code + "' _lon='" + topObj.lon + "' _lat='" + topObj.lat + "' onmouseover='over(this)' onmouseout='out(this)' ><td><input type='checkbox' name='selectedItem' value='" + j + "' /></td><td>" + j + "</td><td onclick='locateAndShowDetail(this)'>" + topObj.code + "</td><td onclick='locateAndShowDetail(this)'>" + topObj.name + "</td><td><font color='" + getLayerPointColorByQindexandValue(current_selected_monitor_type, current_selected_monitor_qindex, topObj[current_selected_monitor_qindex]) + "'>" + "/" + "</font></td></tr>"
                         $("#top10Tb").append(_tr);
-                    } else if(topObj.name == undefined){
-                        var _tr = "<tr _siteid='" + topObj.code + "' _lon='" + topObj.lon + "' _lat='" + topObj.lat + "' onclick='locateAndShowDetail(this)' onmouseover='over(this)' onmouseout='out(this)' ><td>" + j + "</td><td>" + topObj.code + "</td><td>" + "/" + "</td><td><font color='" + getLayerPointColorByQindexandValue(current_selected_monitor_type, current_selected_monitor_qindex, topObj[current_selected_monitor_qindex]) + "'>" + topObj[current_selected_monitor_qindex] + "</font></td></tr>"
+                    } else if (topObj.name == undefined) {
+                        var _tr = "<tr _siteid='" + topObj.code + "' _lon='" + topObj.lon + "' _lat='" + topObj.lat + "' onmouseover='over(this)' onmouseout='out(this)' ><td><input type='checkbox' name='selectedItem' value='" + j + "' /></td><td>" + j + "</td><td onclick='locateAndShowDetail(this)'>" + topObj.code + "</td><td onclick='locateAndShowDetail(this)'>" + "/" + "</td><td><font color='" + getLayerPointColorByQindexandValue(current_selected_monitor_type, current_selected_monitor_qindex, topObj[current_selected_monitor_qindex]) + "'>" + topObj[current_selected_monitor_qindex] + "</font></td></tr>"
                         $("#top10Tb").append(_tr);
-                    }else{
-                        var _tr = "<tr _siteid='" + topObj.code + "' _lon='" + topObj.lon + "' _lat='" + topObj.lat + "' onclick='locateAndShowDetail(this)' onmouseover='over(this)' onmouseout='out(this)' ><td>" + j + "</td><td>" + topObj.code + "</td><td>" + topObj.name + "</td><td><font color='" + getLayerPointColorByQindexandValue(current_selected_monitor_type, current_selected_monitor_qindex, topObj[current_selected_monitor_qindex]) + "'>" + topObj[current_selected_monitor_qindex] + "</font></td></tr>"
+                    } else {
+                        var _tr = "<tr _siteid='" + topObj.code + "' _lon='" + topObj.lon + "' _lat='" + topObj.lat + "' onmouseover='over(this)' onmouseout='out(this)' ><td><input type='checkbox' name='selectedItem' value='" + j + "' /></td><td>" + j + "</td><td onclick='locateAndShowDetail(this)'>" + topObj.code + "</td><td onclick='locateAndShowDetail(this)'>" + topObj.name + "</td><td><font color='" + getLayerPointColorByQindexandValue(current_selected_monitor_type, current_selected_monitor_qindex, topObj[current_selected_monitor_qindex]) + "'>" + topObj[current_selected_monitor_qindex] + "</font></td></tr>"
                         $("#top10Tb").append(_tr);
                     }
-                }      
-         }else{
-            haoutil.msg("鏌ヨ鏃犳暟鎹紝璇锋洿鎹㈡煡璇㈡潯浠讹紒");
-         }
+                }
+            } else {
+                haoutil.msg("鏌ヨ鏃犳暟鎹紝璇锋洿鎹㈡煡璇㈡潯浠讹紒");
+            }
 
         },
         error: function (request, textStatus) {
@@ -127,20 +141,40 @@
 
 function locateAndShowDetail(obj) {
     $('#top10Tb tr').removeClass("select_tr");
-    $(obj).addClass("select_tr");
-    var siteId = $(obj).attr("_siteid");
-    var lon = $(obj).attr("_lon");
-    var lat = $(obj).attr("_lat");
+    let parentObj = $(obj).parent();
+
+    $(parentObj).addClass("select_tr");
+    var siteId = $(parentObj).attr("_siteid");
+    var lon = $(parentObj).attr("_lon");
+    var lat = $(parentObj).attr("_lat");
 
     if (lon && lon != 'undefined') {
         thisWidget.locateAndHighlight(lon, lat);
     }
-    if (current_selected_monitor_type !=100500){
-        thisWidget.showDetailedWindow({ "nodejs_url_predix": thisWidget.nodejs_url_predix, "datatype": thisWidget.datatype,"selected_qindex": current_selected_monitor_qindex,"datatime": thisWidget.datatime, "layerid": current_selected_monitor_type, "siteid": siteId });
+    if (current_selected_monitor_type != 100500) {
+        thisWidget.showDetailedWindow({ "nodejs_url_predix": thisWidget.nodejs_url_predix, "datatype": thisWidget.datatype, "selected_qindex": current_selected_monitor_qindex, "datatime": thisWidget.datatime, "layerid": current_selected_monitor_type, "siteid": siteId });
     }
 }
 
-function setTopNname(count){
-    $("#topN_name").html("Top"+count);
+function setTopNname(count) {
+    $("#topN_name").html("Top" + count);
 
+}
+
+function highlightSelected() {
+
+    var obj = document.getElementsByName('selectedItem'); //閫夋嫨鎵�鏈塶ame="'selectedItem'"鐨勫璞★紝杩斿洖鏁扮粍 
+    var selectedItem = [];
+    for (var i = 0; i < obj.length; ++i) {
+        if (obj[i].checked) {
+            selectedItem[selectedItem.length] = tmpTopListQueryResult[i];
+        }
+    }
+
+    if (selectedItem.length <= 0) {
+        haoutil.msg("璇峰嬀閫�");
+    } else {
+        //console.log(selectedItem);
+        thisWidget.HighlightMulti(current_selected_monitor_type, current_selected_monitor_qindex, selectedItem);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1