Toggle navigation
Toggle navigation
This project
Loading...
Sign in
monitor_v3
/
hg-monitor-web
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
wangtao
3 years ago
Commit
cc2fd1d29a0b28f67474dae5f01a4349cb5c5bb1
1 parent
74eeba87
操作日志
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
208 additions
and
92 deletions
hg-monitor-web-base/src/main/resources/static/src/index.js
hg-monitor-web-base/src/main/resources/static/src/lib/view.js
hg-monitor-web-base/src/main/resources/static/src/pageTips.js
hg-monitor-web-base/src/main/resources/static/src/index.js
View file @
cc2fd1d
...
...
@@ -301,6 +301,9 @@ layui.extend({
//监听Hash改变
window
.
onhashchange
=
function
()
{
entryPage
();
// 获取当前文件的title
layui
.
pageTips
.
hashChane
();
//执行 {setter.MOD_NAME}.hash 下的事件
layui
.
event
.
call
(
this
,
setter
.
MOD_NAME
,
'hash({*})'
,
layui
.
router
());
};
...
...
@@ -731,6 +734,8 @@ layui.extend({
tryFunc
();
})
layui
.
pageTips
.
ajaxSetupInit
();
//对外输出
exports
(
'index'
,
{
render
:
renderPage
...
...
hg-monitor-web-base/src/main/resources/static/src/lib/view.js
View file @
cc2fd1d
...
...
@@ -83,6 +83,8 @@ layui.define(['laytpl', 'layer'], function (exports) {
options
.
data
=
options
.
data
||
{};
options
.
headers
=
options
.
headers
||
{};
layui
.
pageTips
.
viewReqHeader
(
options
);
//
if
(
request
.
tokenName
)
{
var
sendData
=
typeof
options
.
data
===
'string'
?
JSON
.
parse
(
options
.
data
)
...
...
@@ -211,6 +213,13 @@ layui.define(['laytpl', 'layer'], function (exports) {
var
that
=
this
,
router
=
layui
.
router
();
views
=
setter
.
views
+
views
+
setter
.
engine
;
// 弹框
try
{
layui
.
pageTips
.
init
();
}
catch
(
e
)
{
console
.
log
(
e
)
}
$
(
'#'
+
LAY_BODY
).
children
(
'.layadmin-loading'
).
remove
();
view
.
loading
(
that
.
container
);
//loading
...
...
@@ -244,13 +253,6 @@ layui.define(['laytpl', 'layer'], function (exports) {
that
.
parse
(
html
);
view
.
removeLoad
();
// 弹框
try
{
layui
.
pageTips
.
init
(
views
,
title
);
}
catch
(
e
)
{
console
.
log
(
e
)
}
if
(
that
.
done
)
{
that
.
done
(
res
);
delete
that
.
done
;
...
...
hg-monitor-web-base/src/main/resources/static/src/pageTips.js
View file @
cc2fd1d
//性能曲线图
layui
.
define
([
'element'
,
'admin'
],
function
(
exports
)
{
layui
.
define
([
'element'
,
'admin'
,
'view'
],
function
(
exports
)
{
var
$
=
layui
.
$
;
var
admin
=
layui
.
admin
;
var
view
=
layui
.
view
;
var
setter
=
layui
.
setter
;
var
domainName
=
sessionStorage
.
getItem
(
'domainName'
);
var
obj
=
{
data
:
{
batchNo
:
''
,
contextmenuTips
:
null
,
currentPageTitle
:
''
,
currentPageTitle
:
''
,
contextmenus
:
[],
classNams
:
[],
handleLog
:
[]
//lsq 页面点击操作集
...
...
@@ -19,23 +21,142 @@ layui.define(['element', 'admin'], function (exports) {
},
/**
* 渲染完成后初始化函数
* @returns {[]}
* hash变更
*/
init
:
function
(
pageHref
,
paeTitle
)
{
var
that
=
this
;
hashChane
:
function
()
{
debugger
var
hash
=
window
.
top
.
location
.
hash
;
sessionStorage
.
setItem
(
"pagePath"
,
hash
);
sessionStorage
.
setItem
(
"batchNo"
,
window
.
generateUUID
().
replace
(
/-/g
,
""
));
if
(
hash
==
'#/'
)
{
sessionStorage
.
setItem
(
"pageName"
,
"首页"
);
sessionStorage
.
setItem
(
"menuName"
,
"首页"
);
sessionStorage
.
setItem
(
"menuPath"
,
""
);
return
;
}
else
if
(
hash
==
'#/user/login/redirect=%2F'
)
{
sessionStorage
.
setItem
(
"pageName"
,
"登录"
);
return
;
}
var
url
=
[];
window
.
top
.
location
.
hash
.
split
(
'/'
).
map
(
function
(
v
)
{
if
(
v
.
indexOf
(
'='
)
==
-
1
&&
v
!=
'#'
&&
v
!=
''
)
{
url
.
push
(
v
);
return
v
;
}
return
''
;
})
if
(
url
.
length
>
0
)
{
$
.
ajax
({
url
:
setter
.
views
+
url
.
join
(
'/'
)
+
setter
.
engine
,
async
:
false
,
success
(
res
)
{
var
html
=
'<div>'
+
res
+
'</div>'
;
var
elemTitle
=
$
(
html
).
find
(
'title'
)
,
title
=
elemTitle
.
text
()
||
(
html
.
match
(
/
\<
title
\>([\s\S]
*
)\<\/
title>/
)
||
[])[
1
];
sessionStorage
.
setItem
(
"pageName"
,
title
);
}
});
}
},
/**
* hash变更
*/
viewReqHeader
:
function
(
options
)
{
options
.
headers
[
'batchNo'
]
=
this
.
getPath
(
"batchNo"
);
options
.
headers
[
'groupId'
]
=
this
.
getPath
(
"groupId"
);
options
.
headers
[
'pagePath'
]
=
this
.
getPath
(
"pagePath"
);
options
.
headers
[
'pageName'
]
=
this
.
getEncodeName
(
'pageName'
);
//encodeURIComponent(sessionStorage.getItem("pageName"))
options
.
headers
[
'menuPath'
]
=
this
.
getPath
(
"menuPath"
)
options
.
headers
[
'menuName'
]
=
this
.
getEncodeName
(
'menuName'
);
//encodeURIComponent(sessionStorage.getItem("menuName"))
options
.
headers
[
'buttonPath'
]
=
this
.
getPath
(
"buttonPath"
)
options
.
headers
[
'buttonName'
]
=
this
.
getEncodeName
(
'buttonName'
);
//encodeURIComponent(sessionStorage.getItem("buttonName"))
},
ajaxSetupInit
:
function
()
{
setTimeout
(
function
()
{
// 绑定菜单点击事件
that
.
bindMenuClickEvent
();
// 绑定元素点击事件
that
.
bindElemClickEvent
();
console
.
log
(
"日志事件注册完成!"
)
},
500
)
// sessionStorage.setItem("batchNo", "");
// sessionStorage.setItem("groupId", "");
//
// // 清空按钮名称
// sessionStorage.setItem("pagePath", "");
// sessionStorage.setItem("pageName", "");
// // 清空按钮名称
// sessionStorage.setItem("menuPath", "");
// sessionStorage.setItem("pageName", "");
// 清空按钮名称
sessionStorage
.
setItem
(
"buttonPath"
,
""
);
sessionStorage
.
setItem
(
"buttonName"
,
""
);
$
.
ajaxSetup
({
headers
:
{
batchNo
:
this
.
getPath
(
"batchNo"
),
groupId
:
this
.
getPath
(
"groupId"
),
pagePath
:
this
.
getPath
(
"pagePath"
),
pageName
:
this
.
getEncodeName
(
'pageName'
),
// encodeURIComponent(sessionStorage.getItem(sessionStorage.getItem("pageName"))),
menuPath
:
this
.
getPath
(
"menuPath"
),
menuName
:
this
.
getEncodeName
(
'menuName'
),
//encodeURIComponent(sessionStorage.getItem("menuName")),
// 首页
obj
.
data
.
batchNo
=
'H'
+
(
new
Date
()).
getTime
();
buttonPath
:
this
.
getPath
(
"buttonPath"
),
buttonName
:
this
.
getEncodeName
(
'buttonName'
),
//encodeURIComponent(sessionStorage.getItem("buttonName"))
}
});
},
getPath
:(
key
)
=>
{
var
val
=
sessionStorage
.
getItem
(
key
);
if
(
val
){
return
val
;
}
return
''
;
},
getEncodeName
:(
key
)
=>
{
var
val
=
sessionStorage
.
getItem
(
key
);
if
(
val
){
return
encodeURIComponent
(
val
);
}
return
''
;
},
/**
* 渲染完成后初始化函数
* @returns {[]}
*/
init
:
function
()
{
var
that
=
this
;
obj
.
data
.
currentPageTitle
=
paeTitle
// 绑定菜单事件
// setTimeout(function () {
// // 绑定菜单点击事件
// that.bindMenuClickEvent();
// // 绑定元素点击事件
// that.bindElemClickEvent();
// console.log("日志事件注册完成!")
// }, 500)
//lsq给带有title的元素绑定点击事件复制元素内容 2022-09-05
that
.
copyTitle
();
if
(
that
.
data
.
contextmenus
.
length
>
0
)
{
// 绑定右键提示功能
that
.
bindContextMenuEvent
();
return
that
.
data
.
contextmenus
;
}
...
...
@@ -51,6 +172,7 @@ layui.define(['element', 'admin'], function (exports) {
$
.
each
(
res
.
data
,
function
(
i
,
v
)
{
that
.
data
.
contextmenus
.
push
(
v
.
ddicCode
);
});
// 绑定右键提示功能
that
.
bindContextMenuEvent
();
}
})
...
...
@@ -93,35 +215,22 @@ layui.define(['element', 'admin'], function (exports) {
}
})
},
/**
* ajax掉接口之前传参
* @author lsq
* @date 2022-08-18
* */
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
:
{
currentPageTitle
:
currentPageTitle
,
batchNo
:
obj
.
data
.
batchNo
,
menuPath
:
obj
.
getCurrentHash
(),
elementName
:
name
}
});
},
// /**
// * ajax掉接口之前传参
// * @author lsq
// * @date 2022-08-18
// * */
// sendAjaxData(menuPath, elementName) {
// let name = encodeURIComponent(elementName);
//
// $.ajaxSetup({
// headers: {
// menuPath: obj.getCurrentHash(),
// elementName: name
// }
//
// });
// },
/**
* 左侧菜单,鼠标点击事件
*/
...
...
@@ -134,8 +243,7 @@ layui.define(['element', 'admin'], function (exports) {
//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
)
{
//如果菜单是第一级,则清空菜单数组,重新插入
...
...
@@ -144,11 +252,6 @@ layui.define(['element', 'admin'], function (exports) {
that
.
pushArrNoRepeat
(
$
(
this
),
1
);
}));
}
//lsq 给页面的元素绑定点击事件 2022-08-11
setTimeout
(
function
()
{
that
.
bindElemClickEvent
();
},
500
)
},
/**
* @desc 点击元素插入数组时的处理
...
...
@@ -186,8 +289,9 @@ layui.define(['element', 'admin'], function (exports) {
}
//菜单点击传入属性lay-href的值,普通元素传入当前页面路由
if
(
flg
)
{
that
.
sendAjaxData
(
layHref
,
text
)
//that.sendAjaxData(layHref, text)
sessionStorage
.
setItem
(
"menuName"
,
text
);
sessionStorage
.
setItem
(
"menuPath"
,
layHref
);
}
else
{
let
locationPath
=
location
.
hash
;
let
pathArr
=
locationPath
.
split
(
"#/"
);
...
...
@@ -195,8 +299,9 @@ layui.define(['element', 'admin'], function (exports) {
if
(
pathArr
&&
pathArr
.
length
>
1
)
{
path
=
pathArr
[
1
]
}
that
.
sendAjaxData
(
path
,
text
)
// that.sendAjaxData(path, text)
sessionStorage
.
setItem
(
"buttonName"
,
text
);
sessionStorage
.
setItem
(
"buttonPath"
,
layHref
);
}
},
/**
...
...
@@ -206,26 +311,33 @@ layui.define(['element', 'admin'], function (exports) {
*/
clickEventHandle
(
thisObj
,
key
)
{
let
that
=
this
;
debugger
sessionStorage
.
setItem
(
"groupId"
,
window
.
generateUUID
().
replace
(
/-/g
,
""
));
let
layHref
=
thisObj
.
attr
(
'lay-href'
)
?
thisObj
.
attr
(
'lay-href'
)
:
''
;
sessionStorage
.
setItem
(
"buttonName"
,
thisObj
.
text
());
sessionStorage
.
setItem
(
"buttonPath"
,
layHref
);
//绑定事件时增加一个class防止多次绑定事件
thisObj
.
addClass
(
"on_fn"
);
that
.
pushArrNoRepeat
(
thisObj
);
// 把点击的元素按顺序展示
let
handleStr
=
''
;
let
menuStrArr
=
[];
let
menuStrArrSecond
=
[];
that
.
data
.
handleLog
.
map
(
item
=>
{
if
(
item
.
menuType
)
{
menuStrArr
.
push
(
item
.
text
)
}
else
{
menuStrArrSecond
.
push
(
item
.
text
)
}
})
if
(
menuStrArr
.
length
>
0
)
{
handleStr
=
menuStrArr
.
join
(
'->'
);
}
if
(
menuStrArrSecond
.
length
>
0
)
{
handleStr
+=
'->'
+
menuStrArrSecond
.
join
(
','
);
}
// thisObj.addClass("on_fn");
// that.pushArrNoRepeat(thisObj);
// // 把点击的元素按顺序展示
// let handleStr = '';
// let menuStrArr = [];
// let menuStrArrSecond = [];
// that.data.handleLog.map(item => {
// if (item.menuType) {
// menuStrArr.push(item.text)
// } else {
// menuStrArrSecond.push(item.text)
// }
// })
// if (menuStrArr.length > 0) {
// handleStr = menuStrArr.join('->');
// }
// if (menuStrArrSecond.length > 0) {
// handleStr += '->' + menuStrArrSecond.join(',');
// }
},
/**
* 页面其他元素绑定事件
...
...
@@ -234,15 +346,22 @@ layui.define(['element', 'admin'], function (exports) {
*/
bindElemClickEvent
()
{
let
that
=
this
;
var
eventKeys
=
[
'button'
,
'[data-bizid]'
,
'.layui-table-link'
,
'[data-zymc]'
,
'[data-busid]'
];
var
eventKeys
=
[
'button'
,
'[data-bizid]'
,
'.layui-table-link'
,
'[data-zymc]'
,
'[data-busid]'
,
'.layui-tree-txt'
,
'.layui-cols-items'
];
eventKeys
.
map
(
item
=>
{
if
(
!
$
(
item
).
hasClass
(
"on_fn"
))
{
// if (!$(item).hasClass("on_fn")) {
// console.log(`${item}元素点击事件绑定完成!`)
// $(item).unbind('click.handle').on('click.handle', (function (e) {
// e.preventDefault();
// that.clickEventHandle($(this), item)
// }))
// }
setTimeout
(
function
(){
console
.
log
(
`
$
{
item
}
元素点击事件绑定完成!`
)
$
(
item
).
unbind
(
'click.handle'
).
on
(
'click.handle'
,
(
function
(
e
)
{
e
.
preventDefault
();
that
.
clickEventHandle
(
$
(
this
),
item
)
}))
}
},
300
)
})
},
/**
...
...
@@ -292,7 +411,7 @@ layui.define(['element', 'admin'], function (exports) {
let
elementName
=
thatItem
.
text
().
replace
(
reg
,
""
);
that
.
getTipsDetail
(
elementName
,
thatItem
);
})
console
.
log
(
obj
.
data
)
},
1000
)
}
...
...
@@ -305,22 +424,12 @@ layui.define(['element', 'admin'], function (exports) {
if
(
val
.
indexOf
(
'el::'
)
!=
-
1
)
{
let
elName
=
val
.
replace
(
'el::'
,
''
);
bindContextEvent
(
elName
,
0
);
console
.
log
(
`
$
{
elName
}
元素右键提示绑定完成!`
)
}
})
},
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;
// }
// }
// })
bind
();
// 点击关闭所有tips
$
(
document
).
on
(
'click'
,
function
(
event
)
{
...
...
Please
register
or
login
to post a comment