Authored by wangtao

操作日志

... ... @@ -246,7 +246,7 @@ layui.define(['laytpl', 'layer'], function (exports) {
// 弹框
try {
layui.pageTips.init();
layui.pageTips.init(views,title);
} catch (e) {
console.log(e)
}
... ...
... ... @@ -6,18 +6,31 @@ layui.define(['element', 'admin'], function (exports) {
var obj = {
data: {
batchNo: '',
contextmenuTips: null,
currentPageTitle:'',
contextmenus: [],
classNams: [],
handleLog: [] //lsq 页面点击操作集
},
// 获取当前路由
getCurrentHash: function () {
return window.location.hash;
},
init: function () {
/**
* 渲染完成后初始化函数
* @returns {[]}
*/
init: function (pageHref,paeTitle) {
var that = this;
that.bindClickEvent();
that.bindMenuClickEvent();
// 首页
obj.data.batchNo = 'H' + (new Date()).getTime();
obj.data.currentPageTitle = paeTitle
//lsq给带有title的元素绑定点击事件复制元素内容 2022-09-05
that.copyTitle();
... ... @@ -85,42 +98,57 @@ layui.define(['element', 'admin'], function (exports) {
* @author lsq
* @date 2022-08-18
* */
sendAjaxData(menuPath,elementName){
let name=encodeURIComponent(elementName);
sendAjaxData(menuPath, elementName) {
let name = encodeURIComponent(elementName);
let layerTitle = $('.layui-layer-title');
let currentPageTitle = '';
if(obj.data.currentPageTitle){
currentPageTitle = encodeURIComponent(obj.data.currentPageTitle);
} else if(layerTitle && layerTitle.length > 0){
// 详情页标题
currentPageTitle = layerTitle.text();
} else {
// 页签名称
currentPageTitle = $('#LAY_app_tabsheader li.layui-this span').text()
}
$.ajaxSetup({
headers:{
menuPath:menuPath,
elementName:name
}
headers: {
currentPageTitle:currentPageTitle,
batchNo: obj.data.batchNo,
menuPath: obj.getCurrentHash(),
elementName: name
}
});
},
/**
* 鼠标点击事件
* 左侧菜单,鼠标点击事件
*/
bindClickEvent(){
let that=this;
var eventKeys = ['a','button','[data-bizid]','.layui-table-link'];
bindMenuClickEvent() {
let that = this;
// 菜单点击
if(!$('#LAY-system-side-menu li a').hasClass("on_fn")){
$('#LAY-system-side-menu li a').unbind('click.handle').on('click.handle',(function (e){
if (!$('#LAY-system-side-menu li a').hasClass("on_fn")) {
$('#LAY-system-side-menu li a').unbind('click.handle').on('click.handle', (function (e) {
e.preventDefault();
//start lsq 元素鼠标点击事件操作 2022-08-11
//绑定事件时增加一个class防止多次绑定事件
$(this).addClass("on_fn");
// 菜单点击设置批次号
obj.data.batchNo = 'M' + (new Date()).getTime();
// 获取当前点击的菜单 2022-08-11
if($(this).parent('li').length>0){
if ($(this).parent('li').length > 0) {
//如果菜单是第一级,则清空菜单数组,重新插入
that.data.handleLog=[];
that.data.handleLog = [];
}
that.pushArrNoRepeat($(this),1);
that.pushArrNoRepeat($(this), 1);
}));
}
//lsq 给页面的元素绑定点击事件 2022-08-11
setTimeout(function(){
setTimeout(function () {
that.bindElemClickEvent();
},500)
}, 500)
},
/**
* @desc 点击元素插入数组时的处理
... ... @@ -129,45 +157,45 @@ layui.define(['element', 'admin'], function (exports) {
* @param thisObj 为点击的元素
* @param flg 1菜单
*/
pushArrNoRepeat (thisObj,flg) {
let that=this;
pushArrNoRepeat(thisObj, flg) {
let that = this;
// 获取当前元素名称正则表达式
var reg = sessionStorage.getItem('regular');
// 获取当前点击的元素的内容
let text=thisObj.text()?thisObj.text().trim().replace(reg, ""):'';
let text = thisObj.text() ? thisObj.text().trim().replace(reg, "") : '';
// 获取当前点击的元素的lay-href-type值
let menuType=thisObj.attr('lay-href-type')?thisObj.attr('lay-href-type'):'';
let menuType = thisObj.attr('lay-href-type') ? thisObj.attr('lay-href-type') : '';
// 获取当前点击的菜单的路由地址
let layHref=thisObj.attr('lay-href')?thisObj.attr('lay-href'):'';
let eleObj={
text:text,
menuType:menuType,
layHref:layHref
let layHref = thisObj.attr('lay-href') ? thisObj.attr('lay-href') : '';
let eleObj = {
text: text,
menuType: menuType,
layHref: layHref
}
//数组中无当前点击的元素时再将当前点击元素加入到数组中
let textArr=[];
that.data.handleLog.map(item=>{
let textArr = [];
that.data.handleLog.map(item => {
textArr.push(item.text)
})
if(textArr.indexOf(text)==-1){
if(flg && !layHref){
if (textArr.indexOf(text) == -1) {
if (flg && !layHref) {
// 如果当前点击的菜单元素没有路由地址则删除
that.data.handleLog.splice(1) ;
that.data.handleLog.splice(1);
}
that.data.handleLog.push(eleObj)
}
//菜单点击传入属性lay-href的值,普通元素传入当前页面路由
if(flg){
that.sendAjaxData(layHref,text)
if (flg) {
that.sendAjaxData(layHref, text)
}else{
let locationPath=location.hash;
let pathArr=locationPath.split("#/");
let path='/'
if(pathArr && pathArr.length>1){
path=pathArr[1]
} else {
let locationPath = location.hash;
let pathArr = locationPath.split("#/");
let path = '/'
if (pathArr && pathArr.length > 1) {
path = pathArr[1]
}
that.sendAjaxData(path,text)
that.sendAjaxData(path, text)
}
},
... ... @@ -176,27 +204,27 @@ layui.define(['element', 'admin'], function (exports) {
* @author lsq
* @date 2022-08-11
*/
clickEventHandle (thisObj) {
let that=this;
clickEventHandle(thisObj, key) {
let that = this;
//绑定事件时增加一个class防止多次绑定事件
thisObj.addClass("on_fn");
that.pushArrNoRepeat(thisObj);
// 把点击的元素按顺序展示
let handleStr='';
let menuStrArr=[];
let menuStrArrSecond=[];
that.data.handleLog.map(item=>{
if(item.menuType){
let handleStr = '';
let menuStrArr = [];
let menuStrArrSecond = [];
that.data.handleLog.map(item => {
if (item.menuType) {
menuStrArr.push(item.text)
}else{
} else {
menuStrArrSecond.push(item.text)
}
})
if(menuStrArr.length>0){
handleStr=menuStrArr.join('->');
if (menuStrArr.length > 0) {
handleStr = menuStrArr.join('->');
}
if(menuStrArrSecond.length>0){
handleStr+='->'+menuStrArrSecond.join(',');
if (menuStrArrSecond.length > 0) {
handleStr += '->' + menuStrArrSecond.join(',');
}
},
/**
... ... @@ -205,13 +233,13 @@ layui.define(['element', 'admin'], function (exports) {
* @date 2022-08-11
*/
bindElemClickEvent() {
let that=this;
var eventKeys = ['button','[data-bizid]','.layui-table-link','[data-zymc]','[data-busid]'];
eventKeys.map(item=>{
if(!$(item).hasClass("on_fn")){
$(item).unbind('click.handle').on('click.handle',(function (e){
let that = this;
var eventKeys = ['button', '[data-bizid]', '.layui-table-link', '[data-zymc]', '[data-busid]'];
eventKeys.map(item => {
if (!$(item).hasClass("on_fn")) {
$(item).unbind('click.handle').on('click.handle', (function (e) {
e.preventDefault();
that.clickEventHandle($(this))
that.clickEventHandle($(this), item)
}))
}
... ... @@ -264,13 +292,14 @@ layui.define(['element', 'admin'], function (exports) {
let elementName = thatItem.text().replace(reg, "");
that.getTipsDetail(elementName, thatItem);
})
console.log(obj.data)
}, 1000)
}
// 循环绑定事件
var bind = function () {
//lsq 表格数据中的元素有时绑定不了事件,加延时 2022-08-11
setTimeout(function (){
setTimeout(function () {
$(contextmenus).each(function (index) {
let val = contextmenus[index];
if (val.indexOf('el::') != -1) {
... ... @@ -278,20 +307,21 @@ layui.define(['element', 'admin'], function (exports) {
bindContextEvent(elName, 0);
}
})
},300)
}, 300)
}
// 获取当前页面,是否在配置中
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;
}
}
})
// 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;
// }
// }
// })
bind();
// 点击关闭所有tips
$(document).on('click', function (event) {
layer.closeAll('tips');
... ... @@ -303,7 +333,7 @@ layui.define(['element', 'admin'], function (exports) {
* 给带有title的元素绑定点击事件
*/
copyTitle() {
$('[title]').unbind('click.title').on('click.title',(function (e){
$('[title]').unbind('click.title').on('click.title', (function (e) {
e.preventDefault();
let oInput = document.createElement('input');
oInput.value = $(this).attr('title').trim();
... ...