【无】操作记录日志-菜单及layui页面元素的点击记录给ajax的headers传入参数
Showing
1 changed file
with
31 additions
and
2 deletions
@@ -78,6 +78,21 @@ layui.define(['element', 'admin'], function (exports) { | @@ -78,6 +78,21 @@ layui.define(['element', 'admin'], function (exports) { | ||
78 | }) | 78 | }) |
79 | }, | 79 | }, |
80 | /** | 80 | /** |
81 | + * ajax掉接口之前传参 | ||
82 | + * @author lsq | ||
83 | + * @date 2022-08-18 | ||
84 | + * */ | ||
85 | + sendAjaxData(menuPath,elementName){ | ||
86 | + let name=encodeURIComponent(elementName); | ||
87 | + $.ajaxSetup({ | ||
88 | + headers:{ | ||
89 | + menuPath:menuPath, | ||
90 | + elementName:name | ||
91 | + } | ||
92 | + | ||
93 | + }); | ||
94 | + }, | ||
95 | + /** | ||
81 | * 鼠标点击事件 | 96 | * 鼠标点击事件 |
82 | */ | 97 | */ |
83 | bindClickEvent(){ | 98 | bindClickEvent(){ |
@@ -85,7 +100,7 @@ layui.define(['element', 'admin'], function (exports) { | @@ -85,7 +100,7 @@ layui.define(['element', 'admin'], function (exports) { | ||
85 | var eventKeys = ['a','button','[data-bizid]','.layui-table-link']; | 100 | var eventKeys = ['a','button','[data-bizid]','.layui-table-link']; |
86 | // 菜单点击 | 101 | // 菜单点击 |
87 | if(!$('#LAY-system-side-menu li a').hasClass("on_fn")){ | 102 | if(!$('#LAY-system-side-menu li a').hasClass("on_fn")){ |
88 | - $('#LAY-system-side-menu li a').on('click',(function (e){ | 103 | + $('#LAY-system-side-menu li a').unbind('click.handle').on('click.handle',(function (e){ |
89 | e.preventDefault(); | 104 | e.preventDefault(); |
90 | //start lsq 元素鼠标点击事件操作 2022-08-11 | 105 | //start lsq 元素鼠标点击事件操作 2022-08-11 |
91 | //绑定事件时增加一个class防止多次绑定事件 | 106 | //绑定事件时增加一个class防止多次绑定事件 |
@@ -138,6 +153,20 @@ layui.define(['element', 'admin'], function (exports) { | @@ -138,6 +153,20 @@ layui.define(['element', 'admin'], function (exports) { | ||
138 | } | 153 | } |
139 | that.data.handleLog.push(eleObj) | 154 | that.data.handleLog.push(eleObj) |
140 | } | 155 | } |
156 | + //菜单点击传入属性lay-href的值,普通元素传入当前页面路由 | ||
157 | + if(flg){ | ||
158 | + that.sendAjaxData(layHref,text) | ||
159 | + | ||
160 | + }else{ | ||
161 | + let locationPath=location.hash; | ||
162 | + let pathArr=locationPath.split("#/"); | ||
163 | + let path='/' | ||
164 | + if(pathArr && pathArr.length>1){ | ||
165 | + path=pathArr[1] | ||
166 | + } | ||
167 | + that.sendAjaxData(path,text) | ||
168 | + | ||
169 | + } | ||
141 | console.log(text,that.data.handleLog); | 170 | console.log(text,that.data.handleLog); |
142 | }, | 171 | }, |
143 | /** | 172 | /** |
@@ -179,7 +208,7 @@ layui.define(['element', 'admin'], function (exports) { | @@ -179,7 +208,7 @@ layui.define(['element', 'admin'], function (exports) { | ||
179 | var eventKeys = ['button','[data-bizid]','.layui-table-link']; | 208 | var eventKeys = ['button','[data-bizid]','.layui-table-link']; |
180 | eventKeys.map(item=>{ | 209 | eventKeys.map(item=>{ |
181 | if(!$(item).hasClass("on_fn")){ | 210 | if(!$(item).hasClass("on_fn")){ |
182 | - $(item).on('click',(function (e){ | 211 | + $(item).unbind('click.handle').on('click.handle',(function (e){ |
183 | e.preventDefault(); | 212 | e.preventDefault(); |
184 | that.clickEventHandle($(this)) | 213 | that.clickEventHandle($(this)) |
185 | })) | 214 | })) |
-
Please register or login to post a comment