diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/index.js b/ruoyi-admin/src/main/resources/static/ruoyi/index.js index b78cd822d..af2346db1 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/index.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/index.js @@ -294,8 +294,11 @@ $(function() { } }); } - if (isRefresh) { + if ($.common.equals(isRefresh, "0")) { + }else if($.common.equals(isRefresh, "1")){ refreshTab(); + }else{ + refreshTable(); } flag = false; return false; @@ -465,6 +468,22 @@ $(function() { target.attr('src', url).ready(); } + // 只刷新当前iframe下面的table和treetable,避免刷新整个tab页签造成检索条件或表单输入丢失 + function refreshTable() { + var currentId = $('.page-tabs-content').find('.active').attr('data-id'); + var topWindow = $(window.document); + //var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel'); + var $contentWindow = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0].contentWindow; + if($contentWindow.table == undefined){ + }else{ + if ($contentWindow.table.options.type == table_type.bootstrapTable) { + $contentWindow.$.table.refresh(); + } else if ($contentWindow.table.options.type == table_type.bootstrapTreeTable) { + $contentWindow.$.treeTable.refresh(); + } + } + } + // 页签全屏 function fullScreenTab() { var currentId = $('.page-tabs-content').find('.active').attr('data-id'); diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js index ee6830fc2..b9fffc40a 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js @@ -274,8 +274,12 @@ function createMenuItem(dataUrl, menuName, isRefresh) { } }); } - if (isRefresh) { - refreshTab(); + + if ($.common.equals(isRefresh, "0")) { + }else if($.common.equals(isRefresh, "1")){ + refreshTab(); + }else{ + refreshTable(); } flag = false; return false; @@ -311,6 +315,21 @@ function refreshTab() { target.attr('src', url).ready(); } +// 只刷新当前iframe下面的table和treetable,避免刷新整个tab页签造成检索条件或表单输入丢失 +function refreshTable() { + var topWindow = $(window.parent.document); + var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel'); + var $contentWindow = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0].contentWindow; + if($contentWindow.table == undefined){ + }else{ + if ($contentWindow.table.options.type == table_type.bootstrapTable) { + $contentWindow.$.table.refresh(); + } else if ($contentWindow.table.options.type == table_type.bootstrapTreeTable) { + $contentWindow.$.treeTable.refresh(); + } + } +} + // 滚动到指定选项卡 function scrollToTab(element) { var topWindow = $(window.parent.document); diff --git a/ruoyi-admin/src/main/resources/templates/index-topnav.html b/ruoyi-admin/src/main/resources/templates/index-topnav.html index b4e7c4bad..e48ba358e 100644 --- a/ruoyi-admin/src/main/resources/templates/index-topnav.html +++ b/ruoyi-admin/src/main/resources/templates/index-topnav.html @@ -50,7 +50,7 @@