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();
|
// loadCountByUserid_taxi();
|
|
$(".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();
|
throttling()
|
});
|
|
$("#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);
|
});
|
}
|
});
|
|
|
}
|
|
// 节流,防止用户点击多次请求多次
|
let timeout;
|
//需要定义在方法外
|
function throttling(){
|
//先清理
|
clearTimeout(timeout)
|
timeout = setTimeout(() => {
|
reloadData()
|
}, 500)
|
}
|
//加载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) {
|
console.log(request);
|
console.log(textStatus);
|
haoutil.msg("系统后台错误,请联系管理员处理!");
|
}
|
});
|
var backend_url_taxi = thisWidget.nodejs_url_predix + "dataapi/Bdata?bid=get_count_all&datatype=" + thisWidget.datatype + "&datatime="+ thisWidget.datatime;
|
$.ajax({
|
type: 'get',
|
dataType: 'json',
|
data: {},
|
async: true,//同步
|
url : backend_url_taxi,
|
success: function (data) {
|
var cntGroup = data.data.result;
|
if (cntGroup != null) {
|
for(var i=0;i < cntGroup.length;i++){
|
var cntobj = cntGroup[i]
|
$("#count_all").text(cntobj.count_all);
|
$("#count_bus").text(cntobj.count_bus);
|
$("#count_taxi").text(cntobj.count_taxi);
|
$("#countName").text(cntobj.name);
|
$("#href4").attr("_code", cntobj.code);
|
$("#href4").attr("_name", cntobj.name);
|
}
|
}
|
},
|
error: function (request, textStatus) {
|
console.log(request);
|
console.log(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>"));
|
$("#qindex_selection").find("option[value=pm25]").text("PM₂.₅");
|
$("#qindex_selection").find("option[value=pm10]").text("PM₁₀");
|
$("#qindex_selection").find("option[value=no]").text("NO");
|
$("#qindex_selection").find("option[value=nox]").text("NOₓ");
|
$("#qindex_selection").find("option[value=no2]").text("NO₂");
|
$("#qindex_selection").find("option[value=co]").text("CO");
|
$("#qindex_selection").find("option[value=so2]").text("SO₂");
|
$("#qindex_selection").find("option[value=o3]").text("O₃");
|
$("#qindex_selection").find("option[value=o31]").text("O₃₁");
|
$("#qindex_selection").find("option[value=o38]").text("O₃₈");
|
$("#qindex_selection").find("option[value=aqi]").text("AQI");
|
$("#qindex_selection").find("option[value=tsp]").text("TSP");
|
|
}
|
|
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+ "&userid=" + thisWidget.userid + "&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];
|
topObj = changeNullAndundefinedToEmpty(topObj);
|
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) {
|
console.log(request);
|
console.log(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);
|
}
|
}
|