var layer; var form; var deviceList;// 当前仓库的所有设备列表 var depotId; var deviceType = DeviceType.TYPE_01;// 被选中的设备类型,默认是通风窗 var viewTargetStatus;// 目标状态,根据设备类型和当前值调用动效 var domSelectDevice;// 被选中的设备dom对象 $(function () { layui.use(['layer', 'form'], function () { form = layui.form; layer = layui.layer; form.render(); // 监听仓库选择 form.on('select(select_depotId)', function (obj) { return query(true, true, true); }); //初始化刷新数据 initData(); }); // 添加切换动作 $(".js-tf-btn").click( function () { $(this).addClass("active").siblings(".js-tf-btn").removeClass( "active"); }); $(".js-xg115-arrow").click(function () { $(this).siblings(".xg115-btnhide").toggle(); $(this).toggleClass("active"); }); }); function initData() { if (depotId) { $("#depotId").val(depotId); query(true, true, true); form.render(); } } /** * 检测仓库类型是否发生改变,如果发生改变,重新切换页面 */ function onDepotChange(obj) { var depotType = obj.elem[obj.elem.selectedIndex].getAttribute('type'); if (depotType == DEPOT_TYPE) { query(true, true, true); } else { changeView(depotType); } } function changeView(depotType) { depotId = $("#depotId").val(); window.location.href = "./gateway?depotId=" + depotId + "&depotType=" + depotType; return true; } /** 视频查看直接跳转到视频概览页面**/ function showVideo() { window.parent.openTab("./basic/security/aerial-video?t=1", "视频鸟瞰", "aerial-video"); }; function closeAll() { layer.msg("终端不支持当前功能……"); }; // 状态查询 function queryStatus() { depotId = $("#depotId").val(); if (!depotId) { layer.msg("请先选择仓库!"); return; } //把当前页面的设备传递到后台 var data = { deptId: deptId, depotId: depotId, deviceList: [] }; var tips = $(".device"); $.each(tips, function (index, item) { data.deviceList.push({ id: item.id, depotId: item.getAttribute("depotid"), passCode: item.getAttribute("passcode"), name: item.getAttribute("name"), serId: item.getAttribute("serid"), link: item.getAttribute("link"), type: item.getAttribute("type"), companyId: companyId }); }); $.ajax({ type: "POST", url: "../../basic/verb/query-status", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(data), success: function (result) { if ("ORDER_SUCCESS" != result.code) { layer.msg(result.msg); } }, error: function (result) { layer.msg("获取数据失败,请重新尝试!"); } }); }; /** * @param isNew 是否新库跟新仓库信息并执行状态刷新 * @param isCut 是否切换页面 * @param isQueryStatus 是否更新状态 */ function query(isNew, isCut, isQueryStatus) { depotId = $("#depotId").val(); if (!depotId) { layer.msg("请先选择仓库!"); return; } if (isNew) { updateGrainInfo(); } deviceList = [{"companyId":"5303","depotId":"P0101","id":"53030P190220_1001","link":"3001","location":"01","locationName":"02-背面","name":"轴流窗#1","passCode":1001,"posX":797,"posY":217,"serId":"20","status":"F_OPEN","statusName":"风机正转","type":"02","typeName":"02-轴流风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1002","link":"3002","location":"01","locationName":"02-背面","name":"轴流窗#2","passCode":1002,"posX":557,"posY":216,"serId":"20","status":"W_OPEN","statusName":"风口开","type":"02","typeName":"02-轴流风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1003","location":"01","locationName":"01-正面","name":"通风窗#3","passCode":1003,"posX":932,"posY":220,"serId":"20","status":"CLOSE","statusName":"关闭","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1004","location":"01","locationName":"01-正面","name":"通风窗#4","passCode":1004,"posX":999,"posY":221,"serId":"20","status":"CLOSE","statusName":"关闭","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1005","location":"01","locationName":"01-正面","name":"通风窗#5","passCode":1005,"posX":722,"posY":217,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1006","location":"01","locationName":"01-正面","name":"通风窗#6","passCode":1006,"posX":638,"posY":218,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1007","location":"01","locationName":"01-正面","name":"通风窗#7","passCode":1007,"posX":380,"posY":214,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1008","location":"01","locationName":"01-正面","name":"通风窗#8","passCode":1008,"posX":284,"posY":212,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1011","link":"3001","location":"02","locationName":"02-背面","name":"轴流窗#1","passCode":1011,"posX":927,"posY":219,"serId":"20","status":"F_OPEN","statusName":"风机正转","type":"02","typeName":"02-轴流风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1012","link":"3002","location":"02","locationName":"02-背面","name":"轴流窗#2","passCode":1012,"posX":386,"posY":213,"serId":"20","status":"W_OPEN","statusName":"风口开","type":"02","typeName":"02-轴流风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1013","location":"02","locationName":"01-正面","name":"通风窗#3","passCode":1013,"posX":804,"posY":218,"serId":"20","status":"CLOSE","statusName":"关闭","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1014","location":"02","locationName":"01-正面","name":"通风窗#4","passCode":1014,"posX":999,"posY":218,"serId":"20","status":"CLOSE","statusName":"关闭","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1015","location":"02","locationName":"01-正面","name":"通风窗#5","passCode":1015,"posX":722,"posY":219,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1016","location":"02","locationName":"01-正面","name":"通风窗#6","passCode":1016,"posX":641,"posY":217,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1017","location":"02","locationName":"01-正面","name":"通风窗#7","passCode":1017,"posX":562,"posY":217,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_1018","location":"02","locationName":"01-正面","name":"通风窗#8","passCode":1018,"posX":284,"posY":212,"serId":"20","status":"OPEN","statusName":"打开","type":"01","typeName":"01-风窗"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2001","link":"4002","location":"01","locationName":"未配置","name":"通风口#1","passCode":2001,"posX":937,"posY":358,"serId":"20","status":"W_OPEN","statusName":"风口开","type":"0C","typeName":"0C-混流风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2002","link":"4003","location":"01","locationName":"未配置","name":"通风口#2","passCode":2002,"posX":393,"posY":382,"serId":"20","status":"W_OPEN","statusName":"风口开","type":"0C","typeName":"0C-混流风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2003","location":"01","locationName":"未配置","name":"通风口#3","passCode":2003,"posX":998,"posY":356,"serId":"20","status":"CLOSE","statusName":"关闭","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2004","location":"01","locationName":"未配置","name":"通风口#4","passCode":2004,"posX":574,"posY":375,"serId":"20","status":"CLOSE","statusName":"关闭","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2005","location":"01","locationName":"未配置","name":"通风口#5","passCode":2005,"posX":730,"posY":368,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2006","location":"01","locationName":"未配置","name":"通风口#6","passCode":2006,"posX":802,"posY":364,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2007","location":"01","locationName":"未配置","name":"通风口#7","passCode":2007,"posX":651,"posY":369,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2008","location":"01","locationName":"未配置","name":"通风口#8","passCode":2008,"posX":295,"posY":382,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2011","link":"4002","location":"02","locationName":"未配置","name":"通风口#1","passCode":2011,"posX":795,"posY":364,"serId":"20","status":"W_OPEN","statusName":"风口开","type":"0C","typeName":"0C-混流风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2012","link":"4003","location":"02","locationName":"未配置","name":"通风口#2","passCode":2012,"posX":560,"posY":374,"serId":"20","status":"W_OPEN","statusName":"风口开","type":"0C","typeName":"0C-混流风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2013","location":"02","locationName":"未配置","name":"通风口#3","passCode":2013,"posX":281,"posY":384,"serId":"20","status":"CLOSE","statusName":"关闭","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2014","location":"02","locationName":"未配置","name":"通风口#4","passCode":2014,"posX":378,"posY":381,"serId":"20","status":"CLOSE","statusName":"关闭","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2015","location":"02","locationName":"未配置","name":"通风口#5","passCode":2015,"posX":637,"posY":369,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2016","location":"02","locationName":"未配置","name":"通风口#6","passCode":2016,"posX":720,"posY":365,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2017","location":"02","locationName":"未配置","name":"通风口#7","passCode":2017,"posX":924,"posY":355,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_2018","location":"02","locationName":"未配置","name":"通风口#8","passCode":2018,"posX":986,"posY":350,"serId":"20","status":"OPEN","statusName":"打开","type":"0B","typeName":"0B-通风口"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_5001","location":"01","locationName":"04-右侧","name":"环流风机#1","passCode":5001,"posX":492,"posY":262,"serId":"20","status":"CLOSE","statusName":"关闭","type":"04","typeName":"04-环流风机"},{"companyId":"5303","depotId":"P0101","id":"53030P190220_5002","location":"01","locationName":"04-右侧","name":"环流风机#2","passCode":5001,"posX":879,"posY":259,"serId":"20","status":"CLOSE","statusName":"关闭","type":"04","typeName":"04-环流风机"}]; if(isCut){ toCutExe(viewAB,true); } // if (isQueryStatus) { // queryStatus(); // } // $.ajax({ // type: "POST", // url: "../../basic/verb/list-device-manual", // dataType: "json", // contentType: "application/json;charset=UTF-8", // data: JSON.stringify({ // depotId: depotId // }), // success: function (result) { // if (isNew) { // updateGrainInfo(); // } // // if (result.code != "0000") { // layer.msg(result.msg); // deviceList = null; // if(isCut){ // toCutExe(viewAB,true); // } // return; // } // deviceList = result.data; // if(isCut){ // toCutExe(viewAB,true); // } // if (isQueryStatus) { // queryStatus(); // } // }, // error: function (result) { // layer.msg("获取数据失败,请重新尝试!"); // } // }); }; // 获取当前仓库的最新粮情数据信息 function updateGrainInfo() { $("#tempIn").text("26.6"); $("#humidityIn").text("41"); $("#humidityOut").text("63"); $("#tempOut").text("32.4"); $("#updateTime").text("2025-05-16 09:05"); // $.ajax({ // type: "POST", // url: "../../basic/grain/grain-data", // dataType: "json", // contentType: "application/json;charset=UTF-8", // data: JSON.stringify({ // depotId: depotId, // deptId: deptId, // depotType: DEPOT_TYPE // }), // success: function (result) { // if (result.code != "0000") { // addRedLog(result.msg) // return; // } // var grainData = result.data; // // 更新信息 // $("#tempIn").text(grainData.tempIn <= -100?"--":(grainData.tempIn).toFixed(1)); // $("#humidityIn").text((grainData.humidityIn).toFixed(1)); // $("#humidityOut").text((grainData.humidityOut).toFixed(1)); // $("#tempOut").text(grainData.tempOut <= -100?"--":(grainData.tempOut).toFixed(1)); // $("#updateTime").text(grainData.receiveDate); // }, // error: function (result) { // layer.msg("当前仓库的粮情数据信息获取失败!"); // } // }); }; /** * 切换效果 * @param target 正反面 * @param isCutImg 是否执行切图 */ function toCutExe(target, isCutImg) { // 获取当前仓库效果图 viewAB = target; if (isCutImg) { cutImg(depotId, viewAB); } // 根据设备列表添加原型信息 addDevice(deviceList, viewAB); }; // 手动执行,同时更新状态 function toCut(target) { if(target == "03" || target == "04"){ layer.msg("当前协议未对接!"); return; } toCutExe(target, true); }; // 添加操作日志 function addLog(htmlStr) { var info = $("#areationInfo").html(); $("#areationInfo").html(htmlStr + "
" + info); }; function addRedLog(htmlStr) { var info = $("#areationInfo").html(); $("#areationInfo").html( "" + htmlStr + "
" + info); }; /** * 弹出操作框 */ function showControl(id) { domSelectDevice = $("#" + id); var curDepotId = domSelectDevice.attr("depotid"); // 如果点击的设备不是选择仓库的,不执行 // if (curDepotId != depotId) { // addRedLog("当前所选设备:" + domSelectDevice.attr("name") + "【非所选仓库】"); // return; // } else { // addLog("当前所选设备:" + domSelectDevice.attr("name")); // } addLog("当前所选设备:" + domSelectDevice.attr("name")); // 更新所选择的设备类型 deviceType = domSelectDevice.attr("type"); if (1 == deviceType) deviceType = "01"; if (2 == deviceType) deviceType = "02"; if (3 == deviceType) deviceType = "03"; if (4 == deviceType) deviceType = "04"; var curStatus = domSelectDevice.attr("status"); // 根据设备类型弹出不一样的弹出框 if (DeviceType.TYPE_01 == deviceType) {// 风窗 layer.open({ type: 1, title: '设备操作-' + domSelectDevice.attr("name"), area: ['450px', '210px'], shade: 0, content: $('#control-FC'), btn: 0, closeBtn: 2 }); } if (DeviceType.TYPE_0B == deviceType) {// 通风口 layer.open({ type: 1, title: '设备操作-' + domSelectDevice.attr("name"), area: ['450px', '210px'], shade: 0, content: $('#control-FK'), btn: 0, closeBtn: 2 }); } if (DeviceType.TYPE_0C == deviceType) {// 混流风机 if (null == curStatus || DeviceStatus.W_CLOSE == curStatus) {// 设置风机按钮不可用 disBtnFj(true, "control-HL"); } else { disBtnFj(false, "control-HL"); } layer.open({ type: 1, title: '设备操作-' + domSelectDevice.attr("name"), area: ['450px', '270px'], shade: 0, content: $('#control-HL'), btn: 0, closeBtn: 2 }); } if (DeviceType.TYPE_04 == deviceType) {// 环流风机 layer.open({ type: 1, title: '设备操作-' + domSelectDevice.attr("name"), area: ['450px', '150px'], shade: 0, content: $('#control-HL2'), btn: 0, closeBtn: 2 }); } if (DeviceType.TYPE_02 == deviceType) {// 轴流风机 if (null == curStatus || DeviceStatus.W_CLOSE == curStatus) {// 设置风机按钮不可用 disBtnFj2(true, "control-ZL"); } else { disBtnFj2(false, "control-ZL"); } layer.open({ type: 1, title: '设备操作-' + domSelectDevice.attr("name"), area: ['480px', '270px'], shade: 0, content: $('#control-ZL'), btn: 0, closeBtn: 2 }); } }; // 根据DIV获取所有的按钮,风机的按钮序号是 2-4 function disBtnFj(tag, divId) { var btns = $("#" + divId).find("button"); if (tag) { $(btns[2]).addClass("layui-btn-disabled"); $(btns[2]).addClass("btn-dis"); $(btns[2]).attr("disabled", true); $(btns[3]).addClass("layui-btn-disabled"); $(btns[3]).addClass("btn-dis"); $(btns[3]).attr("disabled", true); $(btns[4]).addClass("layui-btn-disabled"); $(btns[4]).addClass("btn-dis"); $(btns[4]).attr("disabled", true); } else { $(btns[2]).removeClass("layui-btn-disabled"); $(btns[2]).removeClass("btn-dis"); $(btns[2]).attr("disabled", false); $(btns[3]).removeClass("layui-btn-disabled"); $(btns[3]).removeClass("btn-dis"); $(btns[3]).attr("disabled", false); $(btns[4]).removeClass("layui-btn-disabled"); $(btns[4]).removeClass("btn-dis"); $(btns[4]).attr("disabled", false); } }; function disBtnFj2(tag, divId) { var btns = $("#" + divId).find("button"); if (tag) { $(btns[2]).addClass("layui-btn-disabled"); $(btns[2]).addClass("btn-dis"); $(btns[2]).attr("disabled", true); $(btns[3]).addClass("layui-btn-disabled"); $(btns[3]).addClass("btn-dis"); $(btns[3]).attr("disabled", true); } else { $(btns[2]).removeClass("layui-btn-disabled"); $(btns[2]).removeClass("btn-dis"); $(btns[2]).attr("disabled", false); $(btns[3]).removeClass("layui-btn-disabled"); $(btns[3]).removeClass("btn-dis"); $(btns[3]).attr("disabled", false); } }; // 根据操作目标状态和选择的设备进行执行-目标状态 function toExecute(targetStatus) { layer.msg("当前协议未对接!"); return; var batchTag = false; if ("W_OPEN_ALL" == targetStatus) { batchTag = true; targetStatus = DeviceStatus.OPEN; } if ("W_CLOSE_ALL" == targetStatus) { batchTag = true; targetStatus = DeviceStatus.CLOSE; } // 根据设备类型进行调整,针对风机类 if (targetStatus == DeviceStatus.OPEN) { if (deviceType == DeviceType.TYPE_02) targetStatus = DeviceStatus.W_OPEN; if (deviceType == DeviceType.TYPE_0C) targetStatus = DeviceStatus.W_OPEN; } if (targetStatus == DeviceStatus.CLOSE) { if (deviceType == DeviceType.TYPE_02) targetStatus = DeviceStatus.W_CLOSE; if (deviceType == DeviceType.TYPE_0C) targetStatus = DeviceStatus.W_CLOSE; } viewTargetStatus = targetStatus; var data = { depotId: depotId, deptId: deptId, batchTag: batchTag, deviceType: deviceType, targetStatus: targetStatus, deviceList: [] }; // 批量设备操作,只处理相同的设备类型 if (batchTag) { data.deviceList = deviceList; } else { data.deviceList.push({ id: domSelectDevice.id, depotId: domSelectDevice.attr("depotid"), passCode: domSelectDevice.attr("passcode"), name: domSelectDevice.attr("name"), serId: domSelectDevice.attr("serid"), link: domSelectDevice.attr("link"), type: domSelectDevice.attr("type"), targetStatus: targetStatus }); } // 开始调用后台执行 layer.load(1); $.ajax({ type: 'POST', url: "../../basic/verb/control-device", dataType: 'JSON', contentType: "application/json;charset=UTF-8", data: JSON.stringify(data), success: function (result) { layer.closeAll(); if (result.code != "ORDER_SUCCESS") { layer.msg("执行失败:" + result.msg); } else { layer.msg("操作指令发送成功,待终端响应……"); } }, error: function (result) { layer.closeAll(); layer.msg("操作发生异常,暂时无法解决!!"); } }); };