jyyhq/witDisplay/js/eMap/eMap.js

181 lines
5.2 KiB
JavaScript

$(function(){
$('#map').load('../../page/svg/svgMap_3D_electric.svg',function(){
$('#floors').css('display','block')
$('#checkBox').css('display','block')
handleCheckboxClick();
deviceNum();
realTime();
})
//接口状态数量
interfaceStatus();
})
//接口状态点击
function interfaceStateClick(){
var index = layer.open({
title: ['接口状态','color: #fff'],
type: 2,
closeBtn: 2,
content: '../../page/index/child/interfaceState.html',
area: ["70%", "90%"],
maxmin: false
});
}
//
// const buildingLocationInfo = {
//
// }
//
//大楼与楼栋与楼层间的跳转
function changMap(type,floor){
if(floor == 0){
}
if(type == 0){ // 返回按钮 --- 经研院全局图
$("iframe").attr('src',"../../page/svg/svgMap_2D.html");
}else if(type == 1){ // 计量楼
$("iframe").attr('src',"../../page/svg/JL/svgJL_1.html");
}else if(type == 2){ // 化学楼
$("iframe").attr('src',"../../page/svg/HX/svgHX_1.html");
}else if(type == 3){ //综合楼
$("iframe").attr('src',"../../page/svg/ZH/svgZH_0.html");
}
}
$("#floors li").on({
click : function(){
var name = $(this).attr("name");
if(name === '计量楼'){
$("#map").load('../../page/eMap_svg/JL/svgJL_1.html')
$('#floors').css('display','none')
$('#checkBox').css('display','none')
}
if(name === '化学楼'){
$("#map").load("../../page/eMap_svg/HX/svgHX_1.html")
$('#floors').css('display','none')
$('#checkBox').css('display','none')
}
if(name === '综合楼'){
$("#map").load("../../page/eMap_svg/ZH/svgZH_0.html");
$('#floors').css('display','none')
$('#checkBox').css('display','none')
}
if(name === '4号楼'){
$("#map").load("../../page/eMap_svg/ST/svgST_1.html");
$('#floors').css('display','none')
$('#checkBox').css('display','none')
}
}
});
function handleCheckboxClick() {
const checkboxMapping = {
checkbox1: [".element-group1"],
checkbox2: [".element-group2"],
checkbox3: [".element-group3"],
checkbox4: [".element-group4"]
};
// 获取所有复选框
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(function(checkbox) {
checkbox.addEventListener('click', function() {
// 获取当前复选框的ID
var checkboxId = checkbox.getAttribute('id');
// 获取当前复选框对应的要隐藏的g标签和path标签数组
var selectorsToHide = checkboxMapping[checkboxId];
// 遍历所有要隐藏的选择器并根据是否要隐藏进行显示或隐藏
selectorsToHide.forEach(function(selector) {
var elements = document.querySelectorAll(selector); // 使用有效的CSS选择器
elements.forEach(function(element) {
if (checkbox.checked) {
element.style.display = 'block';
} else {
element.style.display = 'none';
}
});
});
});
});
}
/**
* 智慧用电-接口状态数量
*/
function interfaceStatus() {
$.ajax({
type: 'POST',
url: dataUrl + 'electricity/interfaceStatus',
data: "type=4",
dataType: 'json',
success: function(res) {
let interface = res.obj.electricityBean;
document.getElementById('requestNum').innerText = parseInt(interface.requestNum);
document.getElementById('successNum').innerText = parseInt(interface.successNum);
document.getElementById('errorNum').innerText = parseInt(interface.errorNum);
}
});
}
/**
* 电子地图-设备数量
*/
function deviceNum() {
$.ajax({
type: 'POST',
url: dataUrl + 'electronicMap/deviceCount',
data: "",
dataType: 'json',
success: function(res) {
let deviceCount = res.obj.deviceCount;
document.getElementById('camera').innerText = parseInt(deviceCount[0].camera);
document.getElementById('stand').innerText = parseInt(deviceCount[1].stand);
document.getElementById('switch').innerText = parseInt(deviceCount[2].switch);
document.getElementById('firefight').innerText = parseInt(deviceCount[3].firefight);
var Monitoring = parseInt(deviceCount[0].camera)-(parseInt(deviceCount[0].camera1) + parseInt(deviceCount[0].camera2) + parseInt(deviceCount[0].camera3) + parseInt(deviceCount[0].camera4));
$('#map').find('#svg_795').text(parseInt(deviceCount[0].camera1));
$('#map').find('#svg_793').text(parseInt(deviceCount[0].camera2));
$('#map').find('#svg_800').text(parseInt(deviceCount[0].camera3));
$('#map').find('#svg_803').text(Monitoring);
$('#map').find('#svg_783').text(parseInt(deviceCount[0].camera4));
$('#map').find('#svg_801').text(parseInt(deviceCount[1].stand));
$('#map').find('#svg_796').text(parseInt(deviceCount[2].switch));
$('#map').find('#svg_804').text(parseInt(deviceCount[3].firefight-deviceCount[5].firefight3-deviceCount[4].firefight1)); //监控消防栓
$('#map').find('#svg_802').text(parseInt(deviceCount[5].firefight3)); //3号消防栓
$('#map').find('#svg_792').text(parseInt(deviceCount[4].firefight1)); //1号消防栓
}
});
}
//实时数据
function realTimeData(){
$.ajax({
type: 'POST',
url: dataUrl + '',
data: "",
dataType: 'json',
success: function(res) {
// realTime();
}
});
}
function realTime(){
var elements = document.getElementsByClassName("your-selector");
for (var i = 0; i < elements.length; i++) {
elements[i].innerHTML = "45";
}
}