Authored by wangtao

操作日志

@@ -246,7 +246,7 @@ layui.define(['laytpl', 'layer'], function (exports) { @@ -246,7 +246,7 @@ layui.define(['laytpl', 'layer'], function (exports) {
246 246
247 // 弹框 247 // 弹框
248 try { 248 try {
249 - layui.pageTips.init(); 249 + layui.pageTips.init(views,title);
250 } catch (e) { 250 } catch (e) {
251 console.log(e) 251 console.log(e)
252 } 252 }
@@ -6,18 +6,31 @@ layui.define(['element', 'admin'], function (exports) { @@ -6,18 +6,31 @@ layui.define(['element', 'admin'], function (exports) {
6 6
7 var obj = { 7 var obj = {
8 data: { 8 data: {
  9 + batchNo: '',
9 contextmenuTips: null, 10 contextmenuTips: null,
  11 + currentPageTitle:'',
10 contextmenus: [], 12 contextmenus: [],
11 classNams: [], 13 classNams: [],
12 handleLog: [] //lsq 页面点击操作集 14 handleLog: [] //lsq 页面点击操作集
13 }, 15 },
  16 + // 获取当前路由
14 getCurrentHash: function () { 17 getCurrentHash: function () {
15 return window.location.hash; 18 return window.location.hash;
16 }, 19 },
17 - init: function () { 20 +
  21 + /**
  22 + * 渲染完成后初始化函数
  23 + * @returns {[]}
  24 + */
  25 + init: function (pageHref,paeTitle) {
18 var that = this; 26 var that = this;
19 27
20 - that.bindClickEvent(); 28 + that.bindMenuClickEvent();
  29 +
  30 + // 首页
  31 + obj.data.batchNo = 'H' + (new Date()).getTime();
  32 +
  33 + obj.data.currentPageTitle = paeTitle
21 34
22 //lsq给带有title的元素绑定点击事件复制元素内容 2022-09-05 35 //lsq给带有title的元素绑定点击事件复制元素内容 2022-09-05
23 that.copyTitle(); 36 that.copyTitle();
@@ -85,42 +98,57 @@ layui.define(['element', 'admin'], function (exports) { @@ -85,42 +98,57 @@ layui.define(['element', 'admin'], function (exports) {
85 * @author lsq 98 * @author lsq
86 * @date 2022-08-18 99 * @date 2022-08-18
87 * */ 100 * */
88 - sendAjaxData(menuPath,elementName){  
89 - let name=encodeURIComponent(elementName); 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 +
90 $.ajaxSetup({ 115 $.ajaxSetup({
91 - headers:{  
92 - menuPath:menuPath,  
93 - elementName:name 116 + headers: {
  117 + currentPageTitle:currentPageTitle,
  118 + batchNo: obj.data.batchNo,
  119 + menuPath: obj.getCurrentHash(),
  120 + elementName: name
94 } 121 }
95 122
96 }); 123 });
97 }, 124 },
98 /** 125 /**
99 - * 鼠标点击事件 126 + * 左侧菜单,鼠标点击事件
100 */ 127 */
101 - bindClickEvent(){  
102 - let that=this;  
103 - var eventKeys = ['a','button','[data-bizid]','.layui-table-link']; 128 + bindMenuClickEvent() {
  129 + let that = this;
104 // 菜单点击 130 // 菜单点击
105 - if(!$('#LAY-system-side-menu li a').hasClass("on_fn")){  
106 - $('#LAY-system-side-menu li a').unbind('click.handle').on('click.handle',(function (e){ 131 + if (!$('#LAY-system-side-menu li a').hasClass("on_fn")) {
  132 + $('#LAY-system-side-menu li a').unbind('click.handle').on('click.handle', (function (e) {
107 e.preventDefault(); 133 e.preventDefault();
108 //start lsq 元素鼠标点击事件操作 2022-08-11 134 //start lsq 元素鼠标点击事件操作 2022-08-11
109 //绑定事件时增加一个class防止多次绑定事件 135 //绑定事件时增加一个class防止多次绑定事件
110 $(this).addClass("on_fn"); 136 $(this).addClass("on_fn");
  137 + // 菜单点击设置批次号
  138 + obj.data.batchNo = 'M' + (new Date()).getTime();
111 // 获取当前点击的菜单 2022-08-11 139 // 获取当前点击的菜单 2022-08-11
112 - if($(this).parent('li').length>0){ 140 + if ($(this).parent('li').length > 0) {
113 //如果菜单是第一级,则清空菜单数组,重新插入 141 //如果菜单是第一级,则清空菜单数组,重新插入
114 - that.data.handleLog=[]; 142 + that.data.handleLog = [];
115 } 143 }
116 - that.pushArrNoRepeat($(this),1); 144 + that.pushArrNoRepeat($(this), 1);
117 })); 145 }));
118 } 146 }
119 147
120 //lsq 给页面的元素绑定点击事件 2022-08-11 148 //lsq 给页面的元素绑定点击事件 2022-08-11
121 - setTimeout(function(){ 149 + setTimeout(function () {
122 that.bindElemClickEvent(); 150 that.bindElemClickEvent();
123 - },500) 151 + }, 500)
124 }, 152 },
125 /** 153 /**
126 * @desc 点击元素插入数组时的处理 154 * @desc 点击元素插入数组时的处理
@@ -129,45 +157,45 @@ layui.define(['element', 'admin'], function (exports) { @@ -129,45 +157,45 @@ layui.define(['element', 'admin'], function (exports) {
129 * @param thisObj 为点击的元素 157 * @param thisObj 为点击的元素
130 * @param flg 1菜单 158 * @param flg 1菜单
131 */ 159 */
132 - pushArrNoRepeat (thisObj,flg) {  
133 - let that=this; 160 + pushArrNoRepeat(thisObj, flg) {
  161 + let that = this;
134 // 获取当前元素名称正则表达式 162 // 获取当前元素名称正则表达式
135 var reg = sessionStorage.getItem('regular'); 163 var reg = sessionStorage.getItem('regular');
136 // 获取当前点击的元素的内容 164 // 获取当前点击的元素的内容
137 - let text=thisObj.text()?thisObj.text().trim().replace(reg, ""):''; 165 + let text = thisObj.text() ? thisObj.text().trim().replace(reg, "") : '';
138 // 获取当前点击的元素的lay-href-type值 166 // 获取当前点击的元素的lay-href-type值
139 - let menuType=thisObj.attr('lay-href-type')?thisObj.attr('lay-href-type'):''; 167 + let menuType = thisObj.attr('lay-href-type') ? thisObj.attr('lay-href-type') : '';
140 // 获取当前点击的菜单的路由地址 168 // 获取当前点击的菜单的路由地址
141 - let layHref=thisObj.attr('lay-href')?thisObj.attr('lay-href'):'';  
142 - let eleObj={  
143 - text:text,  
144 - menuType:menuType,  
145 - layHref:layHref 169 + let layHref = thisObj.attr('lay-href') ? thisObj.attr('lay-href') : '';
  170 + let eleObj = {
  171 + text: text,
  172 + menuType: menuType,
  173 + layHref: layHref
146 } 174 }
147 //数组中无当前点击的元素时再将当前点击元素加入到数组中 175 //数组中无当前点击的元素时再将当前点击元素加入到数组中
148 - let textArr=[];  
149 - that.data.handleLog.map(item=>{ 176 + let textArr = [];
  177 + that.data.handleLog.map(item => {
150 textArr.push(item.text) 178 textArr.push(item.text)
151 }) 179 })
152 - if(textArr.indexOf(text)==-1){  
153 - if(flg && !layHref){ 180 + if (textArr.indexOf(text) == -1) {
  181 + if (flg && !layHref) {
154 // 如果当前点击的菜单元素没有路由地址则删除 182 // 如果当前点击的菜单元素没有路由地址则删除
155 - that.data.handleLog.splice(1) ; 183 + that.data.handleLog.splice(1);
156 } 184 }
157 that.data.handleLog.push(eleObj) 185 that.data.handleLog.push(eleObj)
158 } 186 }
159 //菜单点击传入属性lay-href的值,普通元素传入当前页面路由 187 //菜单点击传入属性lay-href的值,普通元素传入当前页面路由
160 - if(flg){  
161 - that.sendAjaxData(layHref,text) 188 + if (flg) {
  189 + that.sendAjaxData(layHref, text)
162 190
163 - }else{  
164 - let locationPath=location.hash;  
165 - let pathArr=locationPath.split("#/");  
166 - let path='/'  
167 - if(pathArr && pathArr.length>1){  
168 - path=pathArr[1] 191 + } else {
  192 + let locationPath = location.hash;
  193 + let pathArr = locationPath.split("#/");
  194 + let path = '/'
  195 + if (pathArr && pathArr.length > 1) {
  196 + path = pathArr[1]
169 } 197 }
170 - that.sendAjaxData(path,text) 198 + that.sendAjaxData(path, text)
171 199
172 } 200 }
173 }, 201 },
@@ -176,27 +204,27 @@ layui.define(['element', 'admin'], function (exports) { @@ -176,27 +204,27 @@ layui.define(['element', 'admin'], function (exports) {
176 * @author lsq 204 * @author lsq
177 * @date 2022-08-11 205 * @date 2022-08-11
178 */ 206 */
179 - clickEventHandle (thisObj) {  
180 - let that=this; 207 + clickEventHandle(thisObj, key) {
  208 + let that = this;
181 //绑定事件时增加一个class防止多次绑定事件 209 //绑定事件时增加一个class防止多次绑定事件
182 thisObj.addClass("on_fn"); 210 thisObj.addClass("on_fn");
183 that.pushArrNoRepeat(thisObj); 211 that.pushArrNoRepeat(thisObj);
184 // 把点击的元素按顺序展示 212 // 把点击的元素按顺序展示
185 - let handleStr='';  
186 - let menuStrArr=[];  
187 - let menuStrArrSecond=[];  
188 - that.data.handleLog.map(item=>{  
189 - if(item.menuType){ 213 + let handleStr = '';
  214 + let menuStrArr = [];
  215 + let menuStrArrSecond = [];
  216 + that.data.handleLog.map(item => {
  217 + if (item.menuType) {
190 menuStrArr.push(item.text) 218 menuStrArr.push(item.text)
191 - }else{ 219 + } else {
192 menuStrArrSecond.push(item.text) 220 menuStrArrSecond.push(item.text)
193 } 221 }
194 }) 222 })
195 - if(menuStrArr.length>0){  
196 - handleStr=menuStrArr.join('->'); 223 + if (menuStrArr.length > 0) {
  224 + handleStr = menuStrArr.join('->');
197 } 225 }
198 - if(menuStrArrSecond.length>0){  
199 - handleStr+='->'+menuStrArrSecond.join(','); 226 + if (menuStrArrSecond.length > 0) {
  227 + handleStr += '->' + menuStrArrSecond.join(',');
200 } 228 }
201 }, 229 },
202 /** 230 /**
@@ -205,13 +233,13 @@ layui.define(['element', 'admin'], function (exports) { @@ -205,13 +233,13 @@ layui.define(['element', 'admin'], function (exports) {
205 * @date 2022-08-11 233 * @date 2022-08-11
206 */ 234 */
207 bindElemClickEvent() { 235 bindElemClickEvent() {
208 - let that=this;  
209 - var eventKeys = ['button','[data-bizid]','.layui-table-link','[data-zymc]','[data-busid]'];  
210 - eventKeys.map(item=>{  
211 - if(!$(item).hasClass("on_fn")){  
212 - $(item).unbind('click.handle').on('click.handle',(function (e){ 236 + let that = this;
  237 + var eventKeys = ['button', '[data-bizid]', '.layui-table-link', '[data-zymc]', '[data-busid]'];
  238 + eventKeys.map(item => {
  239 + if (!$(item).hasClass("on_fn")) {
  240 + $(item).unbind('click.handle').on('click.handle', (function (e) {
213 e.preventDefault(); 241 e.preventDefault();
214 - that.clickEventHandle($(this)) 242 + that.clickEventHandle($(this), item)
215 })) 243 }))
216 } 244 }
217 245
@@ -264,13 +292,14 @@ layui.define(['element', 'admin'], function (exports) { @@ -264,13 +292,14 @@ layui.define(['element', 'admin'], function (exports) {
264 let elementName = thatItem.text().replace(reg, ""); 292 let elementName = thatItem.text().replace(reg, "");
265 that.getTipsDetail(elementName, thatItem); 293 that.getTipsDetail(elementName, thatItem);
266 }) 294 })
  295 + console.log(obj.data)
267 }, 1000) 296 }, 1000)
268 } 297 }
269 298
270 // 循环绑定事件 299 // 循环绑定事件
271 var bind = function () { 300 var bind = function () {
272 //lsq 表格数据中的元素有时绑定不了事件,加延时 2022-08-11 301 //lsq 表格数据中的元素有时绑定不了事件,加延时 2022-08-11
273 - setTimeout(function (){ 302 + setTimeout(function () {
274 $(contextmenus).each(function (index) { 303 $(contextmenus).each(function (index) {
275 let val = contextmenus[index]; 304 let val = contextmenus[index];
276 if (val.indexOf('el::') != -1) { 305 if (val.indexOf('el::') != -1) {
@@ -278,20 +307,21 @@ layui.define(['element', 'admin'], function (exports) { @@ -278,20 +307,21 @@ layui.define(['element', 'admin'], function (exports) {
278 bindContextEvent(elName, 0); 307 bindContextEvent(elName, 0);
279 } 308 }
280 }) 309 })
281 - },300) 310 + }, 300)
282 } 311 }
283 // 获取当前页面,是否在配置中 312 // 获取当前页面,是否在配置中
284 - var page = that.getCurrentHash();  
285 - $(contextmenus).each(function (index) {  
286 - let val = contextmenus[index];  
287 - if (val.indexOf('page::') != -1) {  
288 - let elName = val.replace('page::', '');  
289 - if (elName == page) { 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 + // })
290 bind(); 324 bind();
291 - return;  
292 - }  
293 - }  
294 - })  
295 // 点击关闭所有tips 325 // 点击关闭所有tips
296 $(document).on('click', function (event) { 326 $(document).on('click', function (event) {
297 layer.closeAll('tips'); 327 layer.closeAll('tips');
@@ -303,7 +333,7 @@ layui.define(['element', 'admin'], function (exports) { @@ -303,7 +333,7 @@ layui.define(['element', 'admin'], function (exports) {
303 * 给带有title的元素绑定点击事件 333 * 给带有title的元素绑定点击事件
304 */ 334 */
305 copyTitle() { 335 copyTitle() {
306 - $('[title]').unbind('click.title').on('click.title',(function (e){ 336 + $('[title]').unbind('click.title').on('click.title', (function (e) {
307 e.preventDefault(); 337 e.preventDefault();
308 let oInput = document.createElement('input'); 338 let oInput = document.createElement('input');
309 oInput.value = $(this).attr('title').trim(); 339 oInput.value = $(this).attr('title').trim();