Authored by 袁晋鹏

新增日志页面嵌套监控的公共方法,后续根据需求合入公共代码

@@ -43,7 +43,8 @@ layui.define(['laytpl', 'layer', 'element', 'util'], function(exports){ @@ -43,7 +43,8 @@ layui.define(['laytpl', 'layer', 'element', 'util'], function(exports){
43 //独立页面路由,可随意添加(无需写参数) 43 //独立页面路由,可随意添加(无需写参数)
44 ,indPage: [ 44 ,indPage: [
45 '/user/login', //登入页 45 '/user/login', //登入页
46 - '/page/forward' // 听云访问系统页面 46 + '/page/forward', // 听云访问系统页面
  47 + '/page/log' //辽宁日志系统访问监控页面
47 ] 48 ]
48 49
49 //扩展的第三方模块 50 //扩展的第三方模块
  1 +layui.define(['sessions', 'form', 'common'],function (exports) {
  2 + //登录相关模块,对外暴露的接口
  3 + exports('pageLog', function () {
  4 +
  5 + var $ = layui.$
  6 + , setter = layui.setter
  7 + , form = layui.form
  8 + , router = layui.router()
  9 + , search = router.search
  10 + , common = layui.common
  11 + , sessions = layui.sessions;
  12 +
  13 +
  14 + function getUrlParam(key) {
  15 + var href = window.location.href;
  16 + var url = href.split("?");
  17 + if (url.length <= 1) {
  18 + return "";
  19 + }
  20 + var params = url[1].split("&");
  21 +
  22 + for (var i = 0; i < params.length; i++) {
  23 + var param = params[i].split("=");
  24 + if (key == param[0]) {
  25 + var temp = "" + params[1];
  26 + if (temp.search("#") > -1) {
  27 + return temp.substring(0, temp.indexOf("#"));
  28 + }
  29 + return param[1];
  30 + }
  31 + }
  32 + return "";
  33 + }
  34 +
  35 + try {
  36 + logPage();
  37 + }catch (e) {
  38 + err()
  39 + }
  40 +
  41 +
  42 + function err(){
  43 + layer.msg('没有权限!', {icon: 5, time: 500});
  44 + $('#text').text("没有权限!")
  45 + layer.closeAll();
  46 + }
  47 +
  48 + /**
  49 + * 听云系统嵌套咋们系统
  50 + * 听云token是通过连接传参,key=Authorization
  51 + * url 是请求的页面
  52 + * http://xxxxxx:8088/?show=0&Authorization=token&url=alarm/activewarning#/page/forward
  53 + * @constructor
  54 + */
  55 + function logPage(){
  56 + var index = layer.load(2); //加载层
  57 + // 日志token
  58 + var tokenStr = getUrlParam("Authorization").replace('Bearer%20','').replace('Bearer ','');
  59 + // 跳转地址
  60 + var url = getUrlParam("url").split('#/')[0];
  61 +
  62 + // 日志地址
  63 + var logApi = 'http://192.168.0.44:8080';
  64 + $.ajax({
  65 + url: '/config/getConfig',
  66 + data: {
  67 + configName: 'url'
  68 + },
  69 + async: false,
  70 + success(response) {
  71 + //debugger
  72 + if(response.gateway){
  73 + //logApi = response.gateway;
  74 + }
  75 + }
  76 + });
  77 +
  78 + var api = logApi + "/api-user/users/getUserByToken";
  79 + $.ajax(api,{
  80 + data:{
  81 + "access_token": tokenStr
  82 + },
  83 + headers: {
  84 + 'authorization': 'Bearer '+tokenStr,
  85 + },
  86 + //dataType:'json',//服务器返回json格式数据
  87 + type:'get',//HTTP请求类型
  88 + timeout:30000,//超时时间设置为30秒;
  89 + //contentType: 'application/x-www-form-urlencoded',
  90 + success:function(rsp){
  91 + if(rsp.code == 0){
  92 + console.log(JSON.stringify(rsp.data));
  93 + var name = rsp.object.username;
  94 + var pwd = common.Base64.decode(rsp.object.password);
  95 + console.log(pwd);
  96 + var field = {};
  97 + field.username = name;
  98 + field.password = '123456';
  99 + field.grant_type = 'password';
  100 + field.scope = 'app';
  101 + field.client_id = 'webApp';
  102 + field.client_secret = 'webApp';
  103 + field.deviceId = "";
  104 + field.validCode = '';
  105 +
  106 +
  107 + $.ajax({
  108 + url: common.domainName + '/api-auth/oauth/token',
  109 + data: field,
  110 + type: 'POST',
  111 + dataType: 'JSON',
  112 + success: function (data) {
  113 + if (data.access_token) {
  114 + console.log('登录成功')
  115 +
  116 + layui.data(setter.tableName, {
  117 + key: setter.request.tokenName
  118 + , value: data.access_token
  119 + });
  120 + sessions.putToken(data);
  121 + sessions.putUser(name);
  122 + layer.closeAll();
  123 + //将access_token和refresh_token写入本地
  124 + localStorage.setItem("access_token", data.access_token);
  125 + localStorage.setItem("refresh_token", data.refresh_token);
  126 + //将登陆url写入本地
  127 + localStorage.setItem("loginUrl", location.href);
  128 +
  129 + //登入成功的提示与跳转
  130 + window.location = window.location.origin + '/start/index.html?show=0&access_token='+data.access_token+'#/'+url;
  131 +
  132 + } else {
  133 + layer.msg('登录失败,请重试', {icon: 5, time: 500});
  134 + }
  135 + },
  136 + error: function (xhr) {
  137 + err();
  138 + }
  139 + });
  140 + }
  141 + },
  142 + error:function(xhr,type,errorThrown){
  143 + err();
  144 + }
  145 + });
  146 + }
  147 + });
  148 +});
@@ -9,29 +9,29 @@ @@ -9,29 +9,29 @@
9 9
10 layui.extend({ 10 layui.extend({
11 setter: 'config' //配置文件 11 setter: 'config' //配置文件
12 - ,admin: 'lib/admin' //核心模块 12 + , admin: 'lib/admin' //核心模块
13 /*,sessions: 'controller/sessions'*/ 13 /*,sessions: 'controller/sessions'*/
14 - ,view: 'lib/view' //核心模块  
15 -}).define(['setter', 'admin'], function(exports){ 14 + , view: 'lib/view' //核心模块
  15 +}).define(['setter', 'admin'], function (exports) {
16 var setter = layui.setter 16 var setter = layui.setter
17 - ,element = layui.element  
18 - ,admin = layui.admin  
19 - ,tabsPage = admin.tabsPage  
20 - ,view = layui.view  
21 - ,defaultIndex = '' 17 + , element = layui.element
  18 + , admin = layui.admin
  19 + , tabsPage = admin.tabsPage
  20 + , view = layui.view
  21 + , defaultIndex = ''
22 22
23 23
24 // 根据 路由渲染页面 24 // 根据 路由渲染页面
25 - ,renderPage = function(){ 25 + , renderPage = function () {
26 var show = location.search.substr(1).split("&")[0].split("=")[1]; 26 var show = location.search.substr(1).split("&")[0].split("=")[1];
27 var router = layui.router() 27 var router = layui.router()
28 - ,path = router.path  
29 - ,pathURL = admin.correctRouter(router.path.join('/')); 28 + , path = router.path
  29 + , pathURL = admin.correctRouter(router.path.join('/'));
30 //默认读取主页 30 //默认读取主页
31 - if(!path.length) path = [''];  
32 - if(!tabsPage.index && !renderPage.haveInit && show != '0') path=[''] 31 + if (!path.length) path = [''];
  32 + if (!tabsPage.index && !renderPage.haveInit && show != '0') path = ['']
33 // 如果访问首页 33 // 如果访问首页
34 - if(pathURL === '/'){ 34 + if (pathURL === '/') {
35 // path[path.length - 1] = setter.entry; 35 // path[path.length - 1] = setter.entry;
36 36
37 // 根据不同角色 用户 展示不同首页 开始 37 // 根据不同角色 用户 展示不同首页 开始
@@ -41,7 +41,7 @@ layui.extend({ @@ -41,7 +41,7 @@ layui.extend({
41 async: false, 41 async: false,
42 success(response) { 42 success(response) {
43 // 获取成功 43 // 获取成功
44 - if(response && response.success && response.object){ 44 + if (response && response.success && response.object) {
45 if (response.object.path && response.object.path != '/') { 45 if (response.object.path && response.object.path != '/') {
46 defaultIndex = '/' + response.object.path; 46 defaultIndex = '/' + response.object.path;
47 } else { 47 } else {
@@ -68,13 +68,13 @@ layui.extend({ @@ -68,13 +68,13 @@ layui.extend({
68 */ 68 */
69 69
70 //重置状态 70 //重置状态
71 - var reset = function(type){ 71 + var reset = function (type) {
72 //renderPage.haveInit && layer.closeAll(); 72 //renderPage.haveInit && layer.closeAll();
73 - if(renderPage.haveInit){  
74 - $('.layui-layer').each(function(){ 73 + if (renderPage.haveInit) {
  74 + $('.layui-layer').each(function () {
75 var othis = $(this), 75 var othis = $(this),
76 index = othis.attr('times'); 76 index = othis.attr('times');
77 - if(!othis.hasClass('layui-layim')){ 77 + if (!othis.hasClass('layui-layim')) {
78 layer.close(index); 78 layer.close(index);
79 } 79 }
80 }); 80 });
@@ -86,63 +86,63 @@ layui.extend({ @@ -86,63 +86,63 @@ layui.extend({
86 }; 86 };
87 87
88 //如果路由来自于 tab 切换,则不重新请求视图 88 //如果路由来自于 tab 切换,则不重新请求视图
89 - if(tabsPage.type === 'tab'){ 89 + if (tabsPage.type === 'tab') {
90 //切换到非主页、或者切换到主页且主页必须有内容。方可阻止请求 90 //切换到非主页、或者切换到主页且主页必须有内容。方可阻止请求
91 - if(pathURL !== '/' || (pathURL === '/' && admin.tabsBody().html())){ 91 + if (pathURL !== '/' || (pathURL === '/' && admin.tabsBody().html())) {
92 admin.tabsBodyChange(tabsPage.index); 92 admin.tabsBodyChange(tabsPage.index);
93 return reset(tabsPage.type); 93 return reset(tabsPage.type);
94 } 94 }
95 } 95 }
96 96
97 //请求视图渲染 97 //请求视图渲染
98 - view().render(path.join('/')).then(function(res){ 98 + view().render(path.join('/')).then(function (res) {
99 //遍历页签选项卡 99 //遍历页签选项卡
100 var matchTo 100 var matchTo
101 - ,tabs = $('#LAY_app_tabsheader>li'); 101 + , tabs = $('#LAY_app_tabsheader>li');
102 102
103 - tabs.each(function(index){ 103 + tabs.each(function (index) {
104 var li = $(this) 104 var li = $(this)
105 - ,layid = li.attr('lay-id');  
106 - if(layid === pathURL){ 105 + , layid = li.attr('lay-id');
  106 + if (layid === pathURL) {
107 matchTo = true; 107 matchTo = true;
108 tabsPage.index = index; 108 tabsPage.index = index;
109 } 109 }
110 }); 110 });
111 var tabName; 111 var tabName;
112 //start lsq 页面刷新后名称改变,把aj得存储到localStorage中 2022-03-30 112 //start lsq 页面刷新后名称改变,把aj得存储到localStorage中 2022-03-30
113 - let routerPath=router.path;  
114 - if(routerPath.indexOf('ajConfig')!=-1 && routerPath.indexOf('view')!=-1 && !localStorage.getItem(router.search.ajConfig)){  
115 - localStorage.setItem(router.search.ajConfig,admin.tabsPage.elem.text()); 113 + let routerPath = router.path;
  114 + if (routerPath.indexOf('ajConfig') != -1 && routerPath.indexOf('view') != -1 && !localStorage.getItem(router.search.ajConfig)) {
  115 + localStorage.setItem(router.search.ajConfig, admin.tabsPage.elem.text());
116 } 116 }
117 //end lsq 2022-03-30 117 //end lsq 2022-03-30
118 try { 118 try {
119 let el = admin.tabsPage.elem; 119 let el = admin.tabsPage.elem;
120 - if(el && el.attr('lay-href-type')){  
121 - if(el.attr('lay-href-type') == 'menu' && !matchTo){  
122 - tabName= admin.tabsPage.elem.text(); 120 + if (el && el.attr('lay-href-type')) {
  121 + if (el.attr('lay-href-type') == 'menu' && !matchTo) {
  122 + tabName = admin.tabsPage.elem.text();
123 } 123 }
124 } 124 }
125 - } catch (e){ 125 + } catch (e) {
126 } 126 }
127 - if(!tabName){ 127 + if (!tabName) {
128 //lsq 页面刷新后名称改变 2022-03-30 128 //lsq 页面刷新后名称改变 2022-03-30
129 - if(routerPath.indexOf('ajConfig')!=-1 && routerPath.indexOf('view')!=-1){  
130 - tabName=localStorage.getItem(router.search.ajConfig);  
131 - }else{  
132 - tabName= res.title 129 + if (routerPath.indexOf('ajConfig') != -1 && routerPath.indexOf('view') != -1) {
  130 + tabName = localStorage.getItem(router.search.ajConfig);
  131 + } else {
  132 + tabName = res.title
133 133
134 } 134 }
135 } 135 }
136 136
137 //如果未在选项卡中匹配到,则追加选项卡 137 //如果未在选项卡中匹配到,则追加选项卡
138 - if(setter.pageTabs && pathURL !== '/'){  
139 - if(!matchTo){ 138 + if (setter.pageTabs && pathURL !== '/') {
  139 + if (!matchTo) {
140 $(APP_BODY).append('<div class="layadmin-tabsbody-item layui-show"></div>'); 140 $(APP_BODY).append('<div class="layadmin-tabsbody-item layui-show"></div>');
141 tabsPage.index = tabs.length; 141 tabsPage.index = tabs.length;
142 element.tabAdd(FILTER_TAB_TBAS, { 142 element.tabAdd(FILTER_TAB_TBAS, {
143 - title: '<span>'+ (tabName || '新标签页') +'</span>'  
144 - ,id: pathURL  
145 - ,attr: router.href 143 + title: '<span>' + (tabName || '新标签页') + '</span>'
  144 + , id: pathURL
  145 + , attr: router.href
146 }); 146 });
147 } 147 }
148 } 148 }
@@ -156,21 +156,21 @@ layui.extend({ @@ -156,21 +156,21 @@ layui.extend({
156 $('* [lay-id="' + pathURL + '"] span').text(tabName) 156 $('* [lay-id="' + pathURL + '"] span').text(tabName)
157 admin.tabsBodyChange(tabsPage.index); 157 admin.tabsBodyChange(tabsPage.index);
158 158
159 - }).done(function(){ 159 + }).done(function () {
160 layui.use('common', layui.cache.callback.common); 160 layui.use('common', layui.cache.callback.common);
161 $win.on('resize', layui.data.resize); 161 $win.on('resize', layui.data.resize);
162 162
163 element.render('breadcrumb', 'breadcrumb'); 163 element.render('breadcrumb', 'breadcrumb');
164 164
165 //容器 scroll 事件,剔除吸附层 165 //容器 scroll 事件,剔除吸附层
166 - admin.tabsBody(tabsPage.index).on('scroll', function(){ 166 + admin.tabsBody(tabsPage.index).on('scroll', function () {
167 var othis = $(this) 167 var othis = $(this)
168 - ,elemDate = $('.layui-laydate')  
169 - ,layerOpen = $('.layui-layer')[0]; 168 + , elemDate = $('.layui-laydate')
  169 + , layerOpen = $('.layui-layer')[0];
170 170
171 //关闭 layDate 171 //关闭 layDate
172 - if(elemDate[0]){  
173 - elemDate.each(function(){ 172 + if (elemDate[0]) {
  173 + elemDate.each(function () {
174 var thisElemDate = $(this); 174 var thisElemDate = $(this);
175 thisElemDate.hasClass('layui-laydate-static') || thisElemDate.remove(); 175 thisElemDate.hasClass('layui-laydate-static') || thisElemDate.remove();
176 }); 176 });
@@ -186,14 +186,14 @@ layui.extend({ @@ -186,14 +186,14 @@ layui.extend({
186 } 186 }
187 187
188 //入口页面 188 //入口页面
189 - ,entryPage = function(fn){ 189 + , entryPage = function (fn) {
190 var router = layui.router() 190 var router = layui.router()
191 - ,container = view(setter.container)  
192 - ,pathURL = admin.correctRouter(router.path.join('/'))  
193 - ,isIndPage; 191 + , container = view(setter.container)
  192 + , pathURL = admin.correctRouter(router.path.join('/'))
  193 + , isIndPage;
194 //检查是否属于独立页面 194 //检查是否属于独立页面
195 - layui.each(setter.indPage, function(index, item){  
196 - if(pathURL === item){ 195 + layui.each(setter.indPage, function (index, item) {
  196 + if (pathURL === item) {
197 return isIndPage = true; 197 return isIndPage = true;
198 } 198 }
199 }); 199 });
@@ -206,51 +206,58 @@ layui.extend({ @@ -206,51 +206,58 @@ layui.extend({
206 // 跳转到过度页面的时候,判断参数与跳转的过渡页面的参数是否一直,则强制设置hash 206 // 跳转到过度页面的时候,判断参数与跳转的过渡页面的参数是否一直,则强制设置hash
207 // http://localhost:8088/?Authorization=xxx&show=0&url=alarm/activewarning#/page/forward 207 // http://localhost:8088/?Authorization=xxx&show=0&url=alarm/activewarning#/page/forward
208 var href = window.location.href; 208 var href = window.location.href;
209 - if(href.indexOf('?Authorization') != -1 && href.indexOf('&show=0&url=') != -1 && pathURL !== '/page/forward'){ 209 + console.log(pathURL)
  210 + console.log(href)
  211 + if (href.indexOf('?Authorization') != -1 && href.indexOf('&show=0&url=') != -1 && pathURL !== '/page/forward'&& pathURL !== '/page/log') {
  212 + if(href.indexOf('&flag=log') != -1){
  213 + return location.hash = "/page/log";
  214 + }else {
210 return location.hash = "/page/forward"; 215 return location.hash = "/page/forward";
211 } 216 }
  217 + }
  218 +
212 //跳转到告警页面 219 //跳转到告警页面
213 - let params=new URLSearchParams(location.search);  
214 - let [bizId]=[params.get('bizId')]; 220 + let params = new URLSearchParams(location.search);
  221 + let [bizId] = [params.get('bizId')];
215 //活动告警页面 222 //活动告警页面
216 - if( href.indexOf('&show=3') != -1 && pathURL !== '/alarm/activewarning'){  
217 - return location.hash = "/alarm/activewarning/bizId="+bizId; 223 + if (href.indexOf('&show=3') != -1 && pathURL !== '/alarm/activewarning') {
  224 + return location.hash = "/alarm/activewarning/bizId=" + bizId;
218 } 225 }
219 //历史告警页面 226 //历史告警页面
220 - if( href.indexOf('&show=4') != -1 && pathURL !== '/alarm/historywarning'){  
221 - return location.hash = "/alarm/historywarning/bizId="+bizId; 227 + if (href.indexOf('&show=4') != -1 && pathURL !== '/alarm/historywarning') {
  228 + return location.hash = "/alarm/historywarning/bizId=" + bizId;
222 } 229 }
223 230
224 //独立页面 231 //独立页面
225 - if(isIndPage || pathURL === '/user/login'|| pathURL === '/page/forward'){ //此处单独判断登入页,是为了兼容旧版(即未在 sessions.js 配置 indPage 的情况) 232 + if (isIndPage || pathURL === '/user/login' || pathURL === '/page/forward' || pathURL == "/page/log") { //此处单独判断登入页,是为了兼容旧版(即未在 sessions.js 配置 indPage 的情况)
226 233
227 let path = router.path.join('/') 234 let path = router.path.join('/')
228 - if(pathURL.indexOf('/user/login') != -1){ 235 + if (pathURL.indexOf('/user/login') != -1) {
229 var loginIndex = 'default'; 236 var loginIndex = 'default';
230 // let loginSkin = sessionStorage.getItem("loginSkin"); 237 // let loginSkin = sessionStorage.getItem("loginSkin");
231 //lsq 从cookie中获取登录皮肤 2022-03-31 238 //lsq 从cookie中获取登录皮肤 2022-03-31
232 let loginSkin = admin.getCookie("loginSkin"); 239 let loginSkin = admin.getCookie("loginSkin");
233 - if(loginSkin && ["default",'skin1','skin2'].indexOf(loginSkin) != -1){ 240 + if (loginSkin && ["default", 'skin1', 'skin2'].indexOf(loginSkin) != -1) {
234 loginIndex = loginSkin; 241 loginIndex = loginSkin;
235 } 242 }
236 243
237 path = path + '-' + loginIndex; 244 path = path + '-' + loginIndex;
238 } 245 }
239 - container.render(path).done(function(){ 246 + container.render(path).done(function () {
240 admin.pageType = 'alone'; 247 admin.pageType = 'alone';
241 }); 248 });
242 } else { //后台框架页面 249 } else { //后台框架页面
243 250
244 //强制拦截未登入 251 //强制拦截未登入
245 - if(setter.interceptor){ 252 + if (setter.interceptor) {
246 var local = layui.data(setter.tableName); 253 var local = layui.data(setter.tableName);
247 - if(!local[setter.request.tokenName]){  
248 - return location.hash = '/user/login/redirect='+ encodeURIComponent(pathURL); //跳转到登入页 254 + if (!local[setter.request.tokenName]) {
  255 + return location.hash = '/user/login/redirect=' + encodeURIComponent(pathURL); //跳转到登入页
249 } 256 }
250 } 257 }
251 258
252 //渲染后台结构 259 //渲染后台结构
253 - if(admin.pageType === 'console') { //后台主体页 260 + if (admin.pageType === 'console') { //后台主体页
254 renderPage(); 261 renderPage();
255 } else { //初始控制台结构 262 } else { //初始控制台结构
256 var renderUrl = 'layout'; 263 var renderUrl = 'layout';
@@ -258,14 +265,14 @@ layui.extend({ @@ -258,14 +265,14 @@ layui.extend({
258 // renderUrl = 'layout-nx'; 265 // renderUrl = 'layout-nx';
259 // } 266 // }
260 let userLayout = sessionStorage.getItem("userLayout"); 267 let userLayout = sessionStorage.getItem("userLayout");
261 - if(userLayout && ['layout','layout-nx'].indexOf(userLayout) != -1){ 268 + if (userLayout && ['layout', 'layout-nx'].indexOf(userLayout) != -1) {
262 renderUrl = userLayout; 269 renderUrl = userLayout;
263 } 270 }
264 - container.render(renderUrl).done(function(){ 271 + container.render(renderUrl).done(function () {
265 renderPage(); 272 renderPage();
266 layui.element.render(); 273 layui.element.render();
267 274
268 - if(admin.screen() < 2){ 275 + if (admin.screen() < 2) {
269 admin.sideFlexible(); 276 admin.sideFlexible();
270 } 277 }
271 admin.pageType = 'console'; 278 admin.pageType = 'console';
@@ -275,32 +282,32 @@ layui.extend({ @@ -275,32 +282,32 @@ layui.extend({
275 } 282 }
276 } 283 }
277 284
278 - ,APP_BODY = '#LAY_app_body', FILTER_TAB_TBAS = 'layadmin-layout-tabs'  
279 - ,$ = layui.$, $win = $(window); 285 + , APP_BODY = '#LAY_app_body', FILTER_TAB_TBAS = 'layadmin-layout-tabs'
  286 + , $ = layui.$, $win = $(window);
280 287
281 //初始主体结构 288 //初始主体结构
282 - layui.link(setter.base + 'style/admin.css?v='+ (admin.v + '-1'));  
283 - layui.link(setter.base + 'style/css/main.css?v='+ (admin.v + '-1'), entryPage, 'layuiAdmin'); 289 + layui.link(setter.base + 'style/admin.css?v=' + (admin.v + '-1'));
  290 + layui.link(setter.base + 'style/css/main.css?v=' + (admin.v + '-1'), entryPage, 'layuiAdmin');
284 291
285 //监听Hash改变 292 //监听Hash改变
286 - window.onhashchange = function(){ 293 + window.onhashchange = function () {
287 entryPage(); 294 entryPage();
288 //执行 {setter.MOD_NAME}.hash 下的事件 295 //执行 {setter.MOD_NAME}.hash 下的事件
289 layui.event.call(this, setter.MOD_NAME, 'hash({*})', layui.router()); 296 layui.event.call(this, setter.MOD_NAME, 'hash({*})', layui.router());
290 }; 297 };
291 298
292 //扩展 lib 目录下的其它模块 299 //扩展 lib 目录下的其它模块
293 - layui.each(setter.extend, function(index, item){ 300 + layui.each(setter.extend, function (index, item) {
294 var mods = {}; 301 var mods = {};
295 - if(item === 'mxClient'){ 302 + if (item === 'mxClient') {
296 mods[item] = '{/}' + setter.base + 'lib/mxgraph/' + item; 303 mods[item] = '{/}' + setter.base + 'lib/mxgraph/' + item;
297 } 304 }
298 - else if(item === 'soulTable' || item === 'tableFilter' || item === 'tableChild'  
299 - || item === 'tableMerge' || item === 'excel'){ 305 + else if (item === 'soulTable' || item === 'tableFilter' || item === 'tableChild'
  306 + || item === 'tableMerge' || item === 'excel') {
300 mods[item] = '{/}' + setter.base + 'lib/soultable/' + item; 307 mods[item] = '{/}' + setter.base + 'lib/soultable/' + item;
301 - }else if(item === 'tableEdit' || item === 'tableTree'){ 308 + } else if (item === 'tableEdit' || item === 'tableTree') {
302 mods[item] = '{/}' + setter.base + 'lib/tabletree/' + item; 309 mods[item] = '{/}' + setter.base + 'lib/tabletree/' + item;
303 - } else{ 310 + } else {
304 mods[item] = '{/}' + setter.base + 'lib/extend/' + item; 311 mods[item] = '{/}' + setter.base + 'lib/extend/' + item;
305 } 312 }
306 layui.extend(mods); 313 layui.extend(mods);
@@ -331,7 +338,7 @@ layui.extend({ @@ -331,7 +338,7 @@ layui.extend({
331 } else if (item[0].nodeName.toUpperCase() === 'CANVAS') { 338 } else if (item[0].nodeName.toUpperCase() === 'CANVAS') {
332 var canvas = item; 339 var canvas = item;
333 var target = canvas.parent(); 340 var target = canvas.parent();
334 - canvas[0].width= target.width() + 30; 341 + canvas[0].width = target.width() + 30;
335 canvas[0].height = target.height() + 20; 342 canvas[0].height = target.height() + 20;
336 } 343 }
337 }); 344 });
@@ -339,7 +346,7 @@ layui.extend({ @@ -339,7 +346,7 @@ layui.extend({
339 346
340 // 页面尺寸变化的事件栈 347 // 页面尺寸变化的事件栈
341 window.onresizeEvents = []; 348 window.onresizeEvents = [];
342 - window.setResizeEvents = function(key, val) { 349 + window.setResizeEvents = function (key, val) {
343 var index = -1; 350 var index = -1;
344 351
345 $(onresizeEvents).map(function (i, event) { 352 $(onresizeEvents).map(function (i, event) {
@@ -351,7 +358,7 @@ layui.extend({ @@ -351,7 +358,7 @@ layui.extend({
351 if (index !== -1) { 358 if (index !== -1) {
352 onresizeEvents.splice(index, 1); 359 onresizeEvents.splice(index, 1);
353 } 360 }
354 - onresizeEvents.push({ key: key, val: val }); 361 + onresizeEvents.push({key: key, val: val});
355 }; 362 };
356 window.addEventListener('resize', resizeEventFn); 363 window.addEventListener('resize', resizeEventFn);
357 364
@@ -361,7 +368,7 @@ layui.extend({ @@ -361,7 +368,7 @@ layui.extend({
361 */ 368 */
362 window.generateUUID = function () { 369 window.generateUUID = function () {
363 var d = new Date().getTime() 370 var d = new Date().getTime()
364 - return'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 371 + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
365 var r = (d + Math.random() * 16) % 16 | 0; 372 var r = (d + Math.random() * 16) % 16 | 0;
366 d = Math.floor(d / 16); 373 d = Math.floor(d / 16);
367 return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); 374 return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
@@ -370,26 +377,26 @@ layui.extend({ @@ -370,26 +377,26 @@ layui.extend({
370 377
371 378
372 //系统登录后建立长连接监控实时告警信息 379 //系统登录后建立长连接监控实时告警信息
373 - layui.use(['jquery','msgTips','sockjs','stomp', 'laytpl'], function () { 380 + layui.use(['jquery', 'msgTips', 'sockjs', 'stomp', 'laytpl'], function () {
374 var msgTips = layui.msgTips 381 var msgTips = layui.msgTips
375 - ,webSockState = false  
376 - ,sock = undefined  
377 - ,stompClient = null  
378 - ,laytpl = layui.laytpl  
379 - ,access_token = localStorage.getItem("access_token")  
380 - ,domainName = sessionStorage.getItem('domainName'); 382 + , webSockState = false
  383 + , sock = undefined
  384 + , stompClient = null
  385 + , laytpl = layui.laytpl
  386 + , access_token = localStorage.getItem("access_token")
  387 + , domainName = sessionStorage.getItem('domainName');
381 388
382 var connectFlg = false; 389 var connectFlg = false;
383 var tryIndex = 1; 390 var tryIndex = 1;
384 var voiceList = [{ 391 var voiceList = [{
385 - voice_:'咳咳',  
386 - type_:'ERROR',  
387 - },{  
388 - voice_:'微信提醒',  
389 - type_:'WARNING',  
390 - },{  
391 - voice_:'滑稽',  
392 - type_:'SUCCESS', 392 + voice_: '咳咳',
  393 + type_: 'ERROR',
  394 + }, {
  395 + voice_: '微信提醒',
  396 + type_: 'WARNING',
  397 + }, {
  398 + voice_: '滑稽',
  399 + type_: 'SUCCESS',
393 }]; 400 }];
394 401
395 //setTimeout(alarmWebSocket,10000); 402 //setTimeout(alarmWebSocket,10000);
@@ -397,11 +404,11 @@ layui.extend({ @@ -397,11 +404,11 @@ layui.extend({
397 if (!webSockState) { 404 if (!webSockState) {
398 webSockState = true; 405 webSockState = true;
399 console.log("websock正在连接。。。。。。") 406 console.log("websock正在连接。。。。。。")
400 - sock = new SockJS(domainName+'/api-web/sock-js?access_token=' + access_token); 407 + sock = new SockJS(domainName + '/api-web/sock-js?access_token=' + access_token);
401 stompClient = Stomp.over(sock); 408 stompClient = Stomp.over(sock);
402 409
403 410
404 - stompClient.connect({},function (frame) { 411 + stompClient.connect({}, function (frame) {
405 console.log("websock连接成功。。。。。。") 412 console.log("websock连接成功。。。。。。")
406 connectFlg = true; 413 connectFlg = true;
407 tryIndex = 1; 414 tryIndex = 1;
@@ -410,13 +417,13 @@ layui.extend({ @@ -410,13 +417,13 @@ layui.extend({
410 // console.log(e) 417 // console.log(e)
411 // }); 418 // });
412 //通过stompClient.subscribe订阅/topic/getResponse 目标(destination)发送的消息 419 //通过stompClient.subscribe订阅/topic/getResponse 目标(destination)发送的消息
413 - stompClient.subscribe('/alarmQuery/', function(respnose){ 420 + stompClient.subscribe('/alarmQuery/', function (respnose) {
414 var alarmArr = JSON.parse(respnose.body); 421 var alarmArr = JSON.parse(respnose.body);
415 var mp3Name = sessionStorage.getItem('mp3'); 422 var mp3Name = sessionStorage.getItem('mp3');
416 var audio = audioPlayer(`../src/style/mp3/${mp3Name}.mp3`) 423 var audio = audioPlayer(`../src/style/mp3/${mp3Name}.mp3`)
417 - $.each(alarmArr,function (i,v) { 424 + $.each(alarmArr, function (i, v) {
418 if (v.alarmContent) { 425 if (v.alarmContent) {
419 - (function(i) { 426 + (function (i) {
420 var alarmLevel = 'error'; 427 var alarmLevel = 'error';
421 var alarmType = 'alarm'; 428 var alarmType = 'alarm';
422 if (v.clearType && v.alarmLevel === '1') { 429 if (v.clearType && v.alarmLevel === '1') {
@@ -429,24 +436,24 @@ layui.extend({ @@ -429,24 +436,24 @@ layui.extend({
429 alarmLevel = 'success'; 436 alarmLevel = 'success';
430 alarmType = 'alarmHis' 437 alarmType = 'alarmHis'
431 } 438 }
432 - let isNotify = alarmByUser(v.alarmId,alarmType === 'alarm' ? 'b_alarm' : 'b_alarm_his'); 439 + let isNotify = alarmByUser(v.alarmId, alarmType === 'alarm' ? 'b_alarm' : 'b_alarm_his');
433 if (isNotify) { 440 if (isNotify) {
434 - setTimeout(function() { 441 + setTimeout(function () {
435 audio.playclip(); 442 audio.playclip();
436 new msgTips({ 443 new msgTips({
437 - dom:".right-bottom-tips", 444 + dom: ".right-bottom-tips",
438 title: "告警消息", 445 title: "告警消息",
439 - message:`<p style="line-height: 40px">${v.alarmContent}</p>`,  
440 - duration:10000,  
441 - space:10,  
442 - firstSpace:8,  
443 - limit:8,  
444 - margin:15,  
445 - direction:'right bottom',  
446 - timingFun:'ease',  
447 - width:'300px',  
448 - toastType:alarmLevel,  
449 - type:'click', 446 + message: `<p style="line-height: 40px">${v.alarmContent}</p>`,
  447 + duration: 10000,
  448 + space: 10,
  449 + firstSpace: 8,
  450 + limit: 8,
  451 + margin: 15,
  452 + direction: 'right bottom',
  453 + timingFun: 'ease',
  454 + width: '300px',
  455 + toastType: alarmLevel,
  456 + type: 'click',
450 action: function () { 457 action: function () {
451 if (alarmType === 'alarm') { 458 if (alarmType === 'alarm') {
452 location.hash = "/alarm/activewarning/alarmNo=" + v.alarmNo; 459 location.hash = "/alarm/activewarning/alarmNo=" + v.alarmNo;
@@ -462,24 +469,24 @@ layui.extend({ @@ -462,24 +469,24 @@ layui.extend({
462 }) 469 })
463 }); 470 });
464 // 弹框展示错误消息 471 // 弹框展示错误消息
465 - let showTips = function (content,title="提示", toastType = 'error', hash, delay = 1000, queryResult) { 472 + let showTips = function (content, title = "提示", toastType = 'error', hash, delay = 1000, queryResult) {
466 if (queryResult) { 473 if (queryResult) {
467 content = laytpl(content).render(queryResult); 474 content = laytpl(content).render(queryResult);
468 } 475 }
469 476
470 //判断是否为故障诊断的三种类型 477 //判断是否为故障诊断的三种类型
471 - if(toastType=='faultinfo'||toastType=='faultover'||toastType=='faultprogress'){  
472 - var imgUrl="";  
473 - if(toastType=='faultinfo'){  
474 - imgUrl="/src/style/img/fault.png"; 478 + if (toastType == 'faultinfo' || toastType == 'faultover' || toastType == 'faultprogress') {
  479 + var imgUrl = "";
  480 + if (toastType == 'faultinfo') {
  481 + imgUrl = "/src/style/img/fault.png";
475 } 482 }
476 483
477 - if(toastType=='faultover'){  
478 - imgUrl="/src/style/img/faultprogress.png"; 484 + if (toastType == 'faultover') {
  485 + imgUrl = "/src/style/img/faultprogress.png";
479 } 486 }
480 487
481 - if(toastType=='faultprogress'){  
482 - imgUrl="/src/style/img/faultover.png"; 488 + if (toastType == 'faultprogress') {
  489 + imgUrl = "/src/style/img/faultover.png";
483 } 490 }
484 setTimeout(function () { 491 setTimeout(function () {
485 new msgTips({ 492 new msgTips({
@@ -499,13 +506,13 @@ layui.extend({ @@ -499,13 +506,13 @@ layui.extend({
499 action: function () { 506 action: function () {
500 //if (hash) { 507 //if (hash) {
501 // location.hash = hash; 508 // location.hash = hash;
502 - location.hash = "/faultDiagnosis/list/faultNo="+content.split(",")[0].split(":")[1]; 509 + location.hash = "/faultDiagnosis/list/faultNo=" + content.split(",")[0].split(":")[1];
503 //} 510 //}
504 } 511 }
505 }) 512 })
506 513
507 }, delay); 514 }, delay);
508 - }else{ 515 + } else {
509 setTimeout(function () { 516 setTimeout(function () {
510 new msgTips({ 517 new msgTips({
511 dom: ".right-bottom-tips", 518 dom: ".right-bottom-tips",
@@ -523,10 +530,10 @@ layui.extend({ @@ -523,10 +530,10 @@ layui.extend({
523 type: 'click', 530 type: 'click',
524 action: function () { 531 action: function () {
525 if (hash) { 532 if (hash) {
526 - if(hash.toLowerCase().indexOf("http://")!=-1 && hash.toLowerCase().indexOf("https://")!=-1){ 533 + if (hash.toLowerCase().indexOf("http://") != -1 && hash.toLowerCase().indexOf("https://") != -1) {
527 location.hash = hash; 534 location.hash = hash;
528 - }else{  
529 - window.location.href=hash; 535 + } else {
  536 + window.location.href = hash;
530 } 537 }
531 } 538 }
532 } 539 }
@@ -538,7 +545,7 @@ layui.extend({ @@ -538,7 +545,7 @@ layui.extend({
538 545
539 // 订阅实时消息 546 // 订阅实时消息
540 stompClient.subscribe('/realTime/', function (respnose) { 547 stompClient.subscribe('/realTime/', function (respnose) {
541 - console.log('实时信息: '+ respnose); 548 + console.log('实时信息: ' + respnose);
542 var data = respnose.body; 549 var data = respnose.body;
543 if (data) { 550 if (data) {
544 var obj = JSON.parse(data); 551 var obj = JSON.parse(data);
@@ -548,7 +555,7 @@ layui.extend({ @@ -548,7 +555,7 @@ layui.extend({
548 555
549 // 订阅用户消息 556 // 订阅用户消息
550 stompClient.subscribe("/user/realTime/notifications/", function (respnose) { 557 stompClient.subscribe("/user/realTime/notifications/", function (respnose) {
551 - console.log('专属信息: '+ respnose); 558 + console.log('专属信息: ' + respnose);
552 var data = respnose.body; 559 var data = respnose.body;
553 if (data) { 560 if (data) {
554 var obj = JSON.parse(data); 561 var obj = JSON.parse(data);
@@ -559,11 +566,11 @@ layui.extend({ @@ -559,11 +566,11 @@ layui.extend({
559 view.exit(); 566 view.exit();
560 }); 567 });
561 } else { 568 } else {
562 - showTips(obj.content,obj.title, obj.msgType.toLowerCase(), obj.href, 1000, obj.queryResult);  
563 - if(typeof(obj.msgType)!="undefined"){ 569 + showTips(obj.content, obj.title, obj.msgType.toLowerCase(), obj.href, 1000, obj.queryResult);
  570 + if (typeof(obj.msgType) != "undefined") {
564 var str = '滑稽'; 571 var str = '滑稽';
565 - voiceList.forEach(item =>{  
566 - if(item.type_== obj.msgType){ 572 + voiceList.forEach(item => {
  573 + if (item.type_ == obj.msgType) {
567 str = item.voice_; 574 str = item.voice_;
568 } 575 }
569 }) 576 })
@@ -574,10 +581,10 @@ layui.extend({ @@ -574,10 +581,10 @@ layui.extend({
574 } 581 }
575 } 582 }
576 }); 583 });
577 - },function(e){ 584 + }, function (e) {
578 console.log(`(${tryIndex})链接失败,重试中....`) 585 console.log(`(${tryIndex})链接失败,重试中....`)
579 connectFlg = false; 586 connectFlg = false;
580 - if(location.hash.indexOf('#/user/login') == -1){ 587 + if (location.hash.indexOf('#/user/login') == -1) {
581 // 调用测试接口,出现过期则会跳转到登录页面 588 // 调用测试接口,出现过期则会跳转到登录页面
582 admin.req({ 589 admin.req({
583 url: domainName + "/api-web/common/test" 590 url: domainName + "/api-web/common/test"
@@ -595,7 +602,7 @@ layui.extend({ @@ -595,7 +602,7 @@ layui.extend({
595 } 602 }
596 603
597 //告警是否属于当前用户 604 //告警是否属于当前用户
598 - function alarmByUser(alarmId,tableName) { 605 + function alarmByUser(alarmId, tableName) {
599 let isNotify = false; 606 let isNotify = false;
600 $.ajax({ 607 $.ajax({
601 url: sessionStorage.getItem('domainName') + '/api-web/bAlarm/hasAlarmByUserName?access_token=' + localStorage.getItem("access_token") + '&alarmId=' + alarmId + '&tableName=' + tableName, 608 url: sessionStorage.getItem('domainName') + '/api-web/bAlarm/hasAlarmByUserName?access_token=' + localStorage.getItem("access_token") + '&alarmId=' + alarmId + '&tableName=' + tableName,
@@ -610,17 +617,17 @@ layui.extend({ @@ -610,17 +617,17 @@ layui.extend({
610 } 617 }
611 618
612 //音频播放 619 //音频播放
613 - function audioPlayer(url){ 620 + function audioPlayer(url) {
614 var audio = document.createElement('audio') 621 var audio = document.createElement('audio')
615 - if (audio.canPlayType){ 622 + if (audio.canPlayType) {
616 var element = document.createElement('source') 623 var element = document.createElement('source')
617 element.setAttribute('src', url) 624 element.setAttribute('src', url)
618 element.setAttribute('type', 'audio/mpeg') 625 element.setAttribute('type', 'audio/mpeg')
619 audio.appendChild(element) 626 audio.appendChild(element)
620 audio.load() 627 audio.load()
621 - audio.playclip=function(){ 628 + audio.playclip = function () {
622 audio.pause() 629 audio.pause()
623 - audio.currentTime=0 630 + audio.currentTime = 0
624 audio.play() 631 audio.play()
625 } 632 }
626 return audio 633 return audio
@@ -629,14 +636,14 @@ layui.extend({ @@ -629,14 +636,14 @@ layui.extend({
629 636
630 var tryFunc = function () { 637 var tryFunc = function () {
631 setTimeout(function () { 638 setTimeout(function () {
632 - if(!connectFlg){ 639 + if (!connectFlg) {
633 tryIndex++; 640 tryIndex++;
634 access_token = localStorage.getItem("access_token") 641 access_token = localStorage.getItem("access_token")
635 webSockState = false; 642 webSockState = false;
636 alarmWebSocket(); 643 alarmWebSocket();
637 //setTimeout(tryFunc(),3000); 644 //setTimeout(tryFunc(),3000);
638 } 645 }
639 - },tryIndex*3000); 646 + }, tryIndex * 3000);
640 } 647 }
641 tryFunc(); 648 tryFunc();
642 }) 649 })
@@ -647,8 +654,8 @@ layui.extend({ @@ -647,8 +654,8 @@ layui.extend({
647 }); 654 });
648 //解决刷新后中间出现404页面问题 655 //解决刷新后中间出现404页面问题
649 var show = location.search.substr(1).split("&")[0].split("=")[1]; 656 var show = location.search.substr(1).split("&")[0].split("=")[1];
650 - if(show == '1') window.history.pushState({} ,'' ,'#');  
651 - if(show != '0') location.hash = "/"; 657 + if (show == '1') window.history.pushState({}, '', '#');
  658 + if (show != '0') location.hash = "/";
652 }); 659 });
653 660
654 661
@@ -132,7 +132,7 @@ layui.define(['laytpl', 'layer'], function(exports){ @@ -132,7 +132,7 @@ layui.define(['laytpl', 'layer'], function(exports){
132 typeof success === 'function' && success(res); 132 typeof success === 'function' && success(res);
133 } 133 }
134 ,error: function(e, code){ 134 ,error: function(e, code){
135 - if(window.location.hash.indexOf('page/forward') != -1){ 135 + if(window.location.hash.indexOf('page/forward') != -1 || window.location.hash.indexOf('page/log') != -1){
136 return; 136 return;
137 } 137 }
138 if(e.status == '401'){ 138 if(e.status == '401'){
  1 +<!-- -->
  2 +<article class="page-container template">
  3 + <div class="page-panel">
  4 + <div class="main" id="text">
  5 + 加载中.....
  6 + </div>
  7 + </div>
  8 + <textarea id="line_param" style="display: none;">{{d}}</textarea>
  9 +</article>
  10 +
  11 +<script>
  12 + layui.use('pageLog', function (fn) {
  13 + var $ = layui.$;
  14 + var parm = $("#line_param").val();
  15 + if(parm.indexOf('{{d') != -1){
  16 + fn();
  17 + }else{
  18 + fn(JSON.parse(parm));
  19 + }
  20 + });
  21 +</script>