...
|
...
|
@@ -9,29 +9,29 @@ |
|
|
|
|
|
layui.extend({
|
|
|
setter: 'config' //配置文件
|
|
|
,admin: 'lib/admin' //核心模块
|
|
|
, admin: 'lib/admin' //核心模块
|
|
|
/*,sessions: 'controller/sessions'*/
|
|
|
,view: 'lib/view' //核心模块
|
|
|
}).define(['setter', 'admin'], function(exports){
|
|
|
, view: 'lib/view' //核心模块
|
|
|
}).define(['setter', 'admin'], function (exports) {
|
|
|
var setter = layui.setter
|
|
|
,element = layui.element
|
|
|
,admin = layui.admin
|
|
|
,tabsPage = admin.tabsPage
|
|
|
,view = layui.view
|
|
|
,defaultIndex = ''
|
|
|
, element = layui.element
|
|
|
, admin = layui.admin
|
|
|
, tabsPage = admin.tabsPage
|
|
|
, view = layui.view
|
|
|
, defaultIndex = ''
|
|
|
|
|
|
|
|
|
// 根据 路由渲染页面
|
|
|
,renderPage = function(){
|
|
|
, renderPage = function () {
|
|
|
var show = location.search.substr(1).split("&")[0].split("=")[1];
|
|
|
var router = layui.router()
|
|
|
,path = router.path
|
|
|
,pathURL = admin.correctRouter(router.path.join('/'));
|
|
|
, path = router.path
|
|
|
, pathURL = admin.correctRouter(router.path.join('/'));
|
|
|
//默认读取主页
|
|
|
if(!path.length) path = [''];
|
|
|
if(!tabsPage.index && !renderPage.haveInit && show != '0') path=['']
|
|
|
if (!path.length) path = [''];
|
|
|
if (!tabsPage.index && !renderPage.haveInit && show != '0') path = ['']
|
|
|
// 如果访问首页
|
|
|
if(pathURL === '/'){
|
|
|
if (pathURL === '/') {
|
|
|
// path[path.length - 1] = setter.entry;
|
|
|
|
|
|
// 根据不同角色 用户 展示不同首页 开始
|
...
|
...
|
@@ -41,7 +41,7 @@ layui.extend({ |
|
|
async: false,
|
|
|
success(response) {
|
|
|
// 获取成功
|
|
|
if(response && response.success && response.object){
|
|
|
if (response && response.success && response.object) {
|
|
|
if (response.object.path && response.object.path != '/') {
|
|
|
defaultIndex = '/' + response.object.path;
|
|
|
} else {
|
...
|
...
|
@@ -68,13 +68,13 @@ layui.extend({ |
|
|
*/
|
|
|
|
|
|
//重置状态
|
|
|
var reset = function(type){
|
|
|
var reset = function (type) {
|
|
|
//renderPage.haveInit && layer.closeAll();
|
|
|
if(renderPage.haveInit){
|
|
|
$('.layui-layer').each(function(){
|
|
|
if (renderPage.haveInit) {
|
|
|
$('.layui-layer').each(function () {
|
|
|
var othis = $(this),
|
|
|
index = othis.attr('times');
|
|
|
if(!othis.hasClass('layui-layim')){
|
|
|
if (!othis.hasClass('layui-layim')) {
|
|
|
layer.close(index);
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -86,63 +86,63 @@ layui.extend({ |
|
|
};
|
|
|
|
|
|
//如果路由来自于 tab 切换,则不重新请求视图
|
|
|
if(tabsPage.type === 'tab'){
|
|
|
if (tabsPage.type === 'tab') {
|
|
|
//切换到非主页、或者切换到主页且主页必须有内容。方可阻止请求
|
|
|
if(pathURL !== '/' || (pathURL === '/' && admin.tabsBody().html())){
|
|
|
if (pathURL !== '/' || (pathURL === '/' && admin.tabsBody().html())) {
|
|
|
admin.tabsBodyChange(tabsPage.index);
|
|
|
return reset(tabsPage.type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//请求视图渲染
|
|
|
view().render(path.join('/')).then(function(res){
|
|
|
view().render(path.join('/')).then(function (res) {
|
|
|
//遍历页签选项卡
|
|
|
var matchTo
|
|
|
,tabs = $('#LAY_app_tabsheader>li');
|
|
|
, tabs = $('#LAY_app_tabsheader>li');
|
|
|
|
|
|
tabs.each(function(index){
|
|
|
tabs.each(function (index) {
|
|
|
var li = $(this)
|
|
|
,layid = li.attr('lay-id');
|
|
|
if(layid === pathURL){
|
|
|
, layid = li.attr('lay-id');
|
|
|
if (layid === pathURL) {
|
|
|
matchTo = true;
|
|
|
tabsPage.index = index;
|
|
|
}
|
|
|
});
|
|
|
var tabName;
|
|
|
//start lsq 页面刷新后名称改变,把aj得存储到localStorage中 2022-03-30
|
|
|
let routerPath=router.path;
|
|
|
if(routerPath.indexOf('ajConfig')!=-1 && routerPath.indexOf('view')!=-1 && !localStorage.getItem(router.search.ajConfig)){
|
|
|
localStorage.setItem(router.search.ajConfig,admin.tabsPage.elem.text());
|
|
|
let routerPath = router.path;
|
|
|
if (routerPath.indexOf('ajConfig') != -1 && routerPath.indexOf('view') != -1 && !localStorage.getItem(router.search.ajConfig)) {
|
|
|
localStorage.setItem(router.search.ajConfig, admin.tabsPage.elem.text());
|
|
|
}
|
|
|
//end lsq 2022-03-30
|
|
|
try {
|
|
|
let el = admin.tabsPage.elem;
|
|
|
if(el && el.attr('lay-href-type')){
|
|
|
if(el.attr('lay-href-type') == 'menu' && !matchTo){
|
|
|
tabName= admin.tabsPage.elem.text();
|
|
|
if (el && el.attr('lay-href-type')) {
|
|
|
if (el.attr('lay-href-type') == 'menu' && !matchTo) {
|
|
|
tabName = admin.tabsPage.elem.text();
|
|
|
}
|
|
|
}
|
|
|
} catch (e){
|
|
|
} catch (e) {
|
|
|
}
|
|
|
if(!tabName){
|
|
|
if (!tabName) {
|
|
|
//lsq 页面刷新后名称改变 2022-03-30
|
|
|
if(routerPath.indexOf('ajConfig')!=-1 && routerPath.indexOf('view')!=-1){
|
|
|
tabName=localStorage.getItem(router.search.ajConfig);
|
|
|
}else{
|
|
|
tabName= res.title
|
|
|
if (routerPath.indexOf('ajConfig') != -1 && routerPath.indexOf('view') != -1) {
|
|
|
tabName = localStorage.getItem(router.search.ajConfig);
|
|
|
} else {
|
|
|
tabName = res.title
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//如果未在选项卡中匹配到,则追加选项卡
|
|
|
if(setter.pageTabs && pathURL !== '/'){
|
|
|
if(!matchTo){
|
|
|
if (setter.pageTabs && pathURL !== '/') {
|
|
|
if (!matchTo) {
|
|
|
$(APP_BODY).append('<div class="layadmin-tabsbody-item layui-show"></div>');
|
|
|
tabsPage.index = tabs.length;
|
|
|
element.tabAdd(FILTER_TAB_TBAS, {
|
|
|
title: '<span>'+ (tabName || '新标签页') +'</span>'
|
|
|
,id: pathURL
|
|
|
,attr: router.href
|
|
|
title: '<span>' + (tabName || '新标签页') + '</span>'
|
|
|
, id: pathURL
|
|
|
, attr: router.href
|
|
|
});
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -156,21 +156,21 @@ layui.extend({ |
|
|
$('* [lay-id="' + pathURL + '"] span').text(tabName)
|
|
|
admin.tabsBodyChange(tabsPage.index);
|
|
|
|
|
|
}).done(function(){
|
|
|
}).done(function () {
|
|
|
layui.use('common', layui.cache.callback.common);
|
|
|
$win.on('resize', layui.data.resize);
|
|
|
|
|
|
element.render('breadcrumb', 'breadcrumb');
|
|
|
|
|
|
//容器 scroll 事件,剔除吸附层
|
|
|
admin.tabsBody(tabsPage.index).on('scroll', function(){
|
|
|
admin.tabsBody(tabsPage.index).on('scroll', function () {
|
|
|
var othis = $(this)
|
|
|
,elemDate = $('.layui-laydate')
|
|
|
,layerOpen = $('.layui-layer')[0];
|
|
|
, elemDate = $('.layui-laydate')
|
|
|
, layerOpen = $('.layui-layer')[0];
|
|
|
|
|
|
//关闭 layDate
|
|
|
if(elemDate[0]){
|
|
|
elemDate.each(function(){
|
|
|
if (elemDate[0]) {
|
|
|
elemDate.each(function () {
|
|
|
var thisElemDate = $(this);
|
|
|
thisElemDate.hasClass('layui-laydate-static') || thisElemDate.remove();
|
|
|
});
|
...
|
...
|
@@ -186,14 +186,14 @@ layui.extend({ |
|
|
}
|
|
|
|
|
|
//入口页面
|
|
|
,entryPage = function(fn){
|
|
|
, entryPage = function (fn) {
|
|
|
var router = layui.router()
|
|
|
,container = view(setter.container)
|
|
|
,pathURL = admin.correctRouter(router.path.join('/'))
|
|
|
,isIndPage;
|
|
|
, container = view(setter.container)
|
|
|
, pathURL = admin.correctRouter(router.path.join('/'))
|
|
|
, isIndPage;
|
|
|
//检查是否属于独立页面
|
|
|
layui.each(setter.indPage, function(index, item){
|
|
|
if(pathURL === item){
|
|
|
layui.each(setter.indPage, function (index, item) {
|
|
|
if (pathURL === item) {
|
|
|
return isIndPage = true;
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -206,51 +206,58 @@ layui.extend({ |
|
|
// 跳转到过度页面的时候,判断参数与跳转的过渡页面的参数是否一直,则强制设置hash
|
|
|
// http://localhost:8088/?Authorization=xxx&show=0&url=alarm/activewarning#/page/forward
|
|
|
var href = window.location.href;
|
|
|
if(href.indexOf('?Authorization') != -1 && href.indexOf('&show=0&url=') != -1 && pathURL !== '/page/forward'){
|
|
|
console.log(pathURL)
|
|
|
console.log(href)
|
|
|
if (href.indexOf('?Authorization') != -1 && href.indexOf('&show=0&url=') != -1 && pathURL !== '/page/forward'&& pathURL !== '/page/log') {
|
|
|
if(href.indexOf('&flag=log') != -1){
|
|
|
return location.hash = "/page/log";
|
|
|
}else {
|
|
|
return location.hash = "/page/forward";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//跳转到告警页面
|
|
|
let params=new URLSearchParams(location.search);
|
|
|
let [bizId]=[params.get('bizId')];
|
|
|
let params = new URLSearchParams(location.search);
|
|
|
let [bizId] = [params.get('bizId')];
|
|
|
//活动告警页面
|
|
|
if( href.indexOf('&show=3') != -1 && pathURL !== '/alarm/activewarning'){
|
|
|
return location.hash = "/alarm/activewarning/bizId="+bizId;
|
|
|
if (href.indexOf('&show=3') != -1 && pathURL !== '/alarm/activewarning') {
|
|
|
return location.hash = "/alarm/activewarning/bizId=" + bizId;
|
|
|
}
|
|
|
//历史告警页面
|
|
|
if( href.indexOf('&show=4') != -1 && pathURL !== '/alarm/historywarning'){
|
|
|
return location.hash = "/alarm/historywarning/bizId="+bizId;
|
|
|
if (href.indexOf('&show=4') != -1 && pathURL !== '/alarm/historywarning') {
|
|
|
return location.hash = "/alarm/historywarning/bizId=" + bizId;
|
|
|
}
|
|
|
|
|
|
//独立页面
|
|
|
if(isIndPage || pathURL === '/user/login'|| pathURL === '/page/forward'){ //此处单独判断登入页,是为了兼容旧版(即未在 sessions.js 配置 indPage 的情况)
|
|
|
if (isIndPage || pathURL === '/user/login' || pathURL === '/page/forward' || pathURL == "/page/log") { //此处单独判断登入页,是为了兼容旧版(即未在 sessions.js 配置 indPage 的情况)
|
|
|
|
|
|
let path = router.path.join('/')
|
|
|
if(pathURL.indexOf('/user/login') != -1){
|
|
|
if (pathURL.indexOf('/user/login') != -1) {
|
|
|
var loginIndex = 'default';
|
|
|
// let loginSkin = sessionStorage.getItem("loginSkin");
|
|
|
//lsq 从cookie中获取登录皮肤 2022-03-31
|
|
|
let loginSkin = admin.getCookie("loginSkin");
|
|
|
if(loginSkin && ["default",'skin1','skin2'].indexOf(loginSkin) != -1){
|
|
|
if (loginSkin && ["default", 'skin1', 'skin2'].indexOf(loginSkin) != -1) {
|
|
|
loginIndex = loginSkin;
|
|
|
}
|
|
|
|
|
|
path = path + '-' + loginIndex;
|
|
|
}
|
|
|
container.render(path).done(function(){
|
|
|
container.render(path).done(function () {
|
|
|
admin.pageType = 'alone';
|
|
|
});
|
|
|
} else { //后台框架页面
|
|
|
|
|
|
//强制拦截未登入
|
|
|
if(setter.interceptor){
|
|
|
if (setter.interceptor) {
|
|
|
var local = layui.data(setter.tableName);
|
|
|
if(!local[setter.request.tokenName]){
|
|
|
return location.hash = '/user/login/redirect='+ encodeURIComponent(pathURL); //跳转到登入页
|
|
|
if (!local[setter.request.tokenName]) {
|
|
|
return location.hash = '/user/login/redirect=' + encodeURIComponent(pathURL); //跳转到登入页
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//渲染后台结构
|
|
|
if(admin.pageType === 'console') { //后台主体页
|
|
|
if (admin.pageType === 'console') { //后台主体页
|
|
|
renderPage();
|
|
|
} else { //初始控制台结构
|
|
|
var renderUrl = 'layout';
|
...
|
...
|
@@ -258,14 +265,14 @@ layui.extend({ |
|
|
// renderUrl = 'layout-nx';
|
|
|
// }
|
|
|
let userLayout = sessionStorage.getItem("userLayout");
|
|
|
if(userLayout && ['layout','layout-nx'].indexOf(userLayout) != -1){
|
|
|
if (userLayout && ['layout', 'layout-nx'].indexOf(userLayout) != -1) {
|
|
|
renderUrl = userLayout;
|
|
|
}
|
|
|
container.render(renderUrl).done(function(){
|
|
|
container.render(renderUrl).done(function () {
|
|
|
renderPage();
|
|
|
layui.element.render();
|
|
|
|
|
|
if(admin.screen() < 2){
|
|
|
if (admin.screen() < 2) {
|
|
|
admin.sideFlexible();
|
|
|
}
|
|
|
admin.pageType = 'console';
|
...
|
...
|
@@ -275,32 +282,32 @@ layui.extend({ |
|
|
}
|
|
|
}
|
|
|
|
|
|
,APP_BODY = '#LAY_app_body', FILTER_TAB_TBAS = 'layadmin-layout-tabs'
|
|
|
,$ = layui.$, $win = $(window);
|
|
|
, APP_BODY = '#LAY_app_body', FILTER_TAB_TBAS = 'layadmin-layout-tabs'
|
|
|
, $ = layui.$, $win = $(window);
|
|
|
|
|
|
//初始主体结构
|
|
|
layui.link(setter.base + 'style/admin.css?v='+ (admin.v + '-1'));
|
|
|
layui.link(setter.base + 'style/css/main.css?v='+ (admin.v + '-1'), entryPage, 'layuiAdmin');
|
|
|
layui.link(setter.base + 'style/admin.css?v=' + (admin.v + '-1'));
|
|
|
layui.link(setter.base + 'style/css/main.css?v=' + (admin.v + '-1'), entryPage, 'layuiAdmin');
|
|
|
|
|
|
//监听Hash改变
|
|
|
window.onhashchange = function(){
|
|
|
window.onhashchange = function () {
|
|
|
entryPage();
|
|
|
//执行 {setter.MOD_NAME}.hash 下的事件
|
|
|
layui.event.call(this, setter.MOD_NAME, 'hash({*})', layui.router());
|
|
|
};
|
|
|
|
|
|
//扩展 lib 目录下的其它模块
|
|
|
layui.each(setter.extend, function(index, item){
|
|
|
layui.each(setter.extend, function (index, item) {
|
|
|
var mods = {};
|
|
|
if(item === 'mxClient'){
|
|
|
if (item === 'mxClient') {
|
|
|
mods[item] = '{/}' + setter.base + 'lib/mxgraph/' + item;
|
|
|
}
|
|
|
else if(item === 'soulTable' || item === 'tableFilter' || item === 'tableChild'
|
|
|
|| item === 'tableMerge' || item === 'excel'){
|
|
|
else if (item === 'soulTable' || item === 'tableFilter' || item === 'tableChild'
|
|
|
|| item === 'tableMerge' || item === 'excel') {
|
|
|
mods[item] = '{/}' + setter.base + 'lib/soultable/' + item;
|
|
|
}else if(item === 'tableEdit' || item === 'tableTree'){
|
|
|
} else if (item === 'tableEdit' || item === 'tableTree') {
|
|
|
mods[item] = '{/}' + setter.base + 'lib/tabletree/' + item;
|
|
|
} else{
|
|
|
} else {
|
|
|
mods[item] = '{/}' + setter.base + 'lib/extend/' + item;
|
|
|
}
|
|
|
layui.extend(mods);
|
...
|
...
|
@@ -331,7 +338,7 @@ layui.extend({ |
|
|
} else if (item[0].nodeName.toUpperCase() === 'CANVAS') {
|
|
|
var canvas = item;
|
|
|
var target = canvas.parent();
|
|
|
canvas[0].width= target.width() + 30;
|
|
|
canvas[0].width = target.width() + 30;
|
|
|
canvas[0].height = target.height() + 20;
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -339,7 +346,7 @@ layui.extend({ |
|
|
|
|
|
// 页面尺寸变化的事件栈
|
|
|
window.onresizeEvents = [];
|
|
|
window.setResizeEvents = function(key, val) {
|
|
|
window.setResizeEvents = function (key, val) {
|
|
|
var index = -1;
|
|
|
|
|
|
$(onresizeEvents).map(function (i, event) {
|
...
|
...
|
@@ -351,7 +358,7 @@ layui.extend({ |
|
|
if (index !== -1) {
|
|
|
onresizeEvents.splice(index, 1);
|
|
|
}
|
|
|
onresizeEvents.push({ key: key, val: val });
|
|
|
onresizeEvents.push({key: key, val: val});
|
|
|
};
|
|
|
window.addEventListener('resize', resizeEventFn);
|
|
|
|
...
|
...
|
@@ -361,7 +368,7 @@ layui.extend({ |
|
|
*/
|
|
|
window.generateUUID = function () {
|
|
|
var d = new Date().getTime()
|
|
|
return'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
|
var r = (d + Math.random() * 16) % 16 | 0;
|
|
|
d = Math.floor(d / 16);
|
|
|
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
...
|
...
|
@@ -370,26 +377,26 @@ layui.extend({ |
|
|
|
|
|
|
|
|
//系统登录后建立长连接监控实时告警信息
|
|
|
layui.use(['jquery','msgTips','sockjs','stomp', 'laytpl'], function () {
|
|
|
layui.use(['jquery', 'msgTips', 'sockjs', 'stomp', 'laytpl'], function () {
|
|
|
var msgTips = layui.msgTips
|
|
|
,webSockState = false
|
|
|
,sock = undefined
|
|
|
,stompClient = null
|
|
|
,laytpl = layui.laytpl
|
|
|
,access_token = localStorage.getItem("access_token")
|
|
|
,domainName = sessionStorage.getItem('domainName');
|
|
|
, webSockState = false
|
|
|
, sock = undefined
|
|
|
, stompClient = null
|
|
|
, laytpl = layui.laytpl
|
|
|
, access_token = localStorage.getItem("access_token")
|
|
|
, domainName = sessionStorage.getItem('domainName');
|
|
|
|
|
|
var connectFlg = false;
|
|
|
var tryIndex = 1;
|
|
|
var voiceList = [{
|
|
|
voice_:'咳咳',
|
|
|
type_:'ERROR',
|
|
|
},{
|
|
|
voice_:'微信提醒',
|
|
|
type_:'WARNING',
|
|
|
},{
|
|
|
voice_:'滑稽',
|
|
|
type_:'SUCCESS',
|
|
|
voice_: '咳咳',
|
|
|
type_: 'ERROR',
|
|
|
}, {
|
|
|
voice_: '微信提醒',
|
|
|
type_: 'WARNING',
|
|
|
}, {
|
|
|
voice_: '滑稽',
|
|
|
type_: 'SUCCESS',
|
|
|
}];
|
|
|
|
|
|
//setTimeout(alarmWebSocket,10000);
|
...
|
...
|
@@ -397,11 +404,11 @@ layui.extend({ |
|
|
if (!webSockState) {
|
|
|
webSockState = true;
|
|
|
console.log("websock正在连接。。。。。。")
|
|
|
sock = new SockJS(domainName+'/api-web/sock-js?access_token=' + access_token);
|
|
|
sock = new SockJS(domainName + '/api-web/sock-js?access_token=' + access_token);
|
|
|
stompClient = Stomp.over(sock);
|
|
|
|
|
|
|
|
|
stompClient.connect({},function (frame) {
|
|
|
stompClient.connect({}, function (frame) {
|
|
|
console.log("websock连接成功。。。。。。")
|
|
|
connectFlg = true;
|
|
|
tryIndex = 1;
|
...
|
...
|
@@ -410,13 +417,13 @@ layui.extend({ |
|
|
// console.log(e)
|
|
|
// });
|
|
|
//通过stompClient.subscribe订阅/topic/getResponse 目标(destination)发送的消息
|
|
|
stompClient.subscribe('/alarmQuery/', function(respnose){
|
|
|
stompClient.subscribe('/alarmQuery/', function (respnose) {
|
|
|
var alarmArr = JSON.parse(respnose.body);
|
|
|
var mp3Name = sessionStorage.getItem('mp3');
|
|
|
var audio = audioPlayer(`../src/style/mp3/${mp3Name}.mp3`)
|
|
|
$.each(alarmArr,function (i,v) {
|
|
|
$.each(alarmArr, function (i, v) {
|
|
|
if (v.alarmContent) {
|
|
|
(function(i) {
|
|
|
(function (i) {
|
|
|
var alarmLevel = 'error';
|
|
|
var alarmType = 'alarm';
|
|
|
if (v.clearType && v.alarmLevel === '1') {
|
...
|
...
|
@@ -429,24 +436,24 @@ layui.extend({ |
|
|
alarmLevel = 'success';
|
|
|
alarmType = 'alarmHis'
|
|
|
}
|
|
|
let isNotify = alarmByUser(v.alarmId,alarmType === 'alarm' ? 'b_alarm' : 'b_alarm_his');
|
|
|
let isNotify = alarmByUser(v.alarmId, alarmType === 'alarm' ? 'b_alarm' : 'b_alarm_his');
|
|
|
if (isNotify) {
|
|
|
setTimeout(function() {
|
|
|
setTimeout(function () {
|
|
|
audio.playclip();
|
|
|
new msgTips({
|
|
|
dom:".right-bottom-tips",
|
|
|
dom: ".right-bottom-tips",
|
|
|
title: "告警消息",
|
|
|
message:`<p style="line-height: 40px">${v.alarmContent}</p>`,
|
|
|
duration:10000,
|
|
|
space:10,
|
|
|
firstSpace:8,
|
|
|
limit:8,
|
|
|
margin:15,
|
|
|
direction:'right bottom',
|
|
|
timingFun:'ease',
|
|
|
width:'300px',
|
|
|
toastType:alarmLevel,
|
|
|
type:'click',
|
|
|
message: `<p style="line-height: 40px">${v.alarmContent}</p>`,
|
|
|
duration: 10000,
|
|
|
space: 10,
|
|
|
firstSpace: 8,
|
|
|
limit: 8,
|
|
|
margin: 15,
|
|
|
direction: 'right bottom',
|
|
|
timingFun: 'ease',
|
|
|
width: '300px',
|
|
|
toastType: alarmLevel,
|
|
|
type: 'click',
|
|
|
action: function () {
|
|
|
if (alarmType === 'alarm') {
|
|
|
location.hash = "/alarm/activewarning/alarmNo=" + v.alarmNo;
|
...
|
...
|
@@ -462,24 +469,24 @@ layui.extend({ |
|
|
})
|
|
|
});
|
|
|
// 弹框展示错误消息
|
|
|
let showTips = function (content,title="提示", toastType = 'error', hash, delay = 1000, queryResult) {
|
|
|
let showTips = function (content, title = "提示", toastType = 'error', hash, delay = 1000, queryResult) {
|
|
|
if (queryResult) {
|
|
|
content = laytpl(content).render(queryResult);
|
|
|
}
|
|
|
|
|
|
//判断是否为故障诊断的三种类型
|
|
|
if(toastType=='faultinfo'||toastType=='faultover'||toastType=='faultprogress'){
|
|
|
var imgUrl="";
|
|
|
if(toastType=='faultinfo'){
|
|
|
imgUrl="/src/style/img/fault.png";
|
|
|
if (toastType == 'faultinfo' || toastType == 'faultover' || toastType == 'faultprogress') {
|
|
|
var imgUrl = "";
|
|
|
if (toastType == 'faultinfo') {
|
|
|
imgUrl = "/src/style/img/fault.png";
|
|
|
}
|
|
|
|
|
|
if(toastType=='faultover'){
|
|
|
imgUrl="/src/style/img/faultprogress.png";
|
|
|
if (toastType == 'faultover') {
|
|
|
imgUrl = "/src/style/img/faultprogress.png";
|
|
|
}
|
|
|
|
|
|
if(toastType=='faultprogress'){
|
|
|
imgUrl="/src/style/img/faultover.png";
|
|
|
if (toastType == 'faultprogress') {
|
|
|
imgUrl = "/src/style/img/faultover.png";
|
|
|
}
|
|
|
setTimeout(function () {
|
|
|
new msgTips({
|
...
|
...
|
@@ -499,13 +506,13 @@ layui.extend({ |
|
|
action: function () {
|
|
|
//if (hash) {
|
|
|
// location.hash = hash;
|
|
|
location.hash = "/faultDiagnosis/list/faultNo="+content.split(",")[0].split(":")[1];
|
|
|
location.hash = "/faultDiagnosis/list/faultNo=" + content.split(",")[0].split(":")[1];
|
|
|
//}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
}, delay);
|
|
|
}else{
|
|
|
} else {
|
|
|
setTimeout(function () {
|
|
|
new msgTips({
|
|
|
dom: ".right-bottom-tips",
|
...
|
...
|
@@ -523,10 +530,10 @@ layui.extend({ |
|
|
type: 'click',
|
|
|
action: function () {
|
|
|
if (hash) {
|
|
|
if(hash.toLowerCase().indexOf("http://")!=-1 && hash.toLowerCase().indexOf("https://")!=-1){
|
|
|
if (hash.toLowerCase().indexOf("http://") != -1 && hash.toLowerCase().indexOf("https://") != -1) {
|
|
|
location.hash = hash;
|
|
|
}else{
|
|
|
window.location.href=hash;
|
|
|
} else {
|
|
|
window.location.href = hash;
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -538,7 +545,7 @@ layui.extend({ |
|
|
|
|
|
// 订阅实时消息
|
|
|
stompClient.subscribe('/realTime/', function (respnose) {
|
|
|
console.log('实时信息: '+ respnose);
|
|
|
console.log('实时信息: ' + respnose);
|
|
|
var data = respnose.body;
|
|
|
if (data) {
|
|
|
var obj = JSON.parse(data);
|
...
|
...
|
@@ -548,7 +555,7 @@ layui.extend({ |
|
|
|
|
|
// 订阅用户消息
|
|
|
stompClient.subscribe("/user/realTime/notifications/", function (respnose) {
|
|
|
console.log('专属信息: '+ respnose);
|
|
|
console.log('专属信息: ' + respnose);
|
|
|
var data = respnose.body;
|
|
|
if (data) {
|
|
|
var obj = JSON.parse(data);
|
...
|
...
|
@@ -559,11 +566,11 @@ layui.extend({ |
|
|
view.exit();
|
|
|
});
|
|
|
} else {
|
|
|
showTips(obj.content,obj.title, obj.msgType.toLowerCase(), obj.href, 1000, obj.queryResult);
|
|
|
if(typeof(obj.msgType)!="undefined"){
|
|
|
showTips(obj.content, obj.title, obj.msgType.toLowerCase(), obj.href, 1000, obj.queryResult);
|
|
|
if (typeof(obj.msgType) != "undefined") {
|
|
|
var str = '滑稽';
|
|
|
voiceList.forEach(item =>{
|
|
|
if(item.type_== obj.msgType){
|
|
|
voiceList.forEach(item => {
|
|
|
if (item.type_ == obj.msgType) {
|
|
|
str = item.voice_;
|
|
|
}
|
|
|
})
|
...
|
...
|
@@ -574,10 +581,10 @@ layui.extend({ |
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},function(e){
|
|
|
}, function (e) {
|
|
|
console.log(`(${tryIndex})链接失败,重试中....`)
|
|
|
connectFlg = false;
|
|
|
if(location.hash.indexOf('#/user/login') == -1){
|
|
|
if (location.hash.indexOf('#/user/login') == -1) {
|
|
|
// 调用测试接口,出现过期则会跳转到登录页面
|
|
|
admin.req({
|
|
|
url: domainName + "/api-web/common/test"
|
...
|
...
|
@@ -595,7 +602,7 @@ layui.extend({ |
|
|
}
|
|
|
|
|
|
//告警是否属于当前用户
|
|
|
function alarmByUser(alarmId,tableName) {
|
|
|
function alarmByUser(alarmId, tableName) {
|
|
|
let isNotify = false;
|
|
|
$.ajax({
|
|
|
url: sessionStorage.getItem('domainName') + '/api-web/bAlarm/hasAlarmByUserName?access_token=' + localStorage.getItem("access_token") + '&alarmId=' + alarmId + '&tableName=' + tableName,
|
...
|
...
|
@@ -610,17 +617,17 @@ layui.extend({ |
|
|
}
|
|
|
|
|
|
//音频播放
|
|
|
function audioPlayer(url){
|
|
|
function audioPlayer(url) {
|
|
|
var audio = document.createElement('audio')
|
|
|
if (audio.canPlayType){
|
|
|
if (audio.canPlayType) {
|
|
|
var element = document.createElement('source')
|
|
|
element.setAttribute('src', url)
|
|
|
element.setAttribute('type', 'audio/mpeg')
|
|
|
audio.appendChild(element)
|
|
|
audio.load()
|
|
|
audio.playclip=function(){
|
|
|
audio.playclip = function () {
|
|
|
audio.pause()
|
|
|
audio.currentTime=0
|
|
|
audio.currentTime = 0
|
|
|
audio.play()
|
|
|
}
|
|
|
return audio
|
...
|
...
|
@@ -629,14 +636,14 @@ layui.extend({ |
|
|
|
|
|
var tryFunc = function () {
|
|
|
setTimeout(function () {
|
|
|
if(!connectFlg){
|
|
|
if (!connectFlg) {
|
|
|
tryIndex++;
|
|
|
access_token = localStorage.getItem("access_token")
|
|
|
webSockState = false;
|
|
|
alarmWebSocket();
|
|
|
//setTimeout(tryFunc(),3000);
|
|
|
}
|
|
|
},tryIndex*3000);
|
|
|
}, tryIndex * 3000);
|
|
|
}
|
|
|
tryFunc();
|
|
|
})
|
...
|
...
|
@@ -647,8 +654,8 @@ layui.extend({ |
|
|
});
|
|
|
//解决刷新后中间出现404页面问题
|
|
|
var show = location.search.substr(1).split("&")[0].split("=")[1];
|
|
|
if(show == '1') window.history.pushState({} ,'' ,'#');
|
|
|
if(show != '0') location.hash = "/";
|
|
|
if (show == '1') window.history.pushState({}, '', '#');
|
|
|
if (show != '0') location.hash = "/";
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
|