wangzhibo
2021-11-25 5795821d0ad9c9f3f56ec92dc8df7aada5d2aa6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
var current_selected_monitor_type = 1001;
var current_selected_monitor_name = "国控点";
var current_selected_monitor_qindex = "pm25";
 
var tmpTopListQueryResult;
 
//对应widget.js中MyWidget实例化后的对象
var thisWidget
 
//当前页面业务
function initWidgetView(_thisWidget) {
    thisWidget = _thisWidget
 
    loadCountByUserid();
 
    $(".cnt_div a").on("click", function () {
        $(".cnt_div a").removeClass("select_btn");
        $(this).addClass("select_btn");
        current_selected_monitor_type = $(this).attr("_code");
        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);  
            });
        }  
    });
 
 
}
 
//加载count
function loadCountByUserid() {
    var backend_url = thisWidget.nodejs_url_predix + "dataapi/Bdata?bid=get_all_count_by_id&userid=" + thisWidget.userid;
    $.ajax({
        type: 'get',
        dataType: 'json',
        data: {},
        async: true,//同步
        url: backend_url,
        success: function (data) {
            var cntGroup = data.data.result;
            if (cntGroup != null) {
                for (var i = 0; i < cntGroup.length; i++) {
                    var j = i + 1;
                    var cntObj = cntGroup[i];
                    $("#count" + j).text(cntObj.count);
                    $("#countName" + j).text(cntObj.name);
                    $("#href" + j).attr("_code", cntObj.code);
                    $("#href" + j).attr("_name", cntObj.name);
                }
            }
        },
        error: function (request, textStatus) {
            haoutil.msg("系统后台错误,请联系管理员处理!");
        }
    });
 
    $("#qindex_selection").change(function () {
        current_selected_monitor_qindex = $("#qindex_selection").val();
        reloadData();
    });
 
}
function changeQindexSelection() {
    current_selected_monitor_qindex = "pm25";  // 重设qindex
    $("#qindex_selection").empty();
    var options = [];
    if (current_selected_monitor_type == 1001) {
        options = Object.keys(qindex_range_list_1001);
    } else if (current_selected_monitor_type == 1002) {
        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);
    }
 
    options.forEach(element => $("#qindex_selection").append("<option value='" + element + "'>" + element + "</option>"));
 
}
 
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;
    //加入cntId
    $.ajax({
        type: 'get',
        dataType: 'json',
        //crossDomain: true,
        data: {},
        async: true,//同步
        url: backend_url,
        success: function (data) {
            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 = tmpTopListQueryResult[i];
                    for (var key in topObj) {
                        if (topObj[key] == null || topObj[key] == 'null' || topObj[key] == undefined || topObj[key] == 'undefined') {
                            topObj[key] = "/";
                        }
                      }
                        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("查询无数据,请更换查询条件!");
            }
 
        },
        error: function (request, textStatus) {
            haoutil.msg("系统后台错误,请联系管理员处理!");
        }
    });
}
 
 
function over(obj) {
    $('#top10Tb tr').removeClass("over_tr");
    $(obj).addClass("over_tr");
}
 
function out(obj) {
 
    $(obj).removeClass("over_tr");
}
 
function locateAndShowDetail(obj) {
    $('#top10Tb tr').removeClass("select_tr");
    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 });
    }
}
 
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);
    }
}