feat: 优化返回效果;

This commit is contained in:
augushong
2025-08-21 22:56:19 +08:00
parent 5eb4d787c7
commit 9493134c56
2 changed files with 28 additions and 14 deletions

View File

@@ -3,6 +3,9 @@
{{formList}} {{formList}}
<div class="hr-line"></div> <div class="hr-line"></div>
<div class="layui-form-item text-center"> <div class="layui-form-item text-center">
{notempty name='$Request.param.backTagId'}
<div class="layui-btn layui-btn-sm page-back-button" layuimini-content-href="{$Request.param.backTagId}" data-back="1">返回</div>
{/notempty}
<button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button> <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
<button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button> <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
</div> </div>

View File

@@ -1,10 +1,10 @@
(function () { (function () {
var element = layui.element; var element = layui.element;
$ = layui.$; $ = layui.$;
var miniTab = { var miniTab = {
renderOptions:{}, renderOptions: {},
/** /**
* 初始化tab * 初始化tab
* @param options * @param options
@@ -73,7 +73,7 @@
* @param isParent * @param isParent
*/ */
delete: function (tabId, isParent) { delete: function (tabId, isParent) {
ua.findIndexPage(function (window) { ua.findIndexPage(function (window) {
window.layui.element.tabDelete('layuiminiTab', tabId); window.layui.element.tabDelete('layuiminiTab', tabId);
}); });
}, },
@@ -131,13 +131,13 @@
// } // }
// }); // });
// } // }
ua.findIndexPage(function (window) { ua.findIndexPage(function (window) {
window.layui.$('.layui-tab-title li').each(function () { window.layui.$('.layui-tab-title li').each(function () {
var checkTabId = $(this).attr('lay-id'); var checkTabId = $(this).attr('lay-id');
if (checkTabId != null && checkTabId === tabId) { if (checkTabId != null && checkTabId === tabId) {
checkTab = true; checkTab = true;
} }
@@ -184,10 +184,10 @@
* @param menuList * @param menuList
*/ */
searchMenu: function (href, menuList) { searchMenu: function (href, menuList) {
if(!menuList){ if (!menuList) {
menuList = this.renderOptions.menuList menuList = this.renderOptions.menuList;
} }
var menu; var menu;
for (key in menuList) { for (key in menuList) {
var item = menuList[key]; var item = menuList[key];
@@ -264,7 +264,8 @@
external = $(this).attr('data-external') || false, external = $(this).attr('data-external') || false,
target = $(this).attr('target'); target = $(this).attr('target');
if(back == 0){
if (back == 0) {
if (href.indexOf("?") === -1) { if (href.indexOf("?") === -1) {
href += '?backTagId=' + ua.getCurrentPageId(); href += '?backTagId=' + ua.getCurrentPageId();
} else { } else {
@@ -282,8 +283,18 @@
if (tabId === null || tabId === undefined) tabId = new Date().getTime(); if (tabId === null || tabId === undefined) tabId = new Date().getTime();
var checkTab = miniTab.check(tabId, true); var checkTab = miniTab.check(tabId, true);
if (!checkTab) { if (!checkTab) {
if (!title) {
title = tabId;
ua.findIndexPage(function (window) {
var menu = window.miniTab.searchMenu(tabId);
if (menu) {
title = menu.title;
}
});
}
miniTab.create({ miniTab.create({
tabId: tabId, tabId: tabId,
href: href, href: href,
@@ -294,9 +305,9 @@
} }
parent.layui.element.tabChange('layuiminiTab', tabId); parent.layui.element.tabChange('layuiminiTab', tabId);
parent.layer.close(loading); parent.layer.close(loading);
if(back == 1){ if (back == 1) {
console.log(back); console.log(back);
miniTab.delete(ua.getCurrentPageId()); miniTab.delete(ua.getCurrentPageId());
} }
}); });
@@ -401,7 +412,7 @@
listenSwitch: function (options) { listenSwitch: function (options) {
options.filter = options.filter || null; options.filter = options.filter || null;
options.urlHashLocation = options.urlHashLocation || false; options.urlHashLocation = options.urlHashLocation || false;
options.listenSwichCallback = options.listenSwichCallback || function () { }; options.listenSwichCallback = options.listenSwichCallback || function () { };
element.on('tab(' + options.filter + ')', function (data) { element.on('tab(' + options.filter + ')', function (data) {
var tabId = $(this).attr('lay-id'); var tabId = $(this).attr('lay-id');