大屏更新、源头管理
This commit is contained in:
@ -493,89 +493,12 @@ function getMpPic() {
|
||||
|
||||
function initMenu() {
|
||||
var menu = $('#menu');
|
||||
|
||||
// 定义一个内部函数来执行DOM操作添加菜单
|
||||
var appendS223Menu = function() {
|
||||
var $menu = $('#menu');
|
||||
|
||||
// 查找“纳管企业清单”所在的菜单项
|
||||
// 情况1: 一级菜单,名称在 span 中
|
||||
var $targetSpan = $menu.find("span").filter(function() {
|
||||
return $(this).text().trim() === '纳管企业清单';
|
||||
});
|
||||
|
||||
var $targetLi = null;
|
||||
|
||||
if ($targetSpan.length > 0) {
|
||||
$targetLi = $targetSpan.closest('li');
|
||||
} else {
|
||||
// 情况2: 二级菜单,名称直接在 a 标签中(可能是文本节点)
|
||||
var $targetLink = $menu.find('a').filter(function() {
|
||||
// 克隆节点,移除子元素(如图标),只获取自身的文本
|
||||
return $(this).clone().children().remove().end().text().trim() === '纳管企业清单';
|
||||
});
|
||||
if ($targetLink.length > 0) {
|
||||
$targetLi = $targetLink.closest('li');
|
||||
}
|
||||
}
|
||||
|
||||
if ($targetLi && $targetLi.length > 0) {
|
||||
var $treeviewMenu = $targetLi.find('> .treeview-menu');
|
||||
|
||||
// 确保 treeview-menu 存在
|
||||
if ($treeviewMenu.length === 0) {
|
||||
$treeviewMenu = $('<ul class="treeview-menu"></ul>');
|
||||
$targetLi.append($treeviewMenu);
|
||||
}
|
||||
|
||||
// 检查是否已经添加过,防止重复添加
|
||||
// 注意:新菜单项可能直接是文本,也可能包含 i 标签
|
||||
var exists = false;
|
||||
$treeviewMenu.find('li').each(function() {
|
||||
// if ($(this).text().indexOf('管道管理') > -1) {
|
||||
// exists = true;
|
||||
// }
|
||||
});
|
||||
|
||||
if (!exists) {
|
||||
// 根据层级决定样式,通常二级或三级菜单项不需要 span 包裹文字,或者保持一致
|
||||
// 这里的样式参考了 menuitems.jsp 中的 Level 3: <li><a ...><i ...></i> Name</a></li>
|
||||
// 使用 addTab 函数而不是 refreshPage,以支持在 tab 页中打开(如果系统支持)或者在当前 iframe 打开
|
||||
// 检查 addTab 是否存在,如果存在则使用它,否则回退到 refreshPage
|
||||
var newMenuHtml = '';
|
||||
if (typeof addTab === 'function') {
|
||||
// 假设 addTab(id, name, url)
|
||||
} else {
|
||||
// 如果没有 addTab,尝试使用 iframe 加载或者直接跳转(但在框架内)
|
||||
// refreshPage 通常是 location.replace,这会刷新整个页面。
|
||||
// 如果目标是内嵌,我们应该寻找 iframe 的加载方式。
|
||||
// 查看 comm.js 其他部分,发现有 refreshPage(url) 实现为 location.replace(url)。
|
||||
// 如果要内嵌,通常是设置某个 iframe 的 src。
|
||||
// 假设主内容区域是一个 iframe,或者支持通过 data-url 加载。
|
||||
// 暂时使用 refreshPage,但确认它是在当前窗口(iframe)中加载,而不是弹出新窗口。
|
||||
// 用户反馈说“不要新开特么弹窗”,可能是指 window.open 或者 target="_blank"。
|
||||
// refreshPage 使用 location.replace,是在当前窗口打开。
|
||||
// 如果当前窗口是整个 index 页面,那就会刷新整个页面。
|
||||
// 如果是 SPA 或者 iframe 架构,我们需要找到正确的方法。
|
||||
|
||||
// 观察 menuitems.jsp,发现二级菜单使用 addTab('${cumcl2.id}','${cumcl2.name}','${cumcl2.location}')
|
||||
// 所以我们应该优先使用 addTab。
|
||||
// 如果 addTab 未定义(可能在 index.jsp 中定义),我们尝试模拟它。
|
||||
// 由于 comm.js 被 index.jsp 引用,addTab 应该可用。
|
||||
}
|
||||
$treeviewMenu.append(newMenuHtml);
|
||||
|
||||
// 确保父菜单是展开状态(可选)
|
||||
// $targetLi.addClass('active menu-open');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (sessionStorage.menu != undefined) {
|
||||
$('#menu').html(sessionStorage.menu);
|
||||
|
||||
// 即使是缓存加载,也尝试添加新菜单
|
||||
appendS223Menu();
|
||||
// 更新大屏菜单的onclick事件,确保使用全屏功能
|
||||
updateBigScreenMenuEvents();
|
||||
|
||||
if (sessionStorage.m1 != undefined) {
|
||||
$('#' + sessionStorage.m1).addClass('treeview active menu-open')
|
||||
@ -589,29 +512,8 @@ function initMenu() {
|
||||
//return;
|
||||
} else {
|
||||
$.post(ext.contextPath + "/user/showMenuListByCu.do", {}, function (result) {
|
||||
var bigScreenHtml = '<li class="treeview">' +
|
||||
'<a href="#">' +
|
||||
'<i class="fa fa-desktop"></i> <span>大屏展示</span>' +
|
||||
'<span class="pull-right-container">' +
|
||||
'<i class="fa fa-angle-left pull-right"></i>' +
|
||||
'</span>' +
|
||||
'</a>' +
|
||||
'<ul class="treeview-menu">' +
|
||||
'<li><a href="javascript:void(0);" onclick="window.open(\'' + ext.contextPath + '/jsp/bigScreen.jsp\', \'_blank\');"><i class="fa fa-circle-o"></i> 水厂大屏</a></li>' +
|
||||
'<li><a href="javascript:void(0);" onclick="window.open(\'' + ext.contextPath + '/jsp/bigScreen2.jsp\', \'_blank\');"><i class="fa fa-circle-o"></i> 区域管线大屏</a></li>' +
|
||||
'<li><a href="javascript:void(0);" onclick="window.open(\'' + ext.contextPath + '/jsp/bigScreen3.jsp\', \'_blank\');"><i class="fa fa-circle-o"></i> 排污户大屏</a></li>' +
|
||||
'</ul>' +
|
||||
'</li>';
|
||||
result = result + bigScreenHtml;
|
||||
// 替换源头GIS管理页面链接为JSP
|
||||
result = result.replace('newSourceGISPage.html', 'newSourceGISPage.jsp');
|
||||
result = result.replace('newGIS.html', 'newSourceGISPage.jsp');
|
||||
|
||||
$('#menu').html(result);
|
||||
|
||||
// 在设置HTML后执行DOM注入
|
||||
appendS223Menu();
|
||||
|
||||
sessionStorage.setItem("menu", $('#menu').html()); // 保存修改后的HTML到sessionStorage
|
||||
|
||||
if (sessionStorage.m1 != undefined) {
|
||||
@ -647,6 +549,51 @@ function initMenuScroll(menu) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取浏览器当前缩放比例
|
||||
* @returns 100为100%
|
||||
*/
|
||||
/**
|
||||
* 打开全屏窗口
|
||||
* @param url 页面URL
|
||||
*/
|
||||
function openFullScreenWindow(url) {
|
||||
// 打开新窗口,使用屏幕全部尺寸
|
||||
var width = screen.width;
|
||||
var height = screen.height;
|
||||
var newWindow = window.open(url, '_blank',
|
||||
'width=' + width + ',height=' + height +
|
||||
',top=0,left=0,menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=no');
|
||||
|
||||
// 尝试让新窗口获得焦点
|
||||
if (newWindow) {
|
||||
newWindow.focus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新大屏菜单的点击事件,确保使用全屏功能
|
||||
* 用于处理缓存菜单的情况
|
||||
*/
|
||||
function updateBigScreenMenuEvents() {
|
||||
// 查找所有大屏菜单项并更新onclick事件
|
||||
$('#menu a').each(function() {
|
||||
var text = $(this).text().trim();
|
||||
var url = '';
|
||||
if (text === '水厂大屏') {
|
||||
url = ext.contextPath + '/jsp/bigScreen.jsp';
|
||||
} else if (text === '区域管线大屏') {
|
||||
url = ext.contextPath + '/jsp/bigScreen2.jsp';
|
||||
} else if (text === '排污户大屏') {
|
||||
url = ext.contextPath + '/jsp/bigScreen3.jsp';
|
||||
}
|
||||
if (url) {
|
||||
$(this).attr('href', 'javascript:void(0);');
|
||||
$(this).attr('onclick', 'openFullScreenWindow(\'' + url + '\');');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取浏览器当前缩放比例
|
||||
* @returns 100为100%
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user