调试菜单状态问题
This commit is contained in:
parent
ce23f8933e
commit
af5087aba8
|
|
@ -1,4 +1,16 @@
|
||||||
initMenu();
|
initMenu();
|
||||||
|
function getIsCheckFun(list) {
|
||||||
|
if (list && list.length > 0) {
|
||||||
|
list.forEach((e) => {
|
||||||
|
if (e.isCheck == 1) {
|
||||||
|
console.log("有待审数据", e);
|
||||||
|
}
|
||||||
|
if (e.child && e.child.length > 0) {
|
||||||
|
getIsCheckFun(e.child);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
function initMenu() {
|
function initMenu() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: ctxPath + "/permissions/current",
|
url: ctxPath + "/permissions/current",
|
||||||
|
|
@ -6,7 +18,7 @@ function initMenu(){
|
||||||
async: false,
|
async: false,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (!$.isArray(data)) {
|
if (!$.isArray(data)) {
|
||||||
location.href=ctxPath + '/login.html';
|
location.href = ctxPath + "/login.html";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var menu = $("#menu");
|
var menu = $("#menu");
|
||||||
|
|
@ -15,7 +27,9 @@ function initMenu(){
|
||||||
|
|
||||||
var css = item.css;
|
var css = item.css;
|
||||||
if (css != null && css != "") {
|
if (css != null && css != "") {
|
||||||
a.append("<i aria-hidden='true' class='fa " + css +"'></i>");
|
a.append(
|
||||||
|
"<i aria-hidden='true' class='fa " + css + "'></i>"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
a.append("<cite>" + item.name + "</cite>");
|
a.append("<cite>" + item.name + "</cite>");
|
||||||
a.attr("lay-id", item.id);
|
a.attr("lay-id", item.id);
|
||||||
|
|
@ -33,10 +47,11 @@ function initMenu(){
|
||||||
menu.append(li);
|
menu.append(li);
|
||||||
|
|
||||||
//多级菜单
|
//多级菜单
|
||||||
setChild(li, item.child)
|
setChild(li, item.child);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
// 递归获取菜单状态
|
||||||
|
getIsCheckFun(data);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,8 +87,8 @@ function setChild(parentElement, child){
|
||||||
showLoginInfo();
|
showLoginInfo();
|
||||||
function showLoginInfo() {
|
function showLoginInfo() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'get',
|
type: "get",
|
||||||
url : ctxPath + '/users/current',
|
url: ctxPath + "/users/current",
|
||||||
async: false,
|
async: false,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$(".admin-header-user span").text(data.nickname);
|
$(".admin-header-user span").text(data.nickname);
|
||||||
|
|
@ -97,28 +112,28 @@ function showLoginInfo(){
|
||||||
}
|
}
|
||||||
var img = $(".admin-header-user img");
|
var img = $(".admin-header-user img");
|
||||||
img.attr("src", url);
|
img.attr("src", url);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'get',
|
type: "get",
|
||||||
url : ctxPath + '/logout',
|
url: ctxPath + "/logout",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
localStorage.removeItem("token");
|
localStorage.removeItem("token");
|
||||||
location.href= ctxPath + '/login.html';
|
location.href = ctxPath + "/login.html";
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var active;
|
var active;
|
||||||
|
|
||||||
layui.use(['layer', 'element'], function() {
|
layui.use(["layer", "element"], function () {
|
||||||
var $ = layui.jquery,
|
var $ = layui.jquery,
|
||||||
layer = layui.layer;
|
layer = layui.layer;
|
||||||
var element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
|
var element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
|
||||||
element.on('nav(demo)', function(elem){
|
element.on("nav(demo)", function (elem) {
|
||||||
//layer.msg(elem.text());
|
//layer.msg(elem.text());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -126,12 +141,17 @@ layui.use(['layer', 'element'], function() {
|
||||||
active = {
|
active = {
|
||||||
tabAdd: function (obj) {
|
tabAdd: function (obj) {
|
||||||
var lay_id = $(this).attr("lay-id");
|
var lay_id = $(this).attr("lay-id");
|
||||||
var title = $(this).html() + '<i class="layui-icon" data-id="' + lay_id + '"></i>';
|
var title =
|
||||||
|
$(this).html() +
|
||||||
|
'<i class="layui-icon" data-id="' +
|
||||||
|
lay_id +
|
||||||
|
'"></i>';
|
||||||
//新增一个Tab项
|
//新增一个Tab项
|
||||||
element.tabAdd('admin-tab', {
|
element.tabAdd("admin-tab", {
|
||||||
title: title,
|
title: title,
|
||||||
content: '<iframe src="' + $(this).attr('data-url') + '"></iframe>',
|
content:
|
||||||
id: lay_id
|
'<iframe src="' + $(this).attr("data-url") + '"></iframe>',
|
||||||
|
id: lay_id,
|
||||||
});
|
});
|
||||||
element.tabChange("admin-tab", lay_id);
|
element.tabChange("admin-tab", lay_id);
|
||||||
},
|
},
|
||||||
|
|
@ -139,12 +159,15 @@ layui.use(['layer', 'element'], function() {
|
||||||
element.tabDelete("admin-tab", lay_id);
|
element.tabDelete("admin-tab", lay_id);
|
||||||
},
|
},
|
||||||
tabChange: function (lay_id) {
|
tabChange: function (lay_id) {
|
||||||
element.tabChange('admin-tab', lay_id);
|
element.tabChange("admin-tab", lay_id);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
//添加tab
|
//添加tab
|
||||||
$(document).on('click','a',function(){
|
$(document).on("click", "a", function () {
|
||||||
if(!$(this)[0].hasAttribute('data-url') || $(this).attr('data-url')===''){
|
if (
|
||||||
|
!$(this)[0].hasAttribute("data-url") ||
|
||||||
|
$(this).attr("data-url") === ""
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var tabs = $(".layui-tab-title").children();
|
var tabs = $(".layui-tab-title").children();
|
||||||
|
|
@ -162,53 +185,55 @@ layui.use(['layer', 'element'], function() {
|
||||||
|
|
||||||
//iframe自适应
|
//iframe自适应
|
||||||
function resize() {
|
function resize() {
|
||||||
var $content = $('.admin-nav-card .layui-tab-content');
|
var $content = $(".admin-nav-card .layui-tab-content");
|
||||||
$content.height($(this).height() - 147);
|
$content.height($(this).height() - 147);
|
||||||
$content.find('iframe').each(function() {
|
$content.find("iframe").each(function () {
|
||||||
$(this).height($content.height());
|
$(this).height($content.height());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$(window).on('resize', function() {
|
$(window)
|
||||||
var $content = $('.admin-nav-card .layui-tab-content');
|
.on("resize", function () {
|
||||||
|
var $content = $(".admin-nav-card .layui-tab-content");
|
||||||
$content.height($(this).height() - 147);
|
$content.height($(this).height() - 147);
|
||||||
$content.find('iframe').each(function() {
|
$content.find("iframe").each(function () {
|
||||||
$(this).height($content.height());
|
$(this).height($content.height());
|
||||||
});
|
});
|
||||||
}).resize();
|
})
|
||||||
|
.resize();
|
||||||
|
|
||||||
//toggle左侧菜单
|
//toggle左侧菜单
|
||||||
$('.admin-side-toggle').on('click', function() {
|
$(".admin-side-toggle").on("click", function () {
|
||||||
var sideWidth = $('#admin-side').width();
|
var sideWidth = $("#admin-side").width();
|
||||||
if (sideWidth === 200) {
|
if (sideWidth === 200) {
|
||||||
$('#admin-body').animate({
|
$("#admin-body").animate({
|
||||||
left: '0'
|
left: "0",
|
||||||
});
|
});
|
||||||
$('#admin-footer').animate({
|
$("#admin-footer").animate({
|
||||||
left: '0'
|
left: "0",
|
||||||
});
|
});
|
||||||
$('#admin-side').animate({
|
$("#admin-side").animate({
|
||||||
width: '0'
|
width: "0",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$('#admin-body').animate({
|
$("#admin-body").animate({
|
||||||
left: '200px'
|
left: "200px",
|
||||||
});
|
});
|
||||||
$('#admin-footer').animate({
|
$("#admin-footer").animate({
|
||||||
left: '200px'
|
left: "200px",
|
||||||
});
|
});
|
||||||
$('#admin-side').animate({
|
$("#admin-side").animate({
|
||||||
width: '200px'
|
width: "200px",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//手机设备的简单适配
|
//手机设备的简单适配
|
||||||
var treeMobile = $('.site-tree-mobile'),
|
var treeMobile = $(".site-tree-mobile"),
|
||||||
shadeMobile = $('.site-mobile-shade');
|
shadeMobile = $(".site-mobile-shade");
|
||||||
treeMobile.on('click', function () {
|
treeMobile.on("click", function () {
|
||||||
$('body').addClass('site-mobile');
|
$("body").addClass("site-mobile");
|
||||||
});
|
});
|
||||||
shadeMobile.on('click', function () {
|
shadeMobile.on("click", function () {
|
||||||
$('body').removeClass('site-mobile');
|
$("body").removeClass("site-mobile");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@
|
||||||
var pers = checkPermission();
|
var pers = checkPermission();
|
||||||
initMenuList();
|
initMenuList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function initMenuList() {
|
function initMenuList() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'get',
|
type: 'get',
|
||||||
|
|
@ -107,8 +109,7 @@
|
||||||
tr += "</tr>"
|
tr += "</tr>"
|
||||||
$("#dt-table").append(tr);
|
$("#dt-table").append(tr);
|
||||||
}
|
}
|
||||||
// 递归获取菜单状态
|
|
||||||
getIsCheckFun(data)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -146,18 +147,7 @@
|
||||||
|
|
||||||
$("#dt-table").treetable(option);
|
$("#dt-table").treetable(option);
|
||||||
|
|
||||||
function getIsCheckFun(list) {
|
|
||||||
if (list && list.length > 0) {
|
|
||||||
list.forEach((e) => {
|
|
||||||
if (e.isCheck === 1) {
|
|
||||||
console.log('有待审数据', e)
|
|
||||||
}
|
|
||||||
if (e.child && e.child.length > 0) {
|
|
||||||
getIsCheckFun(e.child)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue