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=30";
|
//加入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 });
|
}
|