|
|
//性能曲线图
|
|
|
layui.define(['element', 'admin'], function (exports) {
|
|
|
var $ = layui.$;
|
|
|
var admin = layui.admin;
|
|
|
var domainName = sessionStorage.getItem('domainName');
|
|
|
|
|
|
var obj = {
|
|
|
data: {
|
|
|
contextmenuTips: null,
|
|
|
contextmenus: [],
|
|
|
classNams: []
|
|
|
},
|
|
|
getCurrentHash: function () {
|
|
|
return window.location.hash;
|
|
|
},
|
|
|
init: function () {
|
|
|
var that = this;
|
|
|
|
|
|
if (that.data.contextmenus.length > 0) {
|
|
|
that.bindContextMenuEvent();
|
|
|
return that.data.contextmenus;
|
|
|
}
|
|
|
if('#/user/login/redirect=%2F' == that.getCurrentHash()){
|
|
|
return;
|
|
|
}
|
|
|
// 获取配置的信息
|
|
|
admin.req({
|
|
|
url: domainName + '/api-web/manage/ddic/findSucDdics/contextmenus'
|
|
|
, method: 'POST'
|
|
|
, async: false
|
|
|
, success: function (res) {
|
|
|
$.each(res.data, function (i, v) {
|
|
|
that.data.contextmenus.push(v.ddicCode);
|
|
|
});
|
|
|
that.bindContextMenuEvent();
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 获取当前元素的提示信息
|
|
|
* @param elementName 文本内容
|
|
|
* @param currentEl 当前元素
|
|
|
*/
|
|
|
getTipsDetail(elementName, currentEl) {
|
|
|
var that = this;
|
|
|
admin.req({
|
|
|
url: domainName + '/api-web/bHalt'
|
|
|
, data: {
|
|
|
urlHash: that.getCurrentHash(),
|
|
|
elementName: elementName
|
|
|
}
|
|
|
, async: false
|
|
|
, done: function (res) {
|
|
|
var contextmenuEl = '<ul id="tipContextmenu" class="contextmenu-style" style="color:#fff;">';
|
|
|
if (res.data && res.data.length > 0) {
|
|
|
let tipData = res.data;
|
|
|
tipData.map(item => {
|
|
|
contextmenuEl += '<li>' + item.elementExplain + '</li>';
|
|
|
})
|
|
|
} else {
|
|
|
contextmenuEl += '<li>' + elementName + '</li>';
|
|
|
}
|
|
|
contextmenuEl += '</ul>';
|
|
|
that.data.contextmenuTips = layer.tips(contextmenuEl, currentEl, {
|
|
|
time: 0,
|
|
|
tips: [3, '#1e9fff'],
|
|
|
success() {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
setTimeout(function (){
|
|
|
layer.closeAll('tips');
|
|
|
},5000)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
bindContextMenuEvent() {
|
|
|
var that = this;
|
|
|
var contextmenus = that.data.contextmenus;
|
|
|
|
|
|
var bindContextEvent = function (selector, index) {
|
|
|
var el = $(selector);
|
|
|
|
|
|
// 超过30秒
|
|
|
if (index > 60) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (el == null || el.length == 0) {
|
|
|
setTimeout(function () {
|
|
|
bindContextEvent(selector, ++index);
|
|
|
}, 500)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
el.attr('title', '点击鼠标右键查看功能点描述信息')
|
|
|
el.contextmenu(function (e) {
|
|
|
e.preventDefault();
|
|
|
let thatItem = $(this);
|
|
|
// 获取当前元素名称正则表达式
|
|
|
var reg = sessionStorage.getItem('regular');
|
|
|
let elementName = thatItem.text().replace(reg, "");
|
|
|
that.getTipsDetail(elementName, thatItem);
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 循环绑定事件
|
|
|
var bind = function (){
|
|
|
$(contextmenus).each(function (index) {
|
|
|
let val = contextmenus[index];
|
|
|
|
|
|
if (val.indexOf('el::') != -1) {
|
|
|
let elName = val.replace('el::', '');
|
|
|
bindContextEvent(elName, 0);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 获取当前页面,是否在配置中
|
|
|
var page = that.getCurrentHash();
|
|
|
$(contextmenus).each(function (index) {
|
|
|
let val = contextmenus[index];
|
|
|
if (val.indexOf('page::') != -1 ) {
|
|
|
let elName = val.replace('page::', '');
|
|
|
if(elName == page){
|
|
|
bind();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
// 点击关闭所有tips
|
|
|
$(document).on('click', function (event) {
|
|
|
layer.closeAll('tips');
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 页面刷新默认初始化
|
|
|
setTimeout(function () {
|
|
|
obj.init();
|
|
|
}, 1000)
|
|
|
|
|
|
//对外暴露 的接口
|
|
|
exports('pageTips', obj);
|
|
|
}); |
...
|
...
|
|