wangzhibo
2021-11-07 5dcd63bfa4498971727ba222365a3050f7df86cb
widgetsTS/widget_summary/view.js
@@ -2,6 +2,8 @@
var current_selected_monitor_name = "国控点";
var current_selected_monitor_qindex = "pm25";
var tmpTopListQueryResult;
//对应widget.js中MyWidget实例化后的对象
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'); //选择所有name="'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);
    }
}