Browse Source

新增选项卡是否刷新属性

RuoYi 4 years ago
parent
commit
9c92d8f87d

+ 4 - 0
ruoyi-admin/src/main/resources/static/ruoyi/index.js

@@ -249,6 +249,7 @@ $(function() {
         var dataUrl = $(this).attr('href'),
         dataIndex = $(this).data('index'),
         menuName = $.trim($(this).text()),
+        isRefresh = $(this).data("refresh"),
         flag = true;
 
         var $dataObj = $('a[href$="' + decodeURI(dataUrl) + '"]');
@@ -278,6 +279,9 @@ $(function() {
                         }
                     });
                 }
+                if (isRefresh) {
+                    refreshTab();
+                }
                 flag = false;
                 return false;
             }

+ 13 - 1
ruoyi-admin/src/main/resources/static/ruoyi/js/common.js

@@ -264,7 +264,7 @@ var closeItem = function(dataId){
 }
 
 /** 创建选项卡 */
-function createMenuItem(dataUrl, menuName) {
+function createMenuItem(dataUrl, menuName, isRefresh) {
     var panelUrl = window.frameElement.getAttribute('data-id');
     dataIndex = $.common.random(1, 100),
     flag = true;
@@ -285,6 +285,9 @@ function createMenuItem(dataUrl, menuName) {
                     }
                 });
             }
+            if (isRefresh) {
+            	refreshTab();
+            }
             flag = false;
             return false;
         }
@@ -310,6 +313,15 @@ function createMenuItem(dataUrl, menuName) {
     return false;
 }
 
+// 刷新iframe
+function refreshTab() {
+	var topWindow = $(window.parent.document);
+	var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
+	var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
+    var url = target.attr('src');
+	target.attr('src', url).ready();
+}
+
 // 滚动到指定选项卡
 function scrollToTab(element) {
     var topWindow = $(window.parent.document);

+ 2 - 2
ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js

@@ -891,8 +891,8 @@ var table = {
                 layer.full(index);
             },
             // 选卡页方式打开
-            openTab: function (title, url) {
-            	createMenuItem(url, title);
+            openTab: function (title, url, isRefresh) {
+            	createMenuItem(url, title, isRefresh);
             },
             // 选卡页同一页签打开
             parentTab: function (title, url) {