qinbo
2021-11-02 4a1aaa1eb44bac3dc66c34187ca312c19d2ddf85
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
var current_selected_monitor_type = 1001;
var current_selected_monitor_name = "国控点";
var current_selected_monitor_qindex = "pm25";
 
//对应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();
    });
 
 
}
 
//加载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) {
 
        }
    });
 
    $("#qindex_selection").change(function () {
        current_selected_monitor_qindex = $("#qindex_selection").val();
        reloadData();
    });
 
}
function changeQindexSelection() {
 
    $("#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);
    } 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=20";
    //加入cntId
    $.ajax({
        type: 'get',
        dataType: 'json',
        //crossDomain: true,
        data: {},
        async: true,//同步
        url: backend_url,
        success: function (data) {
            var tableData = data.data.result;
            //console.log(tableData);
            if (tableData != null) {
                for (var i = 0; length = tableData.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>"
                        $("#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>"
                        $("#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>"
                        $("#top10Tb").append(_tr);
                    }
                }      
         }
 
        },
        error: function (request, textStatus) {
 
        }
    });
}
 
 
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");
    $(obj).addClass("select_tr");
    var siteId = $(obj).attr("_siteid");
    var lon = $(obj).attr("_lon");
    var lat = $(obj).attr("_lat");
 
    if (lon && lon != 'undefined') {
        thisWidget.locateAndHighlight(lon, lat);
    }
    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 });
}