var layer; var form; $(function () { layui.use(['layer', 'form'], function () { form = layui.form; layer = layui.layer; // 查询仓库的实时能耗信息 query(); }); }); // 根据仓库查询 function query() { var index = layer.load(); $.ajax({ type: "POST", url: "../../basic/es/cur-data", dataType: "json", contentType: "application/json;charset=UTF-8", success: function (result) { layer.close(index); if (result.code == "0000") { renderView(result.data); } else { renderView(null); layer.alert(result.msg); } }, error: function (result) { layer.close(index); renderView(null); layer.msg("获取数据失败,请重新尝试!"); } }); }; /** * 根据查询的MAP能耗数据信息,渲染页面,如果没有能耗数据,仅仅渲染粮库信息 * * @param esData * @returns */ function renderView(esList) { $("#div_main").empty(); layer.msg("开始渲染配电信息!!"); var html = ""; if (esList) { $.each(esList, function (index, esData) { html += "
"; //通过判断A相电压的值,判断当前仓库是红色图片还是正常图片 if (esData.ua > 0) { html += "
"; } else { html += "
"; } html += esData.updateTime + "

"; html += "" + esData.depotName + "

"; html += "
电压
"; html += "

A相电压:" + esData.ua.toFixed(1) + " V

"; html += "

B相电压:" + esData.ub.toFixed(1) + " V

"; html += "

C相电压:" + esData.uc.toFixed(1) + " V

"; html += "
电流
"; html += "

A相电流:" + esData.ia.toFixed(1) + " A

"; html += "

B相电流:" + esData.ib.toFixed(1) + " A

"; html += "

C相电流:" + esData.ic.toFixed(1) + " A

"; html += "
"; }); } else { $.each(listDepot, function (index, depot) { html += "
"; html += "
"; html += "00:00

"; html += "" + depot.name + "

电压
"; html += "

A相电压:0.0 V

"; html += "

B相电压:0.0 V

"; html += "

C相电压:0.0 V

"; html += "
电流
"; html += "

A相电流:0.0 A

"; html += "

B相电流:0.0 A

"; html += "

C相电流:0.0 A

"; html += "
"; }); } $("#div_main").append(html); }