206 lines
6.0 KiB
JavaScript
206 lines
6.0 KiB
JavaScript
|
|
let table;
|
|||
|
|
let deviceTable;
|
|||
|
|
let form;
|
|||
|
|
let per;
|
|||
|
|
let laypage;
|
|||
|
|
let strIds;
|
|||
|
|
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
|||
|
|
layui.use(['layer', 'form', 'element','laypage'], function(){
|
|||
|
|
var layer = layui.layer; //弹层
|
|||
|
|
laypage = layui.laypage; //分页
|
|||
|
|
table = layui.table; //表格
|
|||
|
|
form=layui.form;
|
|||
|
|
//注册权限
|
|||
|
|
// per=getPer();
|
|||
|
|
initDeviceTypeSelect('');//设备类型下拉选
|
|||
|
|
//初始化下拉选
|
|||
|
|
pages(1, 10, 1);
|
|||
|
|
|
|||
|
|
$("#query").off().click(function(){
|
|||
|
|
// if(/^[a-zA-Z0-9\u4e80-\u9fa5\\s-]+$/.test($("#deviceName").val()) || ""==$("#deviceName").val()){
|
|||
|
|
// }else {
|
|||
|
|
// layer.msg("不能包合特殊字符", {icon: 5,});
|
|||
|
|
// return;
|
|||
|
|
// }
|
|||
|
|
pages(1, limitSize,false);
|
|||
|
|
return ;
|
|||
|
|
})
|
|||
|
|
//重置
|
|||
|
|
$("#reset").off().click(function(){
|
|||
|
|
pages(1, limitSize,true);
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
//查询按钮
|
|||
|
|
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
function pages(pageNum, pageSize, typeNum) {
|
|||
|
|
let params = getReqParams(pageNum, pageSize, typeNum);
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify(params))
|
|||
|
|
},
|
|||
|
|
url: dataUrl+'proteam/pot/monitor/getMonitorList?token='+token,
|
|||
|
|
data: params,
|
|||
|
|
type: 'POST',
|
|||
|
|
async: false,
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
if (result.data) {
|
|||
|
|
initTable(result.data, result.limit, result.curr)
|
|||
|
|
laypages(result.count, result.curr, result.limit)
|
|||
|
|
}
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
layer.alert(result.msg, {icon: 2})
|
|||
|
|
} else if (result.code === 401) {
|
|||
|
|
logout(1);
|
|||
|
|
}
|
|||
|
|
}, error: function () {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function laypages(total, page, limit) {
|
|||
|
|
laypage.render({
|
|||
|
|
elem: 'voi-page',
|
|||
|
|
count: total,
|
|||
|
|
curr: page,
|
|||
|
|
limit: limit,
|
|||
|
|
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
|||
|
|
groups: 5,
|
|||
|
|
jump: function (obj, first) {
|
|||
|
|
if (!first) {
|
|||
|
|
pageNum = obj.curr, limitSize = obj.limit;
|
|||
|
|
pages(obj.curr, obj.limit, null);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取参数
|
|||
|
|
function getReqParams(page, limit, type) {
|
|||
|
|
let obj = {};
|
|||
|
|
if (!type) {
|
|||
|
|
obj = {
|
|||
|
|
page: page + "",
|
|||
|
|
limit: limit + "",
|
|||
|
|
deviceName:$("#deviceName").val(),
|
|||
|
|
macId:$("#macId").val(),
|
|||
|
|
puId:$("#puId").val(),
|
|||
|
|
state:$("#state").val(),
|
|||
|
|
typeCode:$("#typeCode").val(),
|
|||
|
|
keyWord:$("#keyWord").val(),
|
|||
|
|
};
|
|||
|
|
} else {
|
|||
|
|
obj = {
|
|||
|
|
page: '1',
|
|||
|
|
limit: '10',
|
|||
|
|
deviceName:"",
|
|||
|
|
macId:"",
|
|||
|
|
puId:"",
|
|||
|
|
state:"",
|
|||
|
|
typeCode:"",
|
|||
|
|
keyWord:"",
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
return obj;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//初始化表格
|
|||
|
|
function initTable(dataList, limit, page) {
|
|||
|
|
// 执行一个 table 实例
|
|||
|
|
monitorTable=table.render({
|
|||
|
|
id:'monitorTable',
|
|||
|
|
elem: '#monitor-table',
|
|||
|
|
height: "full-450",
|
|||
|
|
data: dataList,
|
|||
|
|
limit: limit,
|
|||
|
|
title: '资源监测表',
|
|||
|
|
cols: [[ //表头
|
|||
|
|
{type: 'checkbox', fixed: 'left'},
|
|||
|
|
{title: "序号", width: 80, align: "center", templet: function (d) {
|
|||
|
|
return (page - 1) * limit + d.LAY_INDEX;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
,{field: 'deviceName', title: '设备名称', width:200,align:'center'}
|
|||
|
|
,{field: 'macId', title: 'MACID', width: 200,align:'center'}
|
|||
|
|
,{field: 'puId', title: 'puId', width: 200,align:'center'}
|
|||
|
|
,{field: 'state', title: '设备在线状态', width: 200,align:'center'}
|
|||
|
|
,{field: 'typeName', title: '设备类型', width: 200,align:'center'}
|
|||
|
|
,{field: 'electricity', title: '设备电量', width:210,align:'center' }
|
|||
|
|
,{field: 'storage', title: '设备存储', width: 150,align:'center'}
|
|||
|
|
,{field: 'netStatus', title: '网络状态', width: 200,align:'center'}
|
|||
|
|
// ,{fixed: 'right', title: '操作', width: 200,align:'center', toolbar: '#monitor-bar'}
|
|||
|
|
]],
|
|||
|
|
done:function (res,curr,count){
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设备类型下拉选
|
|||
|
|
function initDeviceTypeSelect(keyId){
|
|||
|
|
Ajax().post({
|
|||
|
|
url: dataUrl + 'system/sys/selected/getDeviceTypeSelected',
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({'params':"device_type"}))
|
|||
|
|
},
|
|||
|
|
data: {
|
|||
|
|
params: "device_type"
|
|||
|
|
},
|
|||
|
|
async : true,
|
|||
|
|
success : function(data) {
|
|||
|
|
console.log(data);
|
|||
|
|
var html="";
|
|||
|
|
$(".typeCode").empty();
|
|||
|
|
html+="<option value=''>请选择设备类型</option>"
|
|||
|
|
if(data!=null &&data.length>0){
|
|||
|
|
for(var i = 0;i<data.length;i++){ //循环LIST
|
|||
|
|
var code = data[i].code;//获取LIST里面的对象
|
|||
|
|
var name = data[i].name;//获取LIST里面的对象
|
|||
|
|
if(keyId==code){
|
|||
|
|
html+="<option value='"+code+"' selected>"+name+"</option>";
|
|||
|
|
}else {
|
|||
|
|
html+="<option value='"+code+"'>"+name+"</option>";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
$(".typeCode").append(html);
|
|||
|
|
form.render();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function query(){
|
|||
|
|
pages(1, limitSize,false);
|
|||
|
|
}
|
|||
|
|
function reloadTable(){
|
|||
|
|
query();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
function getNetwork(deviceType) {
|
|||
|
|
Ajax().post({
|
|||
|
|
url: dataUrl + 'proteam/pot/monitor/getNetwork', //预留,暂无数据来源,故后端还未写方法
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({'deviceType':deviceType}))
|
|||
|
|
},
|
|||
|
|
success: function (data) {
|
|||
|
|
console.log(data);
|
|||
|
|
$.each(data.data, function (index, item) {
|
|||
|
|
$('#roomNetwork').text(item.roomNetwork);
|
|||
|
|
$('#serviceNetwork').text(item.serviceNetwork);
|
|||
|
|
$('#serviceMemory').text(item.serviceMemory);
|
|||
|
|
$('#serviceBandwidth').text(item.serviceBandwidth);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|