377 lines
11 KiB
Plaintext
377 lines
11 KiB
Plaintext
|
|
let table, form, layer, rate, util, formSelects, user = getUser();
|
|||
|
|
let pageNum = 1, limitSize = 10;
|
|||
|
|
let nodeList = [];
|
|||
|
|
$(function () {
|
|||
|
|
layui.config({
|
|||
|
|
base: "../../../js/layui/", //此处路径请自行处理, 可以使用绝对路径
|
|||
|
|
}).extend({
|
|||
|
|
formSelects: 'formSelects-v4'
|
|||
|
|
}).use(['layer', 'formSelects', 'form', 'table', 'util'], function () {
|
|||
|
|
layer = layui.layer;
|
|||
|
|
form = layui.form;
|
|||
|
|
table = layui.table;
|
|||
|
|
util = layui.util;
|
|||
|
|
formSelects = layui.formSelects;
|
|||
|
|
form.render();
|
|||
|
|
util.event('lay-active', {
|
|||
|
|
query: function () {
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
},
|
|||
|
|
reset: function () {
|
|||
|
|
$('#fzrName').val('');
|
|||
|
|
$('#deviceName').val('');
|
|||
|
|
formSelects.value('org', []);
|
|||
|
|
$('#mac').val('');
|
|||
|
|
$('#puId').val('');
|
|||
|
|
$('#state').val('');
|
|||
|
|
form.render();
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
},
|
|||
|
|
allMachine: function () {
|
|||
|
|
let puIds = [];
|
|||
|
|
let checkData = table.checkStatus('teamTable').data;
|
|||
|
|
$.each(checkData, function (index, item) {
|
|||
|
|
puIds.push(item.puId);
|
|||
|
|
});
|
|||
|
|
if (checkData.length === 0) {
|
|||
|
|
layer.msg("请选择数据", {icon: 0, scrollbar: false, time: 2000,});
|
|||
|
|
} else {
|
|||
|
|
toPage("", puIds.join(","), "all")
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
refreshRedis: function () {
|
|||
|
|
refreshRedis();
|
|||
|
|
},
|
|||
|
|
groupNode: function () {
|
|||
|
|
groupNode();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
getOrgSelect();
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
function pages(pageNum, pageSize) {
|
|||
|
|
getGroupNode("0");
|
|||
|
|
let params = getReqParams(pageNum, pageSize);
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify(params))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + "proteam/pot/deviceMachine/getDeviceMachineList" + '?token=' + token,
|
|||
|
|
data: params,
|
|||
|
|
type: 'POST',
|
|||
|
|
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) {
|
|||
|
|
layui.use(['laypage'], function () {
|
|||
|
|
let laypage = layui.laypage;
|
|||
|
|
laypage.render({
|
|||
|
|
elem: 'voi-page',
|
|||
|
|
count: total,
|
|||
|
|
curr: page,
|
|||
|
|
limit: limit,
|
|||
|
|
limits: [10, 20, 50, 100, 200, 500],
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/***
|
|||
|
|
*
|
|||
|
|
* @param page
|
|||
|
|
* @param limit
|
|||
|
|
* @returns {{limit: string, page: string, keyWord: string}}
|
|||
|
|
*/
|
|||
|
|
function getReqParams(page, limit) {
|
|||
|
|
return {
|
|||
|
|
page: page + "",
|
|||
|
|
limit: limit + "",
|
|||
|
|
fzrName: $('#fzrName').val(),
|
|||
|
|
deviceName: $('#deviceName').val(),
|
|||
|
|
org: formSelects.value('org', 'val').toString(),
|
|||
|
|
mac: $('#mac').val(),
|
|||
|
|
puId: $('#puId').val(),
|
|||
|
|
state: $('#state').val(),
|
|||
|
|
currentUserId: user.userId + "",
|
|||
|
|
isSup: user.isSup,
|
|||
|
|
currentUserOrgId: user.orgId
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function initTable(dataList, limit, page) {
|
|||
|
|
table.render({
|
|||
|
|
elem: "#teamTable",
|
|||
|
|
id: "teamTable",
|
|||
|
|
height: "full-150",
|
|||
|
|
data: dataList,
|
|||
|
|
cols: [
|
|||
|
|
[//表头
|
|||
|
|
{
|
|||
|
|
type: 'checkbox'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
title: "序号",
|
|||
|
|
width: 80,
|
|||
|
|
unresize: true,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
return (page - 1) * limit + d.LAY_INDEX;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "org",
|
|||
|
|
title: "建管单位",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
width: 120,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "nodeName",
|
|||
|
|
title: "分组",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
width: 200,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'deviceName',
|
|||
|
|
title: "球机名称",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 200,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'fzrName',
|
|||
|
|
title: "负责人",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
width: 120,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
return "<span>" + d.fzrName + "</span><br/><span>" + d.phone + "</span>";
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'mac',
|
|||
|
|
title: "MAC地址",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
width: 180,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'puId',
|
|||
|
|
title: "PUID",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
width: 180,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'state',
|
|||
|
|
title: "设备状态",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
width: 120,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
title: "操作",
|
|||
|
|
width: 180,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
var button = '';
|
|||
|
|
if (user.nickName == 'ahsbd') {
|
|||
|
|
$.each(nodeList, function (index, item) {
|
|||
|
|
if (item.name === '安徽送变电') {
|
|||
|
|
button += '<a onclick="toPage(\'' + d.nodeIndex + '\',\'' + d.puId + '\',\'' + item.index + '\')">' + item.name + '</a>' + '<br>';
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$.each(nodeList, function (index, item) {
|
|||
|
|
button += '<a onclick="toPage(\'' + d.nodeIndex + '\',\'' + d.puId + '\',\'' + item.index + '\')">' + item.name + '</a>' + '<br>';
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return button;
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
],
|
|||
|
|
limit: limit
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//组织机构下拉选
|
|||
|
|
function getOrgSelect() {
|
|||
|
|
let keys = [];
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({}))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + 'proteam/pot/team/getOrgSelected' + '?token=' + token,
|
|||
|
|
type: 'post',
|
|||
|
|
success: function (data) {
|
|||
|
|
$.each(data.data, function (index, item) {
|
|||
|
|
let temp = {
|
|||
|
|
"name": item.name,
|
|||
|
|
"value": item.code
|
|||
|
|
};
|
|||
|
|
keys.push(temp);
|
|||
|
|
})
|
|||
|
|
formSelects.data('org', 'local', {
|
|||
|
|
arr: keys
|
|||
|
|
});
|
|||
|
|
form.render();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//组织机构下拉选
|
|||
|
|
function refreshRedis() {
|
|||
|
|
let loadingMsg = layer.msg("数据刷新中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({}))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + 'proteam//pot/deviceMachine/refreshRedisUtil' + '?token=' + token,
|
|||
|
|
type: 'post',
|
|||
|
|
success: function (data) {
|
|||
|
|
pages(1, 10);
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
}, error: function () {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 跳转今日人员页面
|
|||
|
|
* @param puId
|
|||
|
|
* @param type
|
|||
|
|
*/
|
|||
|
|
function toPage(node, puId, type) {
|
|||
|
|
let width = '50%', height = '80%';
|
|||
|
|
layer.open({
|
|||
|
|
title: ['分配', 'font-size:24px;'],
|
|||
|
|
type: 2,
|
|||
|
|
skin: 'shadows',
|
|||
|
|
content: '../../device/machine/child/machineCity.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
let body = layer.getChildFrame('body', index);
|
|||
|
|
let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法:
|
|||
|
|
iframeWin.setForm(node, puId, type);//调用子页面的方法,页面锁定
|
|||
|
|
}, end: function () {
|
|||
|
|
pages(1, 10);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 跳转今日人员页面
|
|||
|
|
* @param puId
|
|||
|
|
* @param type
|
|||
|
|
*/
|
|||
|
|
function groupNode() {
|
|||
|
|
let width = '50%', height = '80%';
|
|||
|
|
layer.open({
|
|||
|
|
title: ['分配', 'font-size:24px;'],
|
|||
|
|
type: 2,
|
|||
|
|
skin: 'shadows',
|
|||
|
|
content: '../../device/machine/child/groupNode.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
let body = layer.getChildFrame('body', index);
|
|||
|
|
let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法:
|
|||
|
|
iframeWin.setForm();//调用子页面的方法,页面锁定
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function timestamp() {
|
|||
|
|
let date = new Date();
|
|||
|
|
let year = date.getFullYear();
|
|||
|
|
let month = date.getMonth() + 1;
|
|||
|
|
let day = date.getDate();
|
|||
|
|
let hours = date.getHours();
|
|||
|
|
let minutes = date.getMinutes();
|
|||
|
|
let seconds = date.getSeconds()
|
|||
|
|
if (month < 10) {
|
|||
|
|
month = "0" + month;
|
|||
|
|
}
|
|||
|
|
if (day < 10) {
|
|||
|
|
day = "0" + day;
|
|||
|
|
}
|
|||
|
|
if (hours < 10) {
|
|||
|
|
hours = "0" + hours;
|
|||
|
|
}
|
|||
|
|
if (minutes < 10) {
|
|||
|
|
minutes = "0" + minutes;
|
|||
|
|
}
|
|||
|
|
if (seconds < 10) {
|
|||
|
|
seconds = "0" + seconds;
|
|||
|
|
}
|
|||
|
|
return year + "-" + month + "-" + day + " " + hours + "-" + minutes + "-" + seconds
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
*获取分组节点
|
|||
|
|
*/
|
|||
|
|
function getGroupNode(type) {
|
|||
|
|
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
|||
|
|
Ajax().post({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({}))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + 'proteam/pot/deviceMachine/getGroupNode',
|
|||
|
|
data: {
|
|||
|
|
"type": type
|
|||
|
|
},
|
|||
|
|
async: true,
|
|||
|
|
success: function (data) {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
if (data.code === 200) {
|
|||
|
|
nodeList = data.data;
|
|||
|
|
}
|
|||
|
|
}, error: function () {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|