597 lines
16 KiB
JavaScript
597 lines
16 KiB
JavaScript
|
|
$.i18n();
|
||
|
|
|
||
|
|
function getDevTree() {
|
||
|
|
$.ajax({
|
||
|
|
url: "/ems/monitorBusiness/queryAlarmTreeMs",
|
||
|
|
type: "get",
|
||
|
|
data: {},
|
||
|
|
dataType: "json",
|
||
|
|
success: function(res) {
|
||
|
|
initTree(res.rows);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function getColor() {
|
||
|
|
$.ajax({
|
||
|
|
url: "/ems/monitorBusiness/findAlarmcolor",
|
||
|
|
type: "post",
|
||
|
|
dataType: "json",
|
||
|
|
async:false,
|
||
|
|
success: function(res) {
|
||
|
|
window.colorList = {};
|
||
|
|
window.colorIds = [];
|
||
|
|
for (var i = 0, str = ""; i < res.length; i++) {
|
||
|
|
var o = res[i];
|
||
|
|
str +=
|
||
|
|
'<dd data-id="' +
|
||
|
|
o.id +
|
||
|
|
'" data-name="' +
|
||
|
|
o.name +
|
||
|
|
'">' +
|
||
|
|
o.name +
|
||
|
|
'</dd><dt class="color" style="background-color:#' +
|
||
|
|
o.color +
|
||
|
|
'"></dt><br>';
|
||
|
|
window.colorList[o.name] = o.color;
|
||
|
|
window.colorIds.push(o.id);
|
||
|
|
}
|
||
|
|
$("#colorconfig").html(str);
|
||
|
|
setTimeout(function() {
|
||
|
|
$("#colorconfig .color").each(function(i, e) {
|
||
|
|
var color = $(e).css("background-color");
|
||
|
|
var name = $(e)
|
||
|
|
.prev("dd")
|
||
|
|
.html();
|
||
|
|
var reg =
|
||
|
|
color.indexOf("rgb") === -1
|
||
|
|
? ""
|
||
|
|
: color.indexOf("rgba") !== -1
|
||
|
|
? /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d+)\)$/
|
||
|
|
: /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/;
|
||
|
|
if (reg) {
|
||
|
|
color = color.match(reg);
|
||
|
|
|
||
|
|
function hex(x) {
|
||
|
|
return ("0" + parseInt(x).toString(16)).slice(-2);
|
||
|
|
}
|
||
|
|
color = "#" + hex(color[1]) + hex(color[2]) + hex(color[3]);
|
||
|
|
}
|
||
|
|
$(e).ColorPicker({
|
||
|
|
flat: false,
|
||
|
|
eventName: "click",
|
||
|
|
color: color.substring(1),
|
||
|
|
onChange: function(hsb, hex, rgb) {
|
||
|
|
$(e).css("background-color", "#" + hex);
|
||
|
|
colorList[name] = hex;
|
||
|
|
},
|
||
|
|
onSubmit: function(hsb, hex, rgb) {
|
||
|
|
colorList[name] = hex;
|
||
|
|
$(".colorpicker").hide();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}, 200);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
$(function() {
|
||
|
|
getColor();
|
||
|
|
getDevTree();
|
||
|
|
$("input[name=time-start]").val(
|
||
|
|
dayjs()
|
||
|
|
.subtract(1, "day")
|
||
|
|
.format("YYYY-MM-DD HH:mm")
|
||
|
|
);
|
||
|
|
$("input[name=time-end]").val(dayjs().format("YYYY-MM-DD HH:mm"));
|
||
|
|
var cols = [
|
||
|
|
{
|
||
|
|
key: "4",
|
||
|
|
name: $("input:hidden[name=h-timeStamp]"),
|
||
|
|
sortId: "timeStamp",
|
||
|
|
sort: "desc",
|
||
|
|
fn: "alarm",
|
||
|
|
prop: "timeStamp"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "8",
|
||
|
|
name: $("input:hidden[name=h-priority]"),
|
||
|
|
sortId: "priority",
|
||
|
|
sort: "",
|
||
|
|
fn: "alarm",
|
||
|
|
prop: "priority"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "6",
|
||
|
|
name: $("input:hidden[name=h-location]"),
|
||
|
|
sortId: "location",
|
||
|
|
sort: "",
|
||
|
|
fn: "alarm",
|
||
|
|
prop: "location"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "2",
|
||
|
|
name: $("input:hidden[name=h-almState]"),
|
||
|
|
sortId: "almState",
|
||
|
|
sort: "",
|
||
|
|
fn: "alarm",
|
||
|
|
prop: "almState"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "3",
|
||
|
|
name: $("input:hidden[name=h-almStatus]"),
|
||
|
|
sortId: "almStatus",
|
||
|
|
sort: "",
|
||
|
|
fn: "alarm",
|
||
|
|
prop: "almStatus"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "content",
|
||
|
|
name: $("input:hidden[name=h-content]"),
|
||
|
|
sort: false,
|
||
|
|
fn: "alarm",
|
||
|
|
prop: "content"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
window.alarm = initSocket({
|
||
|
|
url: "alarmWebsocket",
|
||
|
|
success: function(res) {
|
||
|
|
$("#table").css("counter-reset", "c " + (res.pageNo - 1) * res.pageSize);
|
||
|
|
if (res.data) {
|
||
|
|
for (var i = 0, str = ""; i < res.data.length; i++) {
|
||
|
|
var d = res.data[i];
|
||
|
|
var vals = cols.reduce(function(o, v, i) {
|
||
|
|
var str = "";
|
||
|
|
if (v.key == 4) {
|
||
|
|
str = dayjs(d.other[v.key]).format("YYYY-MM-DD HH:mm:ss");
|
||
|
|
} else if (v.key == 3) {
|
||
|
|
if (localStorage.getItem("i18n") == "en") {
|
||
|
|
if (d.other[v.key] === "未确认") {
|
||
|
|
d.other[v.key] = "Unconfirmed";
|
||
|
|
} else {
|
||
|
|
d.other[v.key] = "Confirmed";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
str = d.other[v.key];
|
||
|
|
} else if (v.key == "content") {
|
||
|
|
str = d[v.key];
|
||
|
|
} else {
|
||
|
|
str = d.other[v.key];
|
||
|
|
}
|
||
|
|
o.push(str);
|
||
|
|
return o;
|
||
|
|
}, []);
|
||
|
|
str +=
|
||
|
|
'<tr style="color:#' +
|
||
|
|
colorList[d.other[8]] +
|
||
|
|
'"><td></td><td>' +
|
||
|
|
vals.join("</td><td>") +
|
||
|
|
"</td></tr>";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!str) {
|
||
|
|
$("#table tbody tr td").text("");
|
||
|
|
} else {
|
||
|
|
$("#table tbody").html(str);
|
||
|
|
}
|
||
|
|
$("#page").initPage(
|
||
|
|
{
|
||
|
|
resKey: {
|
||
|
|
pageSize: "pageSize",
|
||
|
|
curPage: "page",
|
||
|
|
sumPage: "records"
|
||
|
|
},
|
||
|
|
pageSize: res.pageSize,
|
||
|
|
curPage: res.pageNo,
|
||
|
|
total: res.total
|
||
|
|
},
|
||
|
|
function(opt) {
|
||
|
|
alarm.open(opt);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
setTimeout(function() {
|
||
|
|
$(".page-loading").hide();
|
||
|
|
}, 500);
|
||
|
|
},
|
||
|
|
open: function(opt) {
|
||
|
|
if (localStorage) {
|
||
|
|
var pageSize = localStorage.getItem("alarmPageSize");
|
||
|
|
}
|
||
|
|
if (!pageSize) {
|
||
|
|
pageSize = 100;
|
||
|
|
}
|
||
|
|
var priority;
|
||
|
|
if (window.colorIds && window.colorIds.length > 0) {
|
||
|
|
priority = window.colorIds.join(";");
|
||
|
|
} else {
|
||
|
|
priority = "1;2;3;4;5";
|
||
|
|
}
|
||
|
|
var param = {
|
||
|
|
orderType: "timeStamp",
|
||
|
|
sequence: "desc",
|
||
|
|
pageNo: opt.curPage || 1,
|
||
|
|
pageSize: pageSize,
|
||
|
|
content: "",
|
||
|
|
priority: priority,
|
||
|
|
startTime: "",
|
||
|
|
endTime: "",
|
||
|
|
location: "",
|
||
|
|
regionId: "",
|
||
|
|
devType: "",
|
||
|
|
type: "",
|
||
|
|
almStatus: "",
|
||
|
|
devGroup: ""
|
||
|
|
};
|
||
|
|
//设备组
|
||
|
|
var treeObj = $.fn.zTree.getZTreeObj("devtree");
|
||
|
|
if (treeObj) {
|
||
|
|
var nodes = treeObj.getCheckedNodes(true);
|
||
|
|
}
|
||
|
|
if (nodes && nodes.length > 0) {
|
||
|
|
param.devGroup = nodes.reduce(function(o, v, i) {
|
||
|
|
if (v.isParent) {
|
||
|
|
return o;
|
||
|
|
}
|
||
|
|
if (o) {
|
||
|
|
o += ";";
|
||
|
|
}
|
||
|
|
o += v.treeCode;
|
||
|
|
return o;
|
||
|
|
}, "");
|
||
|
|
}
|
||
|
|
//处理排序
|
||
|
|
var el = $("#table thead").find(".asc");
|
||
|
|
if (!el[0]) {
|
||
|
|
el = $("#table thead").find(".desc");
|
||
|
|
param.sequence = "desc";
|
||
|
|
} else {
|
||
|
|
param.sequence = "asc";
|
||
|
|
}
|
||
|
|
param.orderType = el.attr("sort-id");
|
||
|
|
//处理时间
|
||
|
|
if ($("input[name=time]").is(":checked")) {
|
||
|
|
var start = $("input[name=time-start]").val();
|
||
|
|
var end = $("input[name=time-end]").val();
|
||
|
|
if (start && end) {
|
||
|
|
param.startTime = dayjs(start).valueOf();
|
||
|
|
param.endTime = dayjs(end).valueOf();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//处理筛选
|
||
|
|
if ($("input[name=priority]").is(":checked")) {
|
||
|
|
param.priority = $("select[name=priority-item]")
|
||
|
|
.val()
|
||
|
|
.join(";");
|
||
|
|
}
|
||
|
|
if ($("input[name=location]").is(":checked")) {
|
||
|
|
param.location = $("select[name=location-item]")
|
||
|
|
.val()
|
||
|
|
.join(";");
|
||
|
|
}
|
||
|
|
if ($("input[name=region]").is(":checked")) {
|
||
|
|
param.regionId = $("select[name=region-item]")
|
||
|
|
.val()
|
||
|
|
.join(";");
|
||
|
|
}
|
||
|
|
if ($("input[name=typename]").is(":checked")) {
|
||
|
|
param.type = $("select[name=typename-item]")
|
||
|
|
.val()
|
||
|
|
.join(";");
|
||
|
|
}
|
||
|
|
if ($("input[name=devtype]").is(":checked")) {
|
||
|
|
param.devType = $("select[name=devtype-item]").val();
|
||
|
|
}
|
||
|
|
if ($("input[name=content]").is(":checked")) {
|
||
|
|
param.content = $("input[name=content-item]").val();
|
||
|
|
}
|
||
|
|
if ($("input[name=alm-status]").is(":checked")) {
|
||
|
|
param.almStatus = $("input[name=alm-status-item]:checked").val();
|
||
|
|
}
|
||
|
|
alarm.send(param);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
//devGroup
|
||
|
|
|
||
|
|
var today = dayjs().startOf("day");
|
||
|
|
// query(1, cols);
|
||
|
|
getFilterData("", function(data) {
|
||
|
|
createHtml(data.alarmLevel, "select[name=priority-item]");
|
||
|
|
createHtml(data.location, "select[name=location-item]");
|
||
|
|
createHtml(data.regionInfo, "select[name=region-item]");
|
||
|
|
createHtml(data.alarmType, "select[name=typename-item]");
|
||
|
|
createHtml(data.subSystem, "select[name=subsystem-item]");
|
||
|
|
$("select[name=subsystem-item]").val(4);
|
||
|
|
});
|
||
|
|
getFilterData(4, function(data) {
|
||
|
|
createHtml(data.devType, "select[name=devtype-item]");
|
||
|
|
});
|
||
|
|
$("#configsubmit").on("click", function() {
|
||
|
|
var pagezise = $("input[name=alarmeverypage]").val();
|
||
|
|
if (pagezise && localStorage) {
|
||
|
|
localStorage.setItem("alarmPageSize", pagezise);
|
||
|
|
}
|
||
|
|
var param = [];
|
||
|
|
$("#colorconfig .color").each(function(i, e) {
|
||
|
|
var id = $(e)
|
||
|
|
.prev("dd")
|
||
|
|
.attr("data-id");
|
||
|
|
var name = $(e)
|
||
|
|
.prev("dd")
|
||
|
|
.attr("data-name");
|
||
|
|
var color = colorList[name];
|
||
|
|
param.push({
|
||
|
|
id: id,
|
||
|
|
name: name,
|
||
|
|
color: color
|
||
|
|
});
|
||
|
|
});
|
||
|
|
$.ajax({
|
||
|
|
contentType: "application/JSON; charset=UTF-8",
|
||
|
|
url: "/ems/monitorBusiness/insertColor",
|
||
|
|
data: JSON.stringify(param),
|
||
|
|
type: "post",
|
||
|
|
dataType: "json",
|
||
|
|
success: function(res) {
|
||
|
|
if ((res.reflag = "succ")) {
|
||
|
|
$("#configcancel").trigger("click");
|
||
|
|
$("#query").trigger("click");
|
||
|
|
} else {
|
||
|
|
alert(res.reflagInfo);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
$("#configcancel").on("click", function() {
|
||
|
|
$(".shadow").hide();
|
||
|
|
});
|
||
|
|
$("input[name=alarmeverypage]").on("blur", function() {
|
||
|
|
var v = $(this).val();
|
||
|
|
v = v > 2000 ? 2000 : Math.floor(v);
|
||
|
|
$(this).val(v);
|
||
|
|
});
|
||
|
|
$(".Wdate").on("click", function() {
|
||
|
|
var option = {
|
||
|
|
el: this,
|
||
|
|
isShowClear: false,
|
||
|
|
firstDayOfWeek: 1,
|
||
|
|
dateFmt: "yyyy-MM-dd HH:mm",
|
||
|
|
onpicked: function() {}
|
||
|
|
};
|
||
|
|
WdatePicker(option);
|
||
|
|
});
|
||
|
|
//点击表头排序
|
||
|
|
$("#table").on("click", "th", function() {
|
||
|
|
if (!$(this).hasClass("sort")) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
var isAsc = $(this).hasClass("asc");
|
||
|
|
var isDesc = $(this).hasClass("desc");
|
||
|
|
if (isAsc || isDesc) {
|
||
|
|
$(this)
|
||
|
|
.removeClass(isAsc ? "asc" : "desc")
|
||
|
|
.addClass(!isAsc ? "asc" : "desc");
|
||
|
|
} else {
|
||
|
|
$("#table th")
|
||
|
|
.removeClass("asc")
|
||
|
|
.removeClass("desc");
|
||
|
|
$(this).addClass("desc");
|
||
|
|
}
|
||
|
|
alarm.open({
|
||
|
|
curPage: $(".page-btn.cur").html()
|
||
|
|
});
|
||
|
|
});
|
||
|
|
// $('#colorconfig').on('click','dt.color',function(){
|
||
|
|
// var el=this;
|
||
|
|
// var color=$(this).css('background-color')
|
||
|
|
// console.log(color);
|
||
|
|
// $(this).ColorPicker({
|
||
|
|
// flat: true,
|
||
|
|
// color: $(el).css('background-color'),
|
||
|
|
// onSubmit: function(hsb, hex, rgb) {
|
||
|
|
// $(el).css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')');
|
||
|
|
// return false;
|
||
|
|
// }
|
||
|
|
// });
|
||
|
|
// })
|
||
|
|
$("#filter").on("click", function() {
|
||
|
|
$("#config_dialog").hide();
|
||
|
|
$("#filter_dialog").show();
|
||
|
|
$(".shadow").show();
|
||
|
|
});
|
||
|
|
$("#config").on("click", function() {
|
||
|
|
$("#filter_dialog").hide();
|
||
|
|
$("#config_dialog").show();
|
||
|
|
$(".shadow").show();
|
||
|
|
});
|
||
|
|
$("#query").on("click", function() {
|
||
|
|
alarm.open({
|
||
|
|
curPage: $(".page-btn.cur").html()
|
||
|
|
});
|
||
|
|
$(".shadow").hide();
|
||
|
|
});
|
||
|
|
$("#search").on("click", function() {
|
||
|
|
alarm.open({
|
||
|
|
curPage: $(".page-btn.cur").html()
|
||
|
|
});
|
||
|
|
});
|
||
|
|
$("#define").on("click", function() {
|
||
|
|
$(".shadow").hide();
|
||
|
|
});
|
||
|
|
$(".shadow>div").on("click", "p.close em", function() {
|
||
|
|
$(".shadow").hide();
|
||
|
|
});
|
||
|
|
//点击查询
|
||
|
|
crateTableHead(cols);
|
||
|
|
//筛选
|
||
|
|
$("#filter_dialog .content li label:first-child input:checkbox").on(
|
||
|
|
"click",
|
||
|
|
function() {
|
||
|
|
var ckd = $(this).is(":checked");
|
||
|
|
var parent = $(this).closest("li");
|
||
|
|
var _name_ = $(this).attr("name");
|
||
|
|
parent.toggleClass("dis");
|
||
|
|
if (ckd) {
|
||
|
|
parent.find("select").removeAttr("disabled");
|
||
|
|
if (_name_ === "alm-status") {
|
||
|
|
parent.find("input[name=alm-status-item]").removeAttr("disabled");
|
||
|
|
} else {
|
||
|
|
parent.find("label:last-child input").removeAttr("disabled");
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
parent
|
||
|
|
.find("select")
|
||
|
|
.attr("disabled", true)
|
||
|
|
.val("");
|
||
|
|
if (_name_ === "alm-status") {
|
||
|
|
parent.find("input[name=alm-status-item]").attr("disabled", true);
|
||
|
|
} else {
|
||
|
|
parent.find("label:last-child input").attr("disabled", true);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
);
|
||
|
|
//全选
|
||
|
|
$("#filter_dialog .content li label:last-child input:checkbox").on(
|
||
|
|
"click",
|
||
|
|
function() {
|
||
|
|
var ckd = $(this).is(":checked");
|
||
|
|
var parent = $(this).closest("li");
|
||
|
|
if (
|
||
|
|
$(this)
|
||
|
|
.attr("name")
|
||
|
|
.indexOf("-all") == -1
|
||
|
|
) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if (ckd) {
|
||
|
|
var values = [];
|
||
|
|
parent.find("select option").each(function(i, e) {
|
||
|
|
values.push($(e).attr("value"));
|
||
|
|
});
|
||
|
|
parent.find("select").val(values);
|
||
|
|
} else {
|
||
|
|
parent.find("select").val("");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
);
|
||
|
|
|
||
|
|
$('input[name="treeType"]').on('change',function(){
|
||
|
|
var flag = $('input[name="treeType"]:checked').val()
|
||
|
|
if(flag === '1'){
|
||
|
|
var treeObj = $.fn.zTree.getZTreeObj("devtree");
|
||
|
|
treeObj.checkAllNodes(false);
|
||
|
|
}
|
||
|
|
})
|
||
|
|
});
|
||
|
|
|
||
|
|
function crateTableHead(cols) {
|
||
|
|
var head = cols.reduce(function(o, v, i) {
|
||
|
|
var cls = v.sort === false ? "" : "sort " + v.sort;
|
||
|
|
o +=
|
||
|
|
'<th class="' +
|
||
|
|
cls +
|
||
|
|
'" sort-id="' +
|
||
|
|
v.sortId +
|
||
|
|
'" data-i18n="' +
|
||
|
|
(v.fn + "." + v.prop) +
|
||
|
|
'">' +
|
||
|
|
v.name.val() +
|
||
|
|
"</th>";
|
||
|
|
return o;
|
||
|
|
}, "");
|
||
|
|
$("#table thead").html("<tr><th></th>" + head + "</tr>");
|
||
|
|
}
|
||
|
|
|
||
|
|
function getFilterData(id, fn) {
|
||
|
|
$.ajax({
|
||
|
|
url: "/ems/monitorBusiness/queryEventConditionMs",
|
||
|
|
type: "get",
|
||
|
|
data: {
|
||
|
|
type: isNaN(id) || id === "" || id === null ? 1 : 2,
|
||
|
|
id: id
|
||
|
|
},
|
||
|
|
dataType: "json",
|
||
|
|
success: function(res) {
|
||
|
|
if (typeof fn === "function") {
|
||
|
|
fn(res.mapData);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function creatConfig(rows) {}
|
||
|
|
|
||
|
|
function createHtml(rows, selected) {
|
||
|
|
for (var i = 0, options = ""; i < rows.length; i++) {
|
||
|
|
options +=
|
||
|
|
'<option value="' + rows[i].id + '">' + rows[i].name + "</option>";
|
||
|
|
}
|
||
|
|
$(selected).html(options);
|
||
|
|
}
|
||
|
|
|
||
|
|
function initTree(data) {
|
||
|
|
var setting = {
|
||
|
|
data: {
|
||
|
|
simpleData: {
|
||
|
|
enable: true,
|
||
|
|
idKey: "treeCode",
|
||
|
|
pIdKey: "treePCode",
|
||
|
|
rootPId: ""
|
||
|
|
}
|
||
|
|
},
|
||
|
|
view: {
|
||
|
|
showLine: false,
|
||
|
|
expandSpeed: "fast",
|
||
|
|
showIcon: false
|
||
|
|
},
|
||
|
|
check: {
|
||
|
|
enable: true,
|
||
|
|
chkStyle: "checkbox"
|
||
|
|
},
|
||
|
|
callback: {
|
||
|
|
beforeCheck:function(id,nodes){
|
||
|
|
if(!nodes.checked){// 仅判断是选中还是取消
|
||
|
|
var flag = $('input[name="treeType"]:checked').val()
|
||
|
|
if(flag === '0'){
|
||
|
|
var nodelist=[];// 本次勾选的设备
|
||
|
|
expandChildren([nodes],nodelist)
|
||
|
|
var treeObj = $.fn.zTree.getZTreeObj("devtree");
|
||
|
|
var checked = treeObj.getCheckedNodes(true);// 已勾选的设备
|
||
|
|
if(nodelist.length+checked.length>999){
|
||
|
|
alert("请勾选小于1000个设备");
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
onCheck: function() {
|
||
|
|
$("#search").trigger("click");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var zTreeObj = $.fn.zTree.init($("#devtree"), setting, data);
|
||
|
|
// zTreeObj.checkAllNodes(true);
|
||
|
|
// zTreeObj.expandAll(true);
|
||
|
|
alarm.open({
|
||
|
|
curPage: $(".page-btn.cur").html()
|
||
|
|
});
|
||
|
|
return zTreeObj;
|
||
|
|
}
|
||
|
|
|
||
|
|
function expandChildren(nodes,result){
|
||
|
|
var arr=[];
|
||
|
|
for (var i = 0; i < nodes.length; i++) {
|
||
|
|
var node = nodes[i];
|
||
|
|
result.push(node);
|
||
|
|
if(node.children&&node.children.length>0){
|
||
|
|
arr=arr.concat(node.children)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(arr.length>0){
|
||
|
|
return expandChildren(arr,result)
|
||
|
|
}
|
||
|
|
}
|