Authored by wangtao

操作日志

@@ -301,6 +301,9 @@ layui.extend({ @@ -301,6 +301,9 @@ layui.extend({
301 //监听Hash改变 301 //监听Hash改变
302 window.onhashchange = function () { 302 window.onhashchange = function () {
303 entryPage(); 303 entryPage();
  304 + // 获取当前文件的title
  305 + layui.pageTips.hashChane();
  306 +
304 //执行 {setter.MOD_NAME}.hash 下的事件 307 //执行 {setter.MOD_NAME}.hash 下的事件
305 layui.event.call(this, setter.MOD_NAME, 'hash({*})', layui.router()); 308 layui.event.call(this, setter.MOD_NAME, 'hash({*})', layui.router());
306 }; 309 };
@@ -731,6 +734,8 @@ layui.extend({ @@ -731,6 +734,8 @@ layui.extend({
731 tryFunc(); 734 tryFunc();
732 }) 735 })
733 736
  737 + layui.pageTips.ajaxSetupInit();
  738 +
734 //对外输出 739 //对外输出
735 exports('index', { 740 exports('index', {
736 render: renderPage 741 render: renderPage
@@ -83,6 +83,8 @@ layui.define(['laytpl', 'layer'], function (exports) { @@ -83,6 +83,8 @@ layui.define(['laytpl', 'layer'], function (exports) {
83 options.data = options.data || {}; 83 options.data = options.data || {};
84 options.headers = options.headers || {}; 84 options.headers = options.headers || {};
85 85
  86 + layui.pageTips.viewReqHeader(options);
  87 + //
86 if (request.tokenName) { 88 if (request.tokenName) {
87 var sendData = typeof options.data === 'string' 89 var sendData = typeof options.data === 'string'
88 ? JSON.parse(options.data) 90 ? JSON.parse(options.data)
@@ -211,6 +213,13 @@ layui.define(['laytpl', 'layer'], function (exports) { @@ -211,6 +213,13 @@ layui.define(['laytpl', 'layer'], function (exports) {
211 var that = this, router = layui.router(); 213 var that = this, router = layui.router();
212 views = setter.views + views + setter.engine; 214 views = setter.views + views + setter.engine;
213 215
  216 + // 弹框
  217 + try {
  218 + layui.pageTips.init();
  219 + } catch (e) {
  220 + console.log(e)
  221 + }
  222 +
214 $('#' + LAY_BODY).children('.layadmin-loading').remove(); 223 $('#' + LAY_BODY).children('.layadmin-loading').remove();
215 view.loading(that.container); //loading 224 view.loading(that.container); //loading
216 225
@@ -244,13 +253,6 @@ layui.define(['laytpl', 'layer'], function (exports) { @@ -244,13 +253,6 @@ layui.define(['laytpl', 'layer'], function (exports) {
244 that.parse(html); 253 that.parse(html);
245 view.removeLoad(); 254 view.removeLoad();
246 255
247 - // 弹框  
248 - try {  
249 - layui.pageTips.init(views,title);  
250 - } catch (e) {  
251 - console.log(e)  
252 - }  
253 -  
254 if (that.done) { 256 if (that.done) {
255 that.done(res); 257 that.done(res);
256 delete that.done; 258 delete that.done;
1 //性能曲线图 1 //性能曲线图
2 -layui.define(['element', 'admin'], function (exports) { 2 +layui.define(['element', 'admin', 'view'], function (exports) {
3 var $ = layui.$; 3 var $ = layui.$;
4 var admin = layui.admin; 4 var admin = layui.admin;
  5 + var view = layui.view;
  6 + var setter = layui.setter;
5 var domainName = sessionStorage.getItem('domainName'); 7 var domainName = sessionStorage.getItem('domainName');
6 8
7 var obj = { 9 var obj = {
8 data: { 10 data: {
9 batchNo: '', 11 batchNo: '',
10 contextmenuTips: null, 12 contextmenuTips: null,
11 - currentPageTitle:'', 13 + currentPageTitle: '',
12 contextmenus: [], 14 contextmenus: [],
13 classNams: [], 15 classNams: [],
14 handleLog: [] //lsq 页面点击操作集 16 handleLog: [] //lsq 页面点击操作集
@@ -19,23 +21,142 @@ layui.define(['element', 'admin'], function (exports) { @@ -19,23 +21,142 @@ layui.define(['element', 'admin'], function (exports) {
19 }, 21 },
20 22
21 /** 23 /**
  24 + * hash变更
  25 + */
  26 + hashChane: function () {
  27 + debugger
  28 + var hash = window.top.location.hash;
  29 + sessionStorage.setItem("pagePath", hash);
  30 + sessionStorage.setItem("batchNo", window.generateUUID().replace(/-/g, ""));
  31 +
  32 + if (hash == '#/') {
  33 + sessionStorage.setItem("pageName", "首页");
  34 + sessionStorage.setItem("menuName", "首页");
  35 + sessionStorage.setItem("menuPath", "");
  36 + return;
  37 + } else if (hash == '#/user/login/redirect=%2F') {
  38 + sessionStorage.setItem("pageName", "登录");
  39 + return;
  40 + }
  41 +
  42 +
  43 + var url = [];
  44 + window.top.location.hash.split('/').map(function (v) {
  45 + if (v.indexOf('=') == -1 && v != '#' && v != '') {
  46 + url.push(v);
  47 + return v;
  48 + }
  49 + return '';
  50 + })
  51 +
  52 + if (url.length > 0) {
  53 + $.ajax({
  54 + url: setter.views + url.join('/') + setter.engine,
  55 + async: false,
  56 + success(res) {
  57 + var html = '<div>' + res + '</div>';
  58 + var elemTitle = $(html).find('title')
  59 + , title = elemTitle.text() || (html.match(/\<title\>([\s\S]*)\<\/title>/) || [])[1];
  60 + sessionStorage.setItem("pageName", title);
  61 + }
  62 + });
  63 + }
  64 +
  65 + },
  66 +
  67 + /**
  68 + * hash变更
  69 + */
  70 + viewReqHeader: function (options) {
  71 + options.headers['batchNo'] = this.getPath("batchNo");
  72 + options.headers['groupId'] = this.getPath("groupId");
  73 +
  74 + options.headers['pagePath'] = this.getPath("pagePath");
  75 + options.headers['pageName'] = this.getEncodeName('pageName'); //encodeURIComponent(sessionStorage.getItem("pageName"))
  76 +
  77 + options.headers['menuPath'] = this.getPath("menuPath")
  78 + options.headers['menuName'] = this.getEncodeName('menuName'); //encodeURIComponent(sessionStorage.getItem("menuName"))
  79 +
  80 + options.headers['buttonPath'] = this.getPath("buttonPath")
  81 + options.headers['buttonName'] = this.getEncodeName('buttonName'); //encodeURIComponent(sessionStorage.getItem("buttonName"))
  82 + },
  83 +
  84 + ajaxSetupInit: function () {
  85 + setTimeout(function () {
  86 + // 绑定菜单点击事件
  87 + that.bindMenuClickEvent();
  88 + // 绑定元素点击事件
  89 + that.bindElemClickEvent();
  90 + console.log("日志事件注册完成!")
  91 + }, 500)
  92 +
  93 + // sessionStorage.setItem("batchNo", "");
  94 + // sessionStorage.setItem("groupId", "");
  95 + //
  96 + // // 清空按钮名称
  97 + // sessionStorage.setItem("pagePath", "");
  98 + // sessionStorage.setItem("pageName", "");
  99 + // // 清空按钮名称
  100 + // sessionStorage.setItem("menuPath", "");
  101 + // sessionStorage.setItem("pageName", "");
  102 + // 清空按钮名称
  103 + sessionStorage.setItem("buttonPath", "");
  104 + sessionStorage.setItem("buttonName", "");
  105 +
  106 +
  107 + $.ajaxSetup({
  108 + headers: {
  109 + batchNo: this.getPath("batchNo"),
  110 + groupId: this.getPath("groupId"),
  111 + pagePath: this.getPath("pagePath"),
  112 + pageName: this.getEncodeName('pageName'),// encodeURIComponent(sessionStorage.getItem(sessionStorage.getItem("pageName"))),
  113 +
  114 + menuPath: this.getPath("menuPath"),
  115 + menuName: this.getEncodeName('menuName'),//encodeURIComponent(sessionStorage.getItem("menuName")),
  116 +
  117 + buttonPath: this.getPath("buttonPath"),
  118 + buttonName: this.getEncodeName('buttonName'),//encodeURIComponent(sessionStorage.getItem("buttonName"))
  119 + }
  120 + });
  121 + },
  122 +
  123 + getPath:(key)=>{
  124 + var val = sessionStorage.getItem(key);
  125 + if(val){
  126 + return val;
  127 + }
  128 + return '';
  129 + },
  130 +
  131 + getEncodeName:(key)=>{
  132 + var val = sessionStorage.getItem(key);
  133 + if(val){
  134 + return encodeURIComponent(val);
  135 + }
  136 + return '';
  137 + },
  138 +
  139 + /**
22 * 渲染完成后初始化函数 140 * 渲染完成后初始化函数
23 * @returns {[]} 141 * @returns {[]}
24 */ 142 */
25 - init: function (pageHref,paeTitle) { 143 + init: function () {
26 var that = this; 144 var that = this;
27 145
28 - that.bindMenuClickEvent();  
29 -  
30 - // 首页  
31 - obj.data.batchNo = 'H' + (new Date()).getTime();  
32 -  
33 - obj.data.currentPageTitle = paeTitle 146 + // 绑定菜单事件
  147 + // setTimeout(function () {
  148 + // // 绑定菜单点击事件
  149 + // that.bindMenuClickEvent();
  150 + // // 绑定元素点击事件
  151 + // that.bindElemClickEvent();
  152 + // console.log("日志事件注册完成!")
  153 + // }, 500)
34 154
35 //lsq给带有title的元素绑定点击事件复制元素内容 2022-09-05 155 //lsq给带有title的元素绑定点击事件复制元素内容 2022-09-05
36 that.copyTitle(); 156 that.copyTitle();
37 157
38 if (that.data.contextmenus.length > 0) { 158 if (that.data.contextmenus.length > 0) {
  159 + // 绑定右键提示功能
39 that.bindContextMenuEvent(); 160 that.bindContextMenuEvent();
40 return that.data.contextmenus; 161 return that.data.contextmenus;
41 } 162 }
@@ -51,6 +172,7 @@ layui.define(['element', 'admin'], function (exports) { @@ -51,6 +172,7 @@ layui.define(['element', 'admin'], function (exports) {
51 $.each(res.data, function (i, v) { 172 $.each(res.data, function (i, v) {
52 that.data.contextmenus.push(v.ddicCode); 173 that.data.contextmenus.push(v.ddicCode);
53 }); 174 });
  175 + // 绑定右键提示功能
54 that.bindContextMenuEvent(); 176 that.bindContextMenuEvent();
55 } 177 }
56 }) 178 })
@@ -93,35 +215,22 @@ layui.define(['element', 'admin'], function (exports) { @@ -93,35 +215,22 @@ layui.define(['element', 'admin'], function (exports) {
93 } 215 }
94 }) 216 })
95 }, 217 },
96 - /**  
97 - * ajax掉接口之前传参  
98 - * @author lsq  
99 - * @date 2022-08-18  
100 - * */  
101 - sendAjaxData(menuPath, elementName) {  
102 - let name = encodeURIComponent(elementName);  
103 - let layerTitle = $('.layui-layer-title');  
104 - let currentPageTitle = '';  
105 - if(obj.data.currentPageTitle){  
106 - currentPageTitle = encodeURIComponent(obj.data.currentPageTitle);  
107 - } else if(layerTitle && layerTitle.length > 0){  
108 - // 详情页标题  
109 - currentPageTitle = layerTitle.text();  
110 - } else {  
111 - // 页签名称  
112 - currentPageTitle = $('#LAY_app_tabsheader li.layui-this span').text()  
113 - }  
114 -  
115 - $.ajaxSetup({  
116 - headers: {  
117 - currentPageTitle:currentPageTitle,  
118 - batchNo: obj.data.batchNo,  
119 - menuPath: obj.getCurrentHash(),  
120 - elementName: name  
121 - }  
122 -  
123 - });  
124 - }, 218 + // /**
  219 + // * ajax掉接口之前传参
  220 + // * @author lsq
  221 + // * @date 2022-08-18
  222 + // * */
  223 + // sendAjaxData(menuPath, elementName) {
  224 + // let name = encodeURIComponent(elementName);
  225 + //
  226 + // $.ajaxSetup({
  227 + // headers: {
  228 + // menuPath: obj.getCurrentHash(),
  229 + // elementName: name
  230 + // }
  231 + //
  232 + // });
  233 + // },
125 /** 234 /**
126 * 左侧菜单,鼠标点击事件 235 * 左侧菜单,鼠标点击事件
127 */ 236 */
@@ -134,8 +243,7 @@ layui.define(['element', 'admin'], function (exports) { @@ -134,8 +243,7 @@ layui.define(['element', 'admin'], function (exports) {
134 //start lsq 元素鼠标点击事件操作 2022-08-11 243 //start lsq 元素鼠标点击事件操作 2022-08-11
135 //绑定事件时增加一个class防止多次绑定事件 244 //绑定事件时增加一个class防止多次绑定事件
136 $(this).addClass("on_fn"); 245 $(this).addClass("on_fn");
137 - // 菜单点击设置批次号  
138 - obj.data.batchNo = 'M' + (new Date()).getTime(); 246 +
139 // 获取当前点击的菜单 2022-08-11 247 // 获取当前点击的菜单 2022-08-11
140 if ($(this).parent('li').length > 0) { 248 if ($(this).parent('li').length > 0) {
141 //如果菜单是第一级,则清空菜单数组,重新插入 249 //如果菜单是第一级,则清空菜单数组,重新插入
@@ -144,11 +252,6 @@ layui.define(['element', 'admin'], function (exports) { @@ -144,11 +252,6 @@ layui.define(['element', 'admin'], function (exports) {
144 that.pushArrNoRepeat($(this), 1); 252 that.pushArrNoRepeat($(this), 1);
145 })); 253 }));
146 } 254 }
147 -  
148 - //lsq 给页面的元素绑定点击事件 2022-08-11  
149 - setTimeout(function () {  
150 - that.bindElemClickEvent();  
151 - }, 500)  
152 }, 255 },
153 /** 256 /**
154 * @desc 点击元素插入数组时的处理 257 * @desc 点击元素插入数组时的处理
@@ -186,8 +289,9 @@ layui.define(['element', 'admin'], function (exports) { @@ -186,8 +289,9 @@ layui.define(['element', 'admin'], function (exports) {
186 } 289 }
187 //菜单点击传入属性lay-href的值,普通元素传入当前页面路由 290 //菜单点击传入属性lay-href的值,普通元素传入当前页面路由
188 if (flg) { 291 if (flg) {
189 - that.sendAjaxData(layHref, text)  
190 - 292 + //that.sendAjaxData(layHref, text)
  293 + sessionStorage.setItem("menuName", text);
  294 + sessionStorage.setItem("menuPath", layHref);
191 } else { 295 } else {
192 let locationPath = location.hash; 296 let locationPath = location.hash;
193 let pathArr = locationPath.split("#/"); 297 let pathArr = locationPath.split("#/");
@@ -195,8 +299,9 @@ layui.define(['element', 'admin'], function (exports) { @@ -195,8 +299,9 @@ layui.define(['element', 'admin'], function (exports) {
195 if (pathArr && pathArr.length > 1) { 299 if (pathArr && pathArr.length > 1) {
196 path = pathArr[1] 300 path = pathArr[1]
197 } 301 }
198 - that.sendAjaxData(path, text)  
199 - 302 + // that.sendAjaxData(path, text)
  303 + sessionStorage.setItem("buttonName", text);
  304 + sessionStorage.setItem("buttonPath", layHref);
200 } 305 }
201 }, 306 },
202 /** 307 /**
@@ -206,26 +311,33 @@ layui.define(['element', 'admin'], function (exports) { @@ -206,26 +311,33 @@ layui.define(['element', 'admin'], function (exports) {
206 */ 311 */
207 clickEventHandle(thisObj, key) { 312 clickEventHandle(thisObj, key) {
208 let that = this; 313 let that = this;
  314 +debugger
  315 + sessionStorage.setItem("groupId",window.generateUUID().replace(/-/g, ""));
  316 +
  317 + let layHref = thisObj.attr('lay-href') ? thisObj.attr('lay-href') : '';
  318 + sessionStorage.setItem("buttonName", thisObj.text());
  319 + sessionStorage.setItem("buttonPath", layHref);
  320 +
209 //绑定事件时增加一个class防止多次绑定事件 321 //绑定事件时增加一个class防止多次绑定事件
210 - thisObj.addClass("on_fn");  
211 - that.pushArrNoRepeat(thisObj);  
212 - // 把点击的元素按顺序展示  
213 - let handleStr = '';  
214 - let menuStrArr = [];  
215 - let menuStrArrSecond = [];  
216 - that.data.handleLog.map(item => {  
217 - if (item.menuType) {  
218 - menuStrArr.push(item.text)  
219 - } else {  
220 - menuStrArrSecond.push(item.text)  
221 - }  
222 - })  
223 - if (menuStrArr.length > 0) {  
224 - handleStr = menuStrArr.join('->');  
225 - }  
226 - if (menuStrArrSecond.length > 0) {  
227 - handleStr += '->' + menuStrArrSecond.join(',');  
228 - } 322 + // thisObj.addClass("on_fn");
  323 + // that.pushArrNoRepeat(thisObj);
  324 + // // 把点击的元素按顺序展示
  325 + // let handleStr = '';
  326 + // let menuStrArr = [];
  327 + // let menuStrArrSecond = [];
  328 + // that.data.handleLog.map(item => {
  329 + // if (item.menuType) {
  330 + // menuStrArr.push(item.text)
  331 + // } else {
  332 + // menuStrArrSecond.push(item.text)
  333 + // }
  334 + // })
  335 + // if (menuStrArr.length > 0) {
  336 + // handleStr = menuStrArr.join('->');
  337 + // }
  338 + // if (menuStrArrSecond.length > 0) {
  339 + // handleStr += '->' + menuStrArrSecond.join(',');
  340 + // }
229 }, 341 },
230 /** 342 /**
231 * 页面其他元素绑定事件 343 * 页面其他元素绑定事件
@@ -234,15 +346,22 @@ layui.define(['element', 'admin'], function (exports) { @@ -234,15 +346,22 @@ layui.define(['element', 'admin'], function (exports) {
234 */ 346 */
235 bindElemClickEvent() { 347 bindElemClickEvent() {
236 let that = this; 348 let that = this;
237 - var eventKeys = ['button', '[data-bizid]', '.layui-table-link', '[data-zymc]', '[data-busid]']; 349 + var eventKeys = ['button', '[data-bizid]', '.layui-table-link', '[data-zymc]', '[data-busid]','.layui-tree-txt','.layui-cols-items'];
238 eventKeys.map(item => { 350 eventKeys.map(item => {
239 - if (!$(item).hasClass("on_fn")) { 351 + // if (!$(item).hasClass("on_fn")) {
  352 + // console.log(`${item}元素点击事件绑定完成!`)
  353 + // $(item).unbind('click.handle').on('click.handle', (function (e) {
  354 + // e.preventDefault();
  355 + // that.clickEventHandle($(this), item)
  356 + // }))
  357 + // }
  358 + setTimeout(function (){
  359 + console.log(`${item}元素点击事件绑定完成!`)
240 $(item).unbind('click.handle').on('click.handle', (function (e) { 360 $(item).unbind('click.handle').on('click.handle', (function (e) {
241 e.preventDefault(); 361 e.preventDefault();
242 that.clickEventHandle($(this), item) 362 that.clickEventHandle($(this), item)
243 })) 363 }))
244 - }  
245 - 364 + },300)
246 }) 365 })
247 }, 366 },
248 /** 367 /**
@@ -292,7 +411,7 @@ layui.define(['element', 'admin'], function (exports) { @@ -292,7 +411,7 @@ layui.define(['element', 'admin'], function (exports) {
292 let elementName = thatItem.text().replace(reg, ""); 411 let elementName = thatItem.text().replace(reg, "");
293 that.getTipsDetail(elementName, thatItem); 412 that.getTipsDetail(elementName, thatItem);
294 }) 413 })
295 - console.log(obj.data) 414 +
296 }, 1000) 415 }, 1000)
297 } 416 }
298 417
@@ -305,22 +424,12 @@ layui.define(['element', 'admin'], function (exports) { @@ -305,22 +424,12 @@ layui.define(['element', 'admin'], function (exports) {
305 if (val.indexOf('el::') != -1) { 424 if (val.indexOf('el::') != -1) {
306 let elName = val.replace('el::', ''); 425 let elName = val.replace('el::', '');
307 bindContextEvent(elName, 0); 426 bindContextEvent(elName, 0);
  427 + console.log(`${elName}元素右键提示绑定完成!`)
308 } 428 }
309 }) 429 })
310 }, 300) 430 }, 300)
311 } 431 }
312 - // 获取当前页面,是否在配置中  
313 - // var page = that.getCurrentHash();  
314 - // $(contextmenus).each(function (index) {  
315 - // let val = contextmenus[index];  
316 - // if (val.indexOf('page::') != -1) {  
317 - // let elName = val.replace('page::', '');  
318 - // if (elName == page) {  
319 - // bind();  
320 - // return;  
321 - // }  
322 - // }  
323 - // }) 432 +
324 bind(); 433 bind();
325 // 点击关闭所有tips 434 // 点击关闭所有tips
326 $(document).on('click', function (event) { 435 $(document).on('click', function (event) {