var layer;// 定义全局变量
|
var isShow = false;
|
var default_top = 20;//默认上偏移
|
var default_left = 0;//默认左偏移
|
|
var listDevice;
|
var deviceMap=[];
|
|
//定时轮询时间5s
|
var INTERVAL = 5 * 1000;
|
var intervalData;
|
|
//定制,
|
var thId1 = "-999";
|
var thId2 = "-999";
|
var thData1;
|
var thData2;
|
|
var imgData = {};
|
|
var testList = [
|
{
|
"id":"21",
|
"name":"温湿度#1",
|
"category":"2001",
|
"type":"0",
|
"leftV":"0.4840",
|
"topV":"0.2015",
|
"value":[{
|
"passcode":"3",
|
"name":"温度",
|
"value":"18"
|
},{
|
"passcode":"4",
|
"name":"湿度",
|
"value":"60"
|
}]
|
},{
|
"id":"2",
|
"name":"温湿度#1",
|
"category":"2001",
|
"type":"0",
|
"leftV":"0.4840",
|
"topV":"0.2015",
|
"value":[{
|
"passcode":"3",
|
"name":"温度",
|
"value":"18"
|
},{
|
"passcode":"4",
|
"name":"湿度",
|
"value":"60"
|
}]
|
},{
|
"id":"3",
|
"name":"精密空调#1",
|
"category":"3004",
|
"type":"0",
|
"leftV":"0.6840",
|
"topV":"0.5015",
|
"value":[{
|
"passcode":"1",
|
"name":"温度",
|
"value":"18"
|
},{
|
"passcode":"2",
|
"name":"湿度",
|
"value":"60"
|
}]
|
}];
|
|
$(function () {
|
layui.use(['layer'], function () {
|
layer = layui.layer;
|
});
|
|
window.onload = function () {
|
|
if(TEST_TAG){
|
listDevice = testList;
|
renderTips(listDevice);
|
}else{
|
//初始页面
|
initImg();
|
|
//初始化数据
|
loadDevice();
|
|
//开始模块的自我循环数据
|
reLoadModelDataRecord();
|
}
|
}
|
|
});
|
|
function closepopBtn(){
|
layer.closeAll();
|
}
|
|
// 循环执行页面数据的刷新
|
function reLoadModelDataRecord(){
|
// 首先停止执行原有的循环
|
if (intervalData) clearInterval(intervalData);
|
|
intervalData = setInterval(function () {
|
//监控信息渲染
|
loadDevice();
|
}, INTERVAL);
|
}
|
|
//获取2.5D图
|
function initImg() {
|
$.ajaxSettings.async = false;
|
$.get("./cgi-bin/img-data/query", function (data, status) {
|
if ("success" == status) {
|
// console.log("-------获取2.5D图接收的数据------");
|
// console.log(data);
|
imgData = data.data;
|
renderImg();
|
} else {
|
window.parent.notify("系统获取2.5D图信息失败!");
|
}
|
}, "json");
|
}
|
|
//点击右侧操作按钮
|
function showEdit() {
|
if (isShow) {
|
$('.btn-edit').addClass('hide');
|
} else {
|
$('.btn-edit').removeClass('hide');
|
}
|
isShow = !isShow;
|
};
|
|
function renderImg() {
|
var bodyH = $(document.body).height();
|
var imgMin = $("#img-main");
|
var top = imgMin.offset().top;
|
var imgHei = bodyH - top - default_top;
|
imgMin.height(imgHei);
|
//console.log(imgData);
|
//调整展示图片地址
|
if(imgData){
|
$("#img-three").attr('src', imgData);
|
}
|
// $("#img-three").css("height", imgHei);
|
};
|
|
//获取设备列表,渲染显示设备信息
|
function loadDevice() {
|
|
$.ajaxSettings.async = false;
|
$.get("./cgi-bin/detail/query-all", function (data, status) {
|
if ("success" == status) {
|
// console.log("-------获取设备列表接收的数据------");
|
// console.log(data);
|
listDevice = data;
|
|
renderTips(listDevice)
|
} else {
|
window.parent.notify("系统获取系统配置信息失败!");
|
}
|
}, "json");
|
};
|
|
//开始渲染信息
|
function renderTips(listDevice) {
|
|
//console.log(listDevice);
|
|
var parent = $("#img-main");
|
var parentWidth = parent.width();
|
var parentHeight = parent.height();
|
|
var left = 50, top = 50;
|
var temp;
|
var id;
|
var tagValue;
|
var category;
|
var recordMap;
|
var warnState;
|
var i;
|
console.log("=========所有设备信息=========");
|
console.log(listDevice);
|
$.each(listDevice, function (index, device) {
|
i = index;
|
left = (parentWidth * device.leftV).toFixed(4);
|
top = (parentHeight * device.topV).toFixed(4);
|
category = device.category;//设备类型
|
id = device.id;//设备ID
|
if(id && category){
|
if(category != CATEGORY.D2090.code && category != CATEGORY.D2091.code){
|
recordMap = device.value;//设备监控属性集合
|
warnState = device.type;
|
tagValue = addCurData(category, recordMap, warnState,device);
|
temp = "";
|
if(device.id == thId1 || device.id == thId2){
|
if(device.id == thId1){
|
thData1 = device;
|
}else{
|
thData2 = device;
|
}
|
temp += "<div id='" + device.id
|
+ "' class='tip arrow_box' style='left:" + left+ "px;top:" + top + "px;display: none;' "
|
+ "name='" + device.name + "' category='" + category + "' index='" + index + "'>";
|
temp += "<div class = 'div-c'>";
|
temp += "</div>";
|
temp += "<div class = 'div-d' style='font-size: 14px;'><p style='margin-bottom: 5px;'><span>露点温度1</span><span style='margin-left: 10%;'>露点温度2</span></p>" +
|
"<p><span style='margin-left: 1%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>22.2℃</span>" +
|
"<span style='margin-left: 15%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>22.2℃</span></div>";
|
temp += "</div>";
|
|
}else{
|
if ("FULL" == tagValue.code) {
|
temp += "<div id='" + device.id
|
+ "' class='tip arrow_box' style='left:" + left+ "px;top:" + top + "px;' "
|
+ "name='" + device.name + "' category='" + category + "' index='" + index + "'>";
|
} else {
|
temp += "<div id='" + device.id
|
+ "' class='tip arrow_min' style='left:" + left + "px;top:" + top + "px;' "
|
+ "name='" + device.name + "' category='" + category + "' index='" + index + "'>";
|
}
|
|
temp += "<div class = 'div-c'>";
|
temp += addCurImg(category);
|
temp += "</div>";
|
temp += tagValue.htm;
|
temp += "</div>";
|
}
|
// if(category == CATEGORY.D3001.code){
|
// console.log("=========门禁设备=========设备信息:");
|
// console.log(device);
|
// }
|
|
if(device.id != "1001" && device.id != "1002"){
|
//删除原有元素,在进行追加
|
$("#"+device.id).remove();
|
parent.append(temp);
|
|
}
|
// //删除原有元素,在进行追加
|
// $("#"+device.id).remove();
|
// parent.append(temp);
|
}
|
}else{
|
console.log("=========没有获取到该设备的设备id(类型)=========设备信息:");
|
console.log(device);
|
}
|
|
|
});
|
// if(thData1 && thData2){
|
// addhtml(parent,i);
|
// }
|
|
//添加图标的事件
|
$(".tip").click(function () {
|
var id = $(this).attr("id");
|
var name = $(this).attr("name");
|
|
layer.msg("当前设备:" + name);
|
});
|
|
//添加图标的事件
|
$(".tip").dblclick(function () {
|
var deviceId = $(this).attr("id");
|
var name = $(this).attr("name");
|
var category = $(this).attr("category");
|
var url = "";
|
url = "./detail-ty.html?id="+deviceId+"&type="+category;
|
if (category == CATEGORY.D2001.code) {
|
url = "./detail-wsd.html?id="+deviceId+"&type=" + category;
|
}
|
if (category == CATEGORY.D3001.code) {
|
url = "./detail-mj.html?id="+deviceId+"&type=" + category;
|
}
|
if (category == CATEGORY.D1004.code || category == CATEGORY.D1003.code) {
|
url = "./detail-pd.html?id="+deviceId+"&type=" + category;
|
}
|
if (category == CATEGORY.D1001.code || category == CATEGORY.D1002.code) {
|
url = "./detail-ups.html?id="+deviceId+"&type=" + category;
|
}
|
if (category == CATEGORY.D2002.code) {
|
url = "./detail-jmkt.html?id="+deviceId+"&type=" + category;
|
}
|
if (category == CATEGORY.D1005.code) {
|
url = "./detail-dcz.html?id="+deviceId+"&type=" + category;
|
}
|
|
//红外
|
if (category == CATEGORY.D3003.code) {
|
url = "./detail-hw.html?id=999&type=" + category;
|
name = "红外";
|
}
|
//漏水
|
if (category == CATEGORY.D2005.code) {
|
url = "./detail-ls.html?id=999&type=" + category;
|
name = "漏水";
|
}
|
//烟感
|
if (category == CATEGORY.D3002.code) {
|
url = "./detail-yg.html?id=999&type=" + category;
|
name = "烟感";
|
}
|
if (category == CATEGORY.D3008.code) {
|
url = "./detail-wg.html?id=999&type=" + category;
|
name = "温感";
|
}
|
if (category == CATEGORY.D3004.code) {
|
// url = "./detail-video.html?id=999&type=" + category;
|
// name = "视频";
|
var html = '';
|
html += '<iframe class="J_iframe" name="iframe0" width="100%" height="100%" ';
|
html += 'src="./detail-video-pop.html?id='+deviceId+'&type='+category+'" ';
|
html += ' frameborder="0" data-id="detail-ty-2.html" seamless></iframe>';
|
$("#video .popCon").html(html);
|
$("#device-name").text(name);
|
layer.open({
|
skin: 'mypop',
|
type: 1,
|
title: false,
|
area: ['100%', '100%'],
|
closeBtn: 0,
|
shade: 0,
|
scrollbar: false,
|
content: $('#video')
|
});
|
return;
|
}
|
// console.log("===================跳转==================");
|
// console.log("url="+url);
|
// var url = "./warn-list.html?id=999&category=" + category;
|
console.log("name="+name+",url="+url);
|
window.parent.openTab(url, name + "", deviceId)
|
});
|
|
//添加图标的事件--鼠标悬停事件
|
$(".tip").mouseenter(function () {
|
var id = $(this).attr("id");
|
var category = $(this).attr("category");
|
if(category == "3004"){
|
return ;
|
}
|
if(id != "th"){
|
var name = $(this).attr("name");
|
var index = $(this).attr("index");
|
|
var device = listDevice[index];
|
|
category = device.category;
|
var record = device.value;
|
|
var temp = addCurDataInfo(category,record);
|
|
layer.open({
|
type: 1
|
,title: '当前设备:' + name
|
,skin: 'skin-class'
|
,area: ['300px']
|
,shade: 0//不遮拦
|
,offset: ['0px','83%']//左上角显示
|
,moveType: 0 //拖拽模式,0或者1
|
,content: temp
|
});
|
}
|
|
// console.log(listDevice[index]);
|
});
|
|
|
|
//添加图标的事件--鼠标离开事件
|
$(".tip").mouseleave(function () {
|
var id = $(this).attr("id");
|
var name = $(this).attr("name");
|
var index = $(this).attr("index");
|
var category = $(this).attr("category");
|
if (category != CATEGORY.D3004.code) {
|
layer.closeAll();
|
}
|
|
});
|
};
|
|
function addhtml(parent,i){
|
console.log("添加露点设备信息");
|
i++;
|
var parentWidth = parent.width();
|
var parentHeight = parent.height();
|
|
var left = (parentWidth * thData1.leftV).toFixed(4);
|
var top = (parentHeight * thData1.topV).toFixed(4);
|
|
var recordMap1 = thData1.value;//设备监控属性集合
|
var recordMap2 = thData2.value;
|
|
var value1 = "00.0",value2 = "00.0";
|
$.each(recordMap1,function (index,item) {
|
if (item.passcode == "3") {
|
value1 = item.value;
|
}
|
});
|
$.each(recordMap2,function (index,item) {
|
if (item.passcode == "3") {
|
value2 = item.value;
|
}
|
});
|
value1 = parseFloat(value1).toFixed(1);
|
value2 = parseFloat(value2).toFixed(1);
|
var temp = "";
|
temp += "<div id='th' class='tip arrow_box_1' style='left:" + left+ "px;top:" + top + "px;' index='" + i + "'>";
|
temp += "<div class = 'div-c'>";
|
temp += "</div>";
|
temp += "<div class = 'div-d' style='font-size: 14px;'><p style='margin-left: 2%;margin-bottom: 5px;'><span>露点温度1</span><span style='margin-left: 10%;'>露点温度2</span></p>" +
|
"<p style='margin-left: 2%;'><span style='margin-left: 1%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>" + value1 +"℃</span>" +
|
"<span style='margin-left: 15%;background-color: rgba(21, 221, 86, 1);padding: 0% 5%;'>" + value2 +"℃</span></div>";
|
temp += "</div>";
|
|
//删除原有元素,在进行追加
|
$("#th").remove();
|
parent.append(temp);
|
}
|
|
|
//使各Tip支持拖拽
|
function editTips() {
|
|
layer.confirm('进行设备拖拽时将会暂停设备数据的实时刷新,是否继续?', function (index) {
|
layer.close(index);
|
// 首先停止执行原有的循环
|
// 循环体中包括设备位置和数据,进行拖拽要暂停数据的自动刷新
|
if (intervalData) clearInterval(intervalData);
|
|
//获取可以移动的范围,默认就是当前页面
|
var maxY = $(document.body).height();
|
var maxX = $(document.body).width();
|
|
var tips = $(".tip");
|
if (tips.length == 0) {
|
return;
|
}
|
$.each(tips, function (index, item) {
|
var dd = new Dragdrop({
|
target: item,
|
area: [0, maxX, 0, maxY],
|
callback: function (obj) {
|
//console.log('left:' + (obj.moveX) + ' top:' + (obj.moveY));
|
}
|
});
|
dd.dragAll();
|
});
|
|
});
|
};
|
|
//--保存位置信息,保存时候调整为相对于当前parent的位置保存
|
function saveTips() {
|
var tips = $(".tip");
|
if (tips.length == 0) {
|
return;
|
}
|
var parent = $("#img-main");
|
var parentWidth = parent.width();
|
var parentHeight = parent.height();
|
var parentLeft = parent.offset().left, parentTop = parent.offset().top;
|
|
//封装数据进行保存
|
var data = new Array();
|
var id = null;
|
var offset;
|
var left = 0, top = 0;
|
$.each(tips, function (index, item) {
|
id = item.id;
|
offset = $('#' + id).offset();
|
var category = $('#' + id).attr("category");
|
|
left = (offset.left - parentLeft) / parentWidth;
|
top = (offset.top - parentTop) / parentHeight;
|
|
data[index] = {
|
deviceId: id,
|
leftV: left.toFixed(4),
|
topV: top.toFixed(4)
|
};
|
|
// if(thData1 && thData2){
|
// if(id==thData1.id || id==thData2.id){
|
// offset = $('#th').offset();
|
//
|
// left = (offset.left - parentLeft) / parentWidth;
|
// top = (offset.top - parentTop) / parentHeight;
|
// }
|
// }
|
//
|
// if(id != "th"){
|
// data[index] = {
|
// deviceId: id,
|
// leftV: left.toFixed(4),
|
// topV: top.toFixed(4)
|
// };
|
// }
|
});
|
// console.log(data);
|
|
var param = data;
|
console.log("-------保存设备位置信息,发送的数据------");
|
console.log(param);
|
//执行保存
|
$.post("./cgi-bin/device-place/save", JSON.stringify(param), function (data, status) {
|
if (data.code == "success") {
|
layer.closeAll();
|
layer.msg("数据保存成功!");
|
window.parent.notify("数据保存成功!");
|
} else {
|
window.parent.notify("数据保存出错,请重新操作!"+data.msg+"!");
|
}
|
if (status == "success") {
|
layer.closeAll();
|
layer.msg("数据保存成功!");
|
window.parent.notify("数据保存成功!");
|
} else {
|
window.parent.notify("数据保存出错,请重新操作!"+data.msg+"!");
|
}
|
|
}, "json");
|
|
};
|
|
function updateImg() {
|
layer.confirm("是否更换2.5D图片?", function (index) {
|
$("#image").click();
|
layer.close(index);
|
});
|
|
|
}
|
|
function toBase64() {
|
var file = document.querySelector('input[type=file]').files[0];
|
var fileSize = file.size;
|
// console.log(fileSize);
|
if(fileSize > 1024 * 1024 ){
|
window.parent.notify("上传的图片大小不得大于1M!");
|
return ;
|
}
|
var reader = new FileReader();
|
reader.onloadend = function () {
|
imgData = reader.result;
|
uploadImg(imgData);
|
// $("#img-three").attr("src", reader.result);
|
// console.log(reader.result);
|
}
|
if (file) {
|
reader.readAsDataURL(file);
|
}
|
}
|
//上传图片Base64码
|
function uploadImg(imgData) {
|
var param = {data:imgData};
|
// console.log("-------保存2.5D图,发送的数据------");
|
// console.log(param);
|
//执行保存
|
$.ajaxSettings.async = false;
|
$.post("./cgi-bin/img-data/save", JSON.stringify(param), function (data, status) {
|
if (data.code == "success") {
|
layer.closeAll();
|
window.parent.notify("图片保存成功!");
|
|
} else {
|
window.parent.notify("图片保存出错,请重新操作!"+data.msg+"!");
|
}
|
}, "json");
|
renderImg();
|
}
|
|
/**
|
* 不同的设备显示不同的信息,部分设备不显示设备信息
|
*
|
* 返回信息是一个MAP,包含两个信息,一个是CODE,一个是值
|
*/
|
function addCurData(category, record, warnState,device) {
|
var recordMap = [];
|
if(record){
|
for(var i=0;i<record.length;i++){
|
recordMap[record[i].passcode] = record[i];
|
}
|
}
|
var result = {code: "FULL", htm: ""};
|
var temp = "";
|
//温湿度-只显示温度和湿度
|
if (category == CATEGORY.D2001.code) {
|
if(recordMap){
|
if(recordMap[1] && recordMap[1].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}else{
|
if(recordMap[2] && recordMap[2].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>报警</span></p>";
|
}else{
|
temp += "<div class = 'div-d'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>正常</span></p>";
|
}
|
if (recordMap[3]) {
|
temp += "<p><span> 温 度:" + recordMap[3].value + "℃</span></p>";
|
}
|
if (recordMap[4]) {
|
temp += "<p><span> 湿 度:" + recordMap[4].value + "%</span></p>";
|
}
|
}
|
}else{
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}
|
temp += "</div>";
|
result.htm = temp;
|
return result;
|
}
|
//精密空调
|
if (category == CATEGORY.D2002.code) {
|
if(recordMap){
|
if(recordMap[1] && recordMap[1].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}else{
|
if(recordMap[2] && recordMap[2].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>报警</span></p>";
|
}else{
|
temp += "<div class = 'div-d'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>正常</span></p>";
|
}
|
if (recordMap[6]) {
|
temp += "<p><span>设定温度:" + recordMap[7].value + "℃</span></p>";
|
}
|
if (recordMap[6]) {
|
temp += "<p><span>设定湿度:" + recordMap[7].value + "%</span></p>";
|
}
|
}
|
}else{
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}
|
temp += "</div>";
|
result.htm = temp;
|
return result;
|
}
|
//普通空调
|
if (category == CATEGORY.D2003.code) {
|
if(recordMap){
|
if(recordMap[1] && recordMap[1].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}else{
|
if(recordMap[2] && recordMap[2].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>报警</span></p>";
|
}else{
|
temp += "<div class = 'div-d'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>正常</span></p>";
|
}
|
if (recordMap[3]) {
|
temp += "<p><span>设定温度:" + recordMap[3].value + "℃</span></p>";
|
}
|
if (recordMap[4]) {
|
temp += "<p><span>设定湿度:" + recordMap[4].value + "%</span></p>";
|
}
|
}
|
}else{
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}
|
temp += "</div>";
|
result.htm = temp;
|
return result;
|
}
|
//电池
|
if (category == CATEGORY.D1005.code) {
|
if(recordMap){
|
if(recordMap[1] && recordMap[1].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}else{
|
if(recordMap[2] && recordMap[2].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>报警</span></p>";
|
}else{
|
temp += "<div class = 'div-d'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
// temp += "<p><span>正常</span></p>";
|
}
|
if (recordMap[125]) {
|
temp += "<p><span>总 电 压:" + recordMap[125].value + "</span></p>";
|
}
|
if (recordMap[124]) {
|
temp += "<p><span>总 电 流:" + recordMap[124].value + "</span></p>";
|
}
|
// if (recordMap[3]) {
|
// temp += "<p><span>电池个数:" + recordMap[3].value + "</span></p>";
|
// }
|
// if (recordMap[126]) {
|
// temp += "<p><span>后备时间:" + recordMap[126].value + "</span></p>";
|
// }
|
}
|
}else{
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}
|
temp += "</div>";
|
// temp += "</marquee>";
|
result.htm = temp;
|
return result;
|
}
|
if(category == CATEGORY.D3001.code){
|
temp += "<div class = 'div-d'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "</div>";
|
result.htm = temp;
|
result.code = "EMPTY";
|
return result;
|
}
|
|
if(category == CATEGORY.D3004.code){
|
temp += "<div class = 'div-d'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "</div>";
|
result.htm = temp;
|
result.code = "EMPTY";
|
return result;
|
}
|
|
if(category == CATEGORY.D2005.code || category == CATEGORY.D3002.code
|
|| category == CATEGORY.D3003.code){
|
if(recordMap){
|
if(recordMap[1] && recordMap[1].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}else{
|
if(recordMap[2] && recordMap[2].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>报警</span></p>";
|
}else{
|
temp += "<div class = 'div-d'>";
|
// temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>正常</span></p>";
|
}
|
}
|
}else{
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}
|
temp += "</div>";
|
result.htm = temp;
|
result.code = "EMPTY";
|
return result;
|
}
|
|
//没有专门的显示,调整父DIV的大小
|
if(recordMap){
|
if(recordMap[1] && recordMap[1].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}else{
|
if(recordMap[2] && recordMap[2].value == 1){
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>报警</span></p>";
|
}else{
|
temp += "<div class = 'div-d'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>正常</span></p>";
|
}
|
}
|
}else{
|
temp += "<div class = 'div-d font-warn'>";
|
temp += "<p><span>"+device.name+"</span></p>";
|
temp += "<p><span>通讯异常</span></p>";
|
}
|
temp += "</div>";
|
result.htm = temp;
|
result.code = "EMPTY";
|
return result;
|
|
}
|
|
/**
|
* 不同设备显示不同的图标
|
* @param category
|
* @returns {String}
|
*/
|
function addCurImg(category) {
|
//温湿度
|
if (category == CATEGORY.D2001.code) {
|
return "<img src='images/icon-ht@64.png'/>";
|
}
|
//电表
|
if (category == CATEGORY.D1003.code) {
|
return "<img src='images/icon-db@100.png'/>";
|
}
|
//配电柜
|
if (category == CATEGORY.D1004.code) {
|
return "<img src='images/icon-ups@64.png'/>";
|
}
|
//UPS-三相
|
if (category == CATEGORY.D1002.code) {
|
return "<img src='images/icon-ups@64.png'/>";
|
}
|
//UPS-单向
|
if (category == CATEGORY.D1001.code) {
|
return "<img src='images/icon-ups@64.png'/>";
|
}
|
//门禁
|
if (category == CATEGORY.D3001.code) {
|
return "<img src='images/icon-mj@64.png'/>";
|
}
|
//精密空调
|
if (category == CATEGORY.D2002.code) {
|
return "<img src='images/img-kt.png'/>";
|
}
|
//普通空调
|
if (category == CATEGORY.D2003.code) {
|
return "<img src='images/img-kt2.png'/>";
|
}
|
//风机
|
if (category == CATEGORY.D2004.code) {
|
return "<img src='images/icon-fj.png'/>";
|
}
|
//红外
|
if (category == CATEGORY.D3003.code) {
|
return "<img src='images/icon-hw@100.png'/>";
|
}
|
//漏水
|
if (category == CATEGORY.D2005.code) {
|
return "<img src='images/icon-ls@100.png'/>";
|
}
|
//烟感
|
if (category == CATEGORY.D3002.code) {
|
return "<img src='images/icon-yg@100.png'/>";
|
}
|
//电池
|
if (category == CATEGORY.D1005.code) {
|
return "<img src='images/icon-dc@64.png'/>";
|
}
|
//视频
|
if (category == CATEGORY.D3004.code) {
|
return "<img src='images/icon-device-sp.png'/>";
|
}
|
|
return "<img src='images/icon-common@64.png'/>";
|
};
|
|
|
|
function addCurDataInfo(category,record){
|
var recordMap = [];
|
$.each(record,function (index,item) {
|
recordMap[item.passcode] = item;
|
});
|
|
var temp = "";
|
//UPS-单向
|
if (category == CATEGORY.D1001.code) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
if (item.passcode == "3")temp += "<p><span>输入电压:" + item.value + "V</span></p>";
|
if (item.passcode == "4")temp += "<p><span>输入电流:" + item.value + "A</span></p>";
|
if (item.passcode == "5")temp += "<p><span>输出电压:" + item.value + "V</span></p>";
|
if (item.passcode == "6")temp += "<p><span>输出电流:" + item.value + "A</span></p>";
|
if (item.passcode == "13")temp += "<p><span>电池剩余:" + item.value + "%</span></p>";
|
});
|
|
temp += "<p><span></span></p>";
|
}else{
|
temp += "<p><span>暂无数据</span></p>";
|
}
|
temp += "</div>";
|
return temp;
|
}
|
//UPS-三相
|
if (category == CATEGORY.D1002.code) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
if (item.passcode == "3")temp += "<p><span>A相输入电压:" + item.value + "V</span></p>";
|
if (item.passcode == "4")temp += "<p><span>B相输入电压:" + item.value + "V</span></p>";
|
if (item.passcode == "5")temp += "<p><span>C相输入电压:" + item.value + "V</span></p>";
|
if (item.passcode == "6")temp += "<p><span>A相输入电流:" + item.value + "A</span></p>";
|
if (item.passcode == "7")temp += "<p><span>B相输入电流:" + item.value + "A</span></p>";
|
if (item.passcode == "8")temp += "<p><span>C相输入电流:" + item.value + "A</span></p>";
|
if (item.passcode == "9")temp += "<p><span>A相输出电压:" + item.value + "V</span></p>";
|
if (item.passcode == "10")temp += "<p><span>B相输出电压:" + item.value + "V</span></p>";
|
if (item.passcode == "11")temp += "<p><span>C相输出电压:" + item.value + "V</span></p>";
|
if (item.passcode == "12")temp += "<p><span>A相输出电流:" + item.value + "A</span></p>";
|
if (item.passcode == "13")temp += "<p><span>B相输出电流:" + item.value + "A</span></p>";
|
if (item.passcode == "14")temp += "<p><span>C相输出电流:" + item.value + "A</span></p>";
|
if (item.passcode == "23")temp += "<p><span>电池剩余:" + (item.value?item.value : "#") + "%</span></p>";
|
});
|
temp += "<p><span></span></p>";
|
}else{
|
temp += "<p><span>暂无数据</span></p>";
|
}
|
temp += "</div>";
|
return temp;
|
}
|
//电表
|
if (category == CATEGORY.D1003.code) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
if (item.passcode == "3")temp += "<p><span> A相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "4")temp += "<p><span> B相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "5")temp += "<p><span> C相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "6")temp += "<p><span> A相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "7")temp += "<p><span> B相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "8")temp += "<p><span> C相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "16")temp += "<p><span> 频率:" + item.value + "Hz</span></p>";
|
});
|
temp += "<p><span></span></p>";
|
}else{
|
temp += "<p><span>暂无数据</span></p>";
|
}
|
temp += "</div>";
|
return temp;
|
}
|
//电表
|
if (category == CATEGORY.D1004.code) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span> 告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
if (item.passcode == "3")temp += "<p><span> 1#A相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "4")temp += "<p><span> 1#B相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "5")temp += "<p><span> 1#C相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "6")temp += "<p><span> 1#A相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "7")temp += "<p><span> 1#B相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "8")temp += "<p><span> 1#C相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "16")temp += "<p><span> 1#频率:" + item.value + "Hz</span></p>";
|
if (item.passcode == "20")temp += "<p><span> 2#A相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "21")temp += "<p><span> 2#B相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "22")temp += "<p><span> 2#C相电压:" + item.value + "V</span></p>";
|
if (item.passcode == "23")temp += "<p><span> 2#A相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "24")temp += "<p><span> 2#B相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "25")temp += "<p><span> 2#C相电流:" + item.value + "A</span></p>";
|
if (item.passcode == "33")temp += "<p><span> 2#频率:" + item.value + "Hz</span></p>";
|
});
|
temp += "<p><span></span></p>";
|
}else{
|
temp += "<p><span>暂无数据</span></p>";
|
}
|
temp += "</div>";
|
return temp;
|
}
|
//电池
|
if (category == CATEGORY.D1005.code) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
if (item.passcode == "3")temp += "<p><span>电池个数:" + item.value + "</span></p>";
|
if (item.passcode == "124")temp += "<p><span>总 电 流:" + item.value + "A</span></p>";
|
if (item.passcode == "125")temp += "<p><span>总 电 压:" + item.value + "V</span></p>";
|
if (item.passcode == "126")temp += "<p><span>后备时间:" + item.value + "小时</span></p>";
|
});
|
}else{
|
temp += "<p><span>暂无数据</span></p>";
|
}
|
temp += "</div>";
|
return temp;
|
}
|
//精密空调
|
if (category == CATEGORY.D2002.code) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
if (item.passcode == "3")temp += "<p><span>运行状态:" + item.value + "</span></p>";
|
if (item.passcode == "4")temp += "<p><span>室内温度:" + item.value + "℃</span></p>";
|
if (item.passcode == "5")temp += "<p><span>室内湿度:" + item.value + "%</span></p>";
|
if (item.passcode == "6")temp += "<p><span>设定温度:" + item.value + "℃</span></p>";
|
if (item.passcode == "7")temp += "<p><span>设定湿度:" + item.value + "%</span></p>";
|
});
|
}
|
temp += "</div>";
|
return temp;
|
}
|
//普通空调
|
if (category == CATEGORY.D2003.code) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "999")temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
if (item.passcode == "3")temp += "<p><span>设定温度:" + item.value + "℃</span></p>";
|
if (item.passcode == "4")temp += "<p><span>设定湿度:" + item.value + "%</span></p>";
|
});
|
}else{
|
temp += "<p><span>暂无数据</span></p>";
|
}
|
temp += "</div>";
|
return temp;
|
}
|
//漏水、红外、烟感
|
if (category == CATEGORY.D2005.code || category == CATEGORY.D3002.code || category == CATEGORY.D3003.code ) {
|
temp += "<div class = 'div-temp'>";
|
if (record) {
|
$.each(record,function (index,item) {
|
if (item.passcode == "1")temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
if (item.passcode == "2")temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
});
|
}else{
|
temp += "<p><span>暂无数据</span></p>";
|
}
|
temp += "</div>";
|
return temp;
|
}
|
|
if (record) {
|
temp += "<div class = 'div-temp'>";
|
$.each(record, function (index, item) {
|
if (item.passcode == "1"){
|
temp += "<p><span>通讯状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
}else if (item.passcode == "2"){
|
temp += "<p><span>告警状态:" + (item.value==0?"正常":"告警") + "</span></p>";
|
}else if(item.passcode == "999"){
|
temp += "<p><span>告警内容:" + (item.value?item.value:"无告警") + "</span></p>";
|
}else{
|
temp += "<p><span>" + item.name + ":" + item.value + "</span></p>";
|
}
|
});
|
temp += "</div>";
|
}else{
|
temp += "<div class = 'div-temp'>";
|
temp += "<p><span>暂无数据</span></p>";
|
temp += "</div>";
|
}
|
|
return temp;
|
|
|
|
}
|