var layer; var form; var viewAB = "01";//01-正面 var curTask; var myChart1; var myChart2; var myChart3; var option1; var option2; var option3; /** * 气调动作 * 01-抽负压 * 02-排气 * 03-充氮 * 04-均氮 * 30-气密性检测 */ var MODE_TAG = { TAG_01: "01", TAG_02: "02", TAG_03: "03", TAG_04: "04", TAG_30: "30" }; $(function () { layui.use(['layer', 'form'], function () { form = layui.form; layer = layui.layer; // 监听仓库选择 form.on('select(select_depotId)', function (obj) { return onDepotChange(obj); }); initChart(); // flushN2Mac(); }); // 添加切换动作 $(".js-tf-btn").click( function () { $(this).addClass("active").siblings(".js-tf-btn").removeClass( "active"); }); }); //socket信息返回處理 function socketOnMessage(pocket) { }; // 按钮事件切换正反面 function toCut(target) { viewAB = target; depotId = $("#depotId").val(); if (!depotId) { layer.alert("请选择仓库"); return; } var imgPath = "../../img/dzhwk/n2/3_box_00.png"; if (target == "02") { imgPath = "../../img/dzhwk/n2/3_box_01.gif"; } //根据任务调整图片 if (curTask) { imgPath = imgPath.replace(imgName, imgName.substr(0, 1) + "box_" + curTask.modeTag + ".gif"); } $("#n2_box_img").attr("src", imgPath); }; //切换仓库,判断仓库类型,刷新当前仓库最新气体检测信息 function onDepotChange(obj) { var selectDepotType = obj.elem[obj.elem.selectedIndex].getAttribute('type'); if (selectDepotType == depotType) { renderInfo(); renderStatus(); toCut(viewAB); } else { changeView(selectDepotType); } }; /** * 选择仓库后更新当前仓库的状态,主要是气调状态 */ function renderStatus() { depotId = $("#depotId").val(); layer.load(1); var param = { companyId: companyId, deptId: deptId, depotId: depotId }; $.ajax({ type: "POST", url: "../../basic/n2/query-task-status", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(param), success: function (result) { layer.closeAll(); console.log(result); if (result.code == "0000") { curTask = result.data; $("#text_status").text(curTask.autoName); } else { layer.msg("没有获取到当前仓库气调相关状态"); } }, error: function () { layer.closeAll(); layer.msg("没有获取到当前仓库气调相关状态"); } }); } /** * 选择仓库后相关信息更新 */ function renderInfo() { depotId = $("#depotId").val(); layer.load(1); var param = { companyId: companyId, deptId: deptId, depotId: depotId }; $.ajax({ type: "POST", url: "../../basic/gas/flush-gas-depot", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(param), success: function (result) { layer.closeAll(); if (result.code == "0000") { if (result.data.perN2 > 0) { $("#text_checkDate").text(result.data.receiveDate); $("#text_n2Max").text(result.data.perN2Max); $("#text_n2Min").text(result.data.perN2Min); $("#text_n2Ave").text(result.data.perN2); $("#text_pressure").text(result.data.pressure); } //仓库信息 if (result.data.depotData) { $("#text_foodVariety").text(result.data.depotData.foodVarietyName); $("#text_storeKeeper").text(result.data.depotData.storeKeeperName); } } else { layer.msg("没有获取到当前仓库气体检测信息"); } }, error: function (result) { layer.closeAll(); layer.msg("没有获取到当前仓库气体检测信息"); } }); } //企业页面 function changeView(selectDepotType) { //类型改变,自动切换页面 if (socket) { socket.close(); } depotId = $("#depotId").val(); window.location.href = "../../basic/n2/gateway?depotId=" + depotId + "&depotType=" + selectDepotType + "&deptId=" + deptId; } /** 视频查看直接跳转到视频概览页面**/ function showVideo() { window.parent.openTab("./basic/security/aerial-video?t=1", "视频鸟瞰", "aerial-video"); }; //刷新制氮机信息 function flushN2Mac() { var param = { companyId: companyId, deptId: deptId }; $.ajax({ type: "POST", url: "../../basic/n2/get-mac", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(param), success: function (result) { if (result.code == "0000") { renderMac(result.data); } else { layer.alert("没有获取到制氮机信息"); } }, error: function (result) { layer.alert("没有获取到制氮机信息"); } }); } function renderMac(macData) { if (!macData) { layer.alert("没有获取到制氮机信息"); return; } $("#mac_name").text("制氮机#" + macData.name); if ("Y" == macData.runStatus) { $("#mac_runStatus").text("开启"); $("#mac_img").attr("src", "../../static/img/dzhwk/n2/mac.gif"); } if ("N" == macData.runStatus) { $("#mac_runStatus").text("关闭"); $("#mac_img").attr("src", "../../static/img/dzhwk/n2/mac.png"); } if (macData.purity) { option1.title[0].text = macData.purity + "%"; myChart1.setOption(option1); } if (macData.pressure) { option2.title[0].text = macData.pressure + "bar"; myChart2.setOption(option2); } if (macData.flow) { option3.title[0].text = macData.flow + "Nm³/h"; myChart3.setOption(option3); } } /** * 根据动作标签执行气调动作 * * @param modeTag */ function doExe(modeTag) { layer.msg("暂未对接设备!"); return; depotId = $("#depotId").val(); if (!depotId) { layer.alert("请选择仓库"); return; } var param = { depotId: depotId, modeTag: modeTag, companyId: companyId, deptId: deptId }; layer.load(1); $.ajax({ type: "POST", url: "../../basic/n2/run-auto", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(param), success: function (result) { layer.closeAll(); if (result.code == "ORDER_SUCCESS") { addTextStatus(modeTag, null); } else { layer.alert(result.msg); } }, error: function (result) { layer.closeAll(); layer.alert("执行失败:" + result.msg); } }); } /** * 标记当前仓库状态 * @param modeTag 如果有标记则根据标记执行 * @param msg 如果有信息则直接显示信息 */ function addTextStatus(modeTag, msg) { if (msg) { $("#text_status").text(msg); } else { if (modeTag) { if (MODE_TAG.TAG_01 == modeTag) { msg = "抽负压执行中……" } if (MODE_TAG.TAG_02 == modeTag) { msg = "排气执行中……" } if (MODE_TAG.TAG_03 == modeTag) { msg = "充氮执行中……" } if (MODE_TAG.TAG_04 == modeTag) { msg = "均氮执行中……" } if (MODE_TAG.TAG_30 == modeTag) { msg = "气密性检测执行中……" } $("#text_status").text(msg); } } } //弹出制氮机控制窗口,直接用一个新页面 function showMacControl() { layer.msg("暂未对接设备!"); return; layer.open({ type: 2, title: "制氮机远程操作", area: ['485px', '210px'], shade: 0, content: "../../basic/n2/mac-control", btn: 0, closeBtn: 2 }); } //初始化图表 function initChart() { myChart1 = echarts.init(document.getElementById('chart1')); myChart2 = echarts.init(document.getElementById('chart2')); myChart3 = echarts.init(document.getElementById('chart3')); var getmax = 100; var getvalue = 98; option1 = { tooltip: [], title: [{ text: '99%', top: '45%', x: 'center', textStyle: { fontSize: 14, color: '#000' } }, { text: '氮气纯度', top: '62%', x: 'center', textStyle: { fontSize: 14, color: '#000' } }], angleAxis: { show: false, max: getmax * 360 / 250, //-45度到225度,二者偏移值是270度除360度 type: 'value', startAngle: 215, //极坐标初始角度 splitLine: { show: false } }, barMaxWidth: 10, //圆环宽度 radiusAxis: { show: false, type: 'category', }, //圆环位置和大小 polar: { center: ['50%', '60%'], radius: '160%' }, series: [{ type: 'bar', data: [{ //上层圆环,显示数据 value: getvalue, itemStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: '#fb8e1e', }, { offset: .5, color: '#77dfa2', }, { offset: 1, color: '#77dfa2', }, ], }, }, }], barGap: '-100%', //柱间距离,上下两层圆环重合 coordinateSystem: 'polar', roundCap: true, //顶端圆角 z: 3 //圆环层级,同zindex }, { //下层圆环,显示最大值 type: 'bar', data: [{ value: getmax, itemStyle: { color: '#c7cfd9', opacity: .8, borderWidth: 0, }, }], barGap: '-100%', coordinateSystem: 'polar', roundCap: true, z: 1 }, ] }; var getmax2 = 100; var getvalue2 = 78; option2 = { title: [{ text: '0.0bar', top: '45%', x: 'center', textStyle: { fontSize: 14, color: '#000' } }, { text: '出口压力', top: '62%', x: 'center', textStyle: { fontSize: 14, color: '#000' } }], angleAxis: { show: false, max: getmax2 * 360 / 250, //-45度到225度,二者偏移值是270度除360度 type: 'value', startAngle: 215, //极坐标初始角度 splitLine: { show: false } }, barMaxWidth: 10, //圆环宽度 radiusAxis: { show: false, type: 'category', }, //圆环位置和大小 polar: { center: ['50%', '60%'], radius: '160%' }, series: [{ type: 'bar', data: [{ //上层圆环,显示数据 value: getvalue2, itemStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: '#fb8e1e', }, { offset: .5, color: '#77dfa2', }, { offset: 1, color: '#77dfa2', }, ], }, }, }], barGap: '-100%', //柱间距离,上下两层圆环重合 coordinateSystem: 'polar', roundCap: true, //顶端圆角 z: 3 //圆环层级,同zindex }, { //下层圆环,显示最大值 type: 'bar', data: [{ value: getmax, itemStyle: { color: '#c7cfd9', opacity: .8, borderWidth: 0, }, }], barGap: '-100%', coordinateSystem: 'polar', roundCap: true, z: 1 }, ] }; var getmax3 = 100; var getvalue3 = 75; option3 = { title: [{ text: '0.0Nm³/h', top: '45%', x: 'center', textStyle: { fontSize: 14, color: '#000' } }, { text: '出口流量', top: '62%', x: 'center', textStyle: { fontSize: 14, color: '#000' } }], angleAxis: { show: false, max: getmax * 360 / 250, //-45度到225度,二者偏移值是270度除360度 type: 'value', startAngle: 215, //极坐标初始角度 splitLine: { show: false } }, barMaxWidth: 10, //圆环宽度 radiusAxis: { show: false, type: 'category', }, //圆环位置和大小 polar: { center: ['50%', '60%'], radius: '160%' }, series: [{ type: 'bar', data: [{ //上层圆环,显示数据 value: getvalue, itemStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: '#fb8e1e', }, { offset: .5, color: '#77dfa2', }, { offset: 1, color: '#77dfa2', }, ], }, }, }], barGap: '-100%', //柱间距离,上下两层圆环重合 coordinateSystem: 'polar', roundCap: true, //顶端圆角 z: 3 //圆环层级,同zindex }, { //下层圆环,显示最大值 type: 'bar', data: [{ value: getmax, itemStyle: { color: '#c7cfd9', opacity: .8, borderWidth: 0, }, }], barGap: '-100%', coordinateSystem: 'polar', roundCap: true, z: 1 }, ] }; myChart1.setOption(option1); myChart2.setOption(option2); myChart3.setOption(option3); window.addEventListener("resize", function () { myChart1.resize(); myChart2.resize(); myChart3.resize(); }); }