浏览代码

企业版 js加载导致 系统控制和控制系统加载问题

pengshengdong 2 月之前
父节点
当前提交
3716ec57c8

+ 12 - 3
dbsyncer-web/src/main/resources/static/js/common.js

@@ -7,7 +7,7 @@ var $initContainer = $(".contentDiv");
     $initContainer.css("min-height", $(window).height() - 125);
 
 // 监控定时器
-var timer;
+var timer=null,timer2=null;
 
 // ******************* 插件封装 ***************************
 // 全局提示框
@@ -196,8 +196,6 @@ $.fn.serializeJson = function () {
 
 // 全局加载页面
 function doLoader(url,route=0){
-    clearInterval(timer);
-
     // 加载页面
     const contents = document.querySelectorAll('.contentDiv');
     contents.forEach(function(content) {
@@ -215,6 +213,17 @@ function doLoader(url,route=0){
         $.loadingT(false);
     });
 }
+function timerLoad(url,route=1) {
+
+    const contentToShow = $('#initContainer' + route);
+    contentToShow.load($basePath + url, function (response, status, xhr) {
+        if (status != 'success') {
+            bootGrowl(response);
+        }
+        watermark();
+        $.loadingT(false);
+    });
+}
 
 // 异常请求
 function doRequest(action, data){

+ 0 - 1
dbsyncer-web/src/main/resources/static/js/index.js

@@ -49,7 +49,6 @@ $(function () {
         var route = $(this).data('route');
         // 加载页面
         doLoader($(this).attr("url"),route);
-
         // 加载页面
         const contents = document.querySelectorAll('.contentDiv');
         contents.forEach(function(content) {

+ 10 - 3
dbsyncer-web/src/main/resources/static/js/index/index.js

@@ -190,9 +190,16 @@ function doPost(url) {
 function createTimer($projectGroupSelect){
     doGetWithoutLoading("/monitor/getRefreshIntervalSeconds",{}, function (data) {
         if (data.success == true) {
-            timer = setInterval(function(){
-                backIndexPage($projectGroupSelect.selectpicker('val'));
-            }, data.resultValue * 1000);
+
+            if (timer2 == null) {
+                timer2 = setInterval(function(){
+                    // 加载页面
+                   var projectGroupId= $projectGroupSelect.selectpicker('val');
+                    projectGroupId = (typeof projectGroupId === 'string') ? projectGroupId : '';
+                    timerLoad("/index?projectGroupId="+ projectGroupId +"&refresh=" + new Date().getTime(),1);
+                }, data.resultValue * 1000);
+            }
+
         } else {
             bootGrowl(data.resultValue, "danger");
         }

+ 5 - 3
dbsyncer-web/src/main/resources/static/js/monitor/index.js

@@ -500,9 +500,11 @@ function createTimer() {
     showChartTable();
     doGetWithoutLoading("/monitor/getRefreshIntervalSeconds", {}, function (data) {
         if (data.success == true) {
-            timer = setInterval(function () {
-                showChartTable();
-            }, data.resultValue * 1000);
+            if (timer == null) {
+                timer = setInterval(function () {
+                    showChartTable();
+                }, data.resultValue * 1000);
+            }
         } else {
             bootGrowl(data.resultValue, "danger");
         }