|
|
1
|
+//性能曲线图
|
|
|
2
|
+layui.define(['element', 'admin'], function (exports) {
|
|
|
3
|
+ var $ = layui.$;
|
|
|
4
|
+ var admin = layui.admin;
|
|
|
5
|
+ var domainName = sessionStorage.getItem('domainName');
|
|
|
6
|
+
|
|
|
7
|
+ var obj = {
|
|
|
8
|
+ data: {
|
|
|
9
|
+ contextmenuTips: null,
|
|
|
10
|
+ contextmenus: [],
|
|
|
11
|
+ classNams: []
|
|
|
12
|
+ },
|
|
|
13
|
+ getCurrentHash: function () {
|
|
|
14
|
+ return window.location.hash;
|
|
|
15
|
+ },
|
|
|
16
|
+ init: function () {
|
|
|
17
|
+ var that = this;
|
|
|
18
|
+
|
|
|
19
|
+ if (that.data.contextmenus.length > 0) {
|
|
|
20
|
+ that.bindContextMenuEvent();
|
|
|
21
|
+ return that.data.contextmenus;
|
|
|
22
|
+ }
|
|
|
23
|
+ if('#/user/login/redirect=%2F' == that.getCurrentHash()){
|
|
|
24
|
+ return;
|
|
|
25
|
+ }
|
|
|
26
|
+ // 获取配置的信息
|
|
|
27
|
+ admin.req({
|
|
|
28
|
+ url: domainName + '/api-web/manage/ddic/findSucDdics/contextmenus'
|
|
|
29
|
+ , method: 'POST'
|
|
|
30
|
+ , async: false
|
|
|
31
|
+ , success: function (res) {
|
|
|
32
|
+ $.each(res.data, function (i, v) {
|
|
|
33
|
+ that.data.contextmenus.push(v.ddicCode);
|
|
|
34
|
+ });
|
|
|
35
|
+ that.bindContextMenuEvent();
|
|
|
36
|
+ }
|
|
|
37
|
+ })
|
|
|
38
|
+ },
|
|
|
39
|
+ /**
|
|
|
40
|
+ * 获取当前元素的提示信息
|
|
|
41
|
+ * @param elementName 文本内容
|
|
|
42
|
+ * @param currentEl 当前元素
|
|
|
43
|
+ */
|
|
|
44
|
+ getTipsDetail(elementName, currentEl) {
|
|
|
45
|
+ var that = this;
|
|
|
46
|
+ admin.req({
|
|
|
47
|
+ url: domainName + '/api-web/bHalt'
|
|
|
48
|
+ , data: {
|
|
|
49
|
+ urlHash: that.getCurrentHash(),
|
|
|
50
|
+ elementName: elementName
|
|
|
51
|
+ }
|
|
|
52
|
+ , async: false
|
|
|
53
|
+ , done: function (res) {
|
|
|
54
|
+ var contextmenuEl = '<ul id="tipContextmenu" class="contextmenu-style" style="color:#fff;">';
|
|
|
55
|
+ if (res.data && res.data.length > 0) {
|
|
|
56
|
+ let tipData = res.data;
|
|
|
57
|
+ tipData.map(item => {
|
|
|
58
|
+ contextmenuEl += '<li>' + item.elementExplain + '</li>';
|
|
|
59
|
+ })
|
|
|
60
|
+ } else {
|
|
|
61
|
+ contextmenuEl += '<li>' + elementName + '</li>';
|
|
|
62
|
+ }
|
|
|
63
|
+ contextmenuEl += '</ul>';
|
|
|
64
|
+ that.data.contextmenuTips = layer.tips(contextmenuEl, currentEl, {
|
|
|
65
|
+ time: 0,
|
|
|
66
|
+ tips: [3, '#1e9fff'],
|
|
|
67
|
+ success() {
|
|
|
68
|
+ }
|
|
|
69
|
+ })
|
|
|
70
|
+
|
|
|
71
|
+ setTimeout(function (){
|
|
|
72
|
+ layer.closeAll('tips');
|
|
|
73
|
+ },5000)
|
|
|
74
|
+ }
|
|
|
75
|
+ })
|
|
|
76
|
+ },
|
|
|
77
|
+ bindContextMenuEvent() {
|
|
|
78
|
+ var that = this;
|
|
|
79
|
+ var contextmenus = that.data.contextmenus;
|
|
|
80
|
+
|
|
|
81
|
+ var bindContextEvent = function (selector, index) {
|
|
|
82
|
+ var el = $(selector);
|
|
|
83
|
+
|
|
|
84
|
+ // 超过30秒
|
|
|
85
|
+ if (index > 60) {
|
|
|
86
|
+ return;
|
|
|
87
|
+ }
|
|
|
88
|
+
|
|
|
89
|
+ if (el == null || el.length == 0) {
|
|
|
90
|
+ setTimeout(function () {
|
|
|
91
|
+ bindContextEvent(selector, ++index);
|
|
|
92
|
+ }, 500)
|
|
|
93
|
+ return;
|
|
|
94
|
+ }
|
|
|
95
|
+
|
|
|
96
|
+ el.attr('title', '点击鼠标右键查看功能点描述信息')
|
|
|
97
|
+ el.contextmenu(function (e) {
|
|
|
98
|
+ e.preventDefault();
|
|
|
99
|
+ let thatItem = $(this);
|
|
|
100
|
+ // 获取当前元素名称正则表达式
|
|
|
101
|
+ var reg = sessionStorage.getItem('regular');
|
|
|
102
|
+ let elementName = thatItem.text().replace(reg, "");
|
|
|
103
|
+ that.getTipsDetail(elementName, thatItem);
|
|
|
104
|
+ })
|
|
|
105
|
+ }
|
|
|
106
|
+
|
|
|
107
|
+ // 循环绑定事件
|
|
|
108
|
+ var bind = function (){
|
|
|
109
|
+ $(contextmenus).each(function (index) {
|
|
|
110
|
+ let val = contextmenus[index];
|
|
|
111
|
+
|
|
|
112
|
+ if (val.indexOf('el::') != -1) {
|
|
|
113
|
+ let elName = val.replace('el::', '');
|
|
|
114
|
+ bindContextEvent(elName, 0);
|
|
|
115
|
+ }
|
|
|
116
|
+ })
|
|
|
117
|
+ }
|
|
|
118
|
+
|
|
|
119
|
+ // 获取当前页面,是否在配置中
|
|
|
120
|
+ var page = that.getCurrentHash();
|
|
|
121
|
+ $(contextmenus).each(function (index) {
|
|
|
122
|
+ let val = contextmenus[index];
|
|
|
123
|
+ if (val.indexOf('page::') != -1 ) {
|
|
|
124
|
+ let elName = val.replace('page::', '');
|
|
|
125
|
+ if(elName == page){
|
|
|
126
|
+ bind();
|
|
|
127
|
+ return;
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+ })
|
|
|
131
|
+
|
|
|
132
|
+ // 点击关闭所有tips
|
|
|
133
|
+ $(document).on('click', function (event) {
|
|
|
134
|
+ layer.closeAll('tips');
|
|
|
135
|
+ })
|
|
|
136
|
+ }
|
|
|
137
|
+ }
|
|
|
138
|
+
|
|
|
139
|
+ // 页面刷新默认初始化
|
|
|
140
|
+ setTimeout(function () {
|
|
|
141
|
+ obj.init();
|
|
|
142
|
+ }, 1000)
|
|
|
143
|
+
|
|
|
144
|
+ //对外暴露 的接口
|
|
|
145
|
+ exports('pageTips', obj);
|
|
|
146
|
+}); |