mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 11:32:48 +08:00
feat: 开始全页面提交
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
window.pageType = 'index';
|
||||||
$(function () {
|
$(function () {
|
||||||
var options = {
|
var options = {
|
||||||
iniUrl: ua.url('ajax/initAdmin'), // 初始化接口
|
iniUrl: ua.url('ajax/initAdmin'), // 初始化接口
|
||||||
|
|||||||
@@ -53,7 +53,10 @@
|
|||||||
|
|
||||||
<div class="hr-line"></div>
|
<div class="hr-line"></div>
|
||||||
<div class="layui-form-item text-center">
|
<div class="layui-form-item text-center">
|
||||||
<button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
|
{notempty name='$Request.param.backTagId'}
|
||||||
|
<div class="layui-btn layui-btn-sm page-back-button" layuimini-content-href="{$Request.param.backTagId}" data-title="管理员管理" data-back="1">返回</div>
|
||||||
|
{/notempty}
|
||||||
|
<button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" data-back-href="{$Request.param.backTagId}" 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>
|
||||||
|
|
||||||
|
|||||||
@@ -69,14 +69,9 @@
|
|||||||
* @param isParent
|
* @param isParent
|
||||||
*/
|
*/
|
||||||
delete: function (tabId, isParent) {
|
delete: function (tabId, isParent) {
|
||||||
// todo 未知BUG,不知道是不是layui问题,必须先删除元素
|
ua.findIndexPage(function (window) {
|
||||||
$('.layuimini-tab .layui-tab-title .layui-unselect.layui-tab-bar').remove();
|
window.layui.element.tabDelete('layuiminiTab', tabId);
|
||||||
|
});
|
||||||
if (isParent === true) {
|
|
||||||
parent.layui.element.tabDelete('layuiminiTab', tabId);
|
|
||||||
} else {
|
|
||||||
element.tabDelete('layuiminiTab', tabId);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,21 +112,33 @@
|
|||||||
check: function (tabId, isIframe) {
|
check: function (tabId, isIframe) {
|
||||||
// 判断选项卡上是否有
|
// 判断选项卡上是否有
|
||||||
var checkTab = false;
|
var checkTab = false;
|
||||||
if (isIframe === undefined || isIframe === false) {
|
// if (isIframe === undefined || isIframe === false) {
|
||||||
$('.layui-tab-title li').each(function () {
|
// $('.layui-tab-title li').each(function () {
|
||||||
|
// var checkTabId = $(this).attr('lay-id');
|
||||||
|
// if (checkTabId != null && checkTabId === tabId) {
|
||||||
|
// checkTab = true;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// parent.layui.$('.layui-tab-title li').each(function () {
|
||||||
|
// var checkTabId = $(this).attr('lay-id');
|
||||||
|
// if (checkTabId != null && checkTabId === tabId) {
|
||||||
|
// checkTab = true;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
ua.findIndexPage(function (window) {
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
parent.layui.$('.layui-tab-title li').each(function () {
|
|
||||||
var checkTabId = $(this).attr('lay-id');
|
|
||||||
if (checkTabId != null && checkTabId === tabId) {
|
|
||||||
checkTab = true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
return checkTab;
|
return checkTab;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -245,14 +252,29 @@
|
|||||||
var tabId = $(this).attr('layuimini-content-href'),
|
var tabId = $(this).attr('layuimini-content-href'),
|
||||||
href = $(this).attr('layuimini-content-href'),
|
href = $(this).attr('layuimini-content-href'),
|
||||||
title = $(this).attr('data-title'),
|
title = $(this).attr('data-title'),
|
||||||
|
back = $(this).attr('data-back') || 0,
|
||||||
|
external = $(this).attr('data-external') || false,
|
||||||
target = $(this).attr('target');
|
target = $(this).attr('target');
|
||||||
|
|
||||||
|
if(back == 0){
|
||||||
|
if (href.indexOf("?") === -1) {
|
||||||
|
href += '?backTagId=' + ua.getCurrentPageId();
|
||||||
|
} else {
|
||||||
|
href += '&backTagId=' + ua.getCurrentPageId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
href = external ? href : ua.url(href);
|
||||||
|
tabId = href;
|
||||||
|
|
||||||
if (target === '_blank') {
|
if (target === '_blank') {
|
||||||
parent.layer.close(loading);
|
parent.layer.close(loading);
|
||||||
window.open(href, '_blank');
|
window.open(href, '_blank');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
miniTab.create({
|
miniTab.create({
|
||||||
tabId: tabId,
|
tabId: tabId,
|
||||||
@@ -264,6 +286,11 @@
|
|||||||
}
|
}
|
||||||
parent.layui.element.tabChange('layuiminiTab', tabId);
|
parent.layui.element.tabChange('layuiminiTab', tabId);
|
||||||
parent.layer.close(loading);
|
parent.layer.close(loading);
|
||||||
|
if(back == 1){
|
||||||
|
console.log(back);
|
||||||
|
|
||||||
|
miniTab.delete(ua.getCurrentPageId());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -409,7 +436,7 @@
|
|||||||
if (tabId === options.homeInfo.href || tabId === options.homeInfo.mb_href) return false;
|
if (tabId === options.homeInfo.href || tabId === options.homeInfo.mb_href) return false;
|
||||||
|
|
||||||
// 判断tab是否已存在
|
// 判断tab是否已存在
|
||||||
if($('.layuimini-tab .layui-tab-content [lay-id="'+tabId+'"]').length > 0) {
|
if ($('.layuimini-tab .layui-tab-content [lay-id="' + tabId + '"]').length > 0) {
|
||||||
element.tabChange('layuiminiTab', tabId);
|
element.tabChange('layuiminiTab', tabId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,28 +144,28 @@
|
|||||||
};
|
};
|
||||||
complete = complete || function () {
|
complete = complete || function () {
|
||||||
};
|
};
|
||||||
if(no){
|
if (no) {
|
||||||
var originalNo = no;
|
var originalNo = no;
|
||||||
no = function (res) {
|
no = function (res) {
|
||||||
originalNo(res);
|
originalNo(res);
|
||||||
complete();
|
complete();
|
||||||
}
|
};
|
||||||
}else{
|
} else {
|
||||||
no = function (res) {
|
no = function (res) {
|
||||||
var msg = res.msg == undefined ? '返回数据格式有误' : res.msg;
|
var msg = res.msg == undefined ? '返回数据格式有误' : res.msg;
|
||||||
admin.msg.error(msg);
|
admin.msg.error(msg);
|
||||||
complete();
|
complete();
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ex){
|
if (ex) {
|
||||||
var originalEx = ex;
|
var originalEx = ex;
|
||||||
ex = function (res) {
|
ex = function (res) {
|
||||||
originalEx(res);
|
originalEx(res);
|
||||||
complete();
|
complete();
|
||||||
}
|
};
|
||||||
}else{
|
} else {
|
||||||
ex = function (res) {
|
ex = function (res) {
|
||||||
complete();
|
complete();
|
||||||
};
|
};
|
||||||
@@ -524,7 +524,7 @@
|
|||||||
toolbarHtml += ' <button class="layui-btn layui-btn-sm layuimini-btn-primary" data-table-refresh="' + tableId + '"><i class="fa fa-refresh"></i> </button>\n';
|
toolbarHtml += ' <button class="layui-btn layui-btn-sm layuimini-btn-primary" data-table-refresh="' + tableId + '"><i class="fa fa-refresh"></i> </button>\n';
|
||||||
} else if (v === 'add') {
|
} else if (v === 'add') {
|
||||||
if (admin.checkAuth('add', elem)) {
|
if (admin.checkAuth('add', elem)) {
|
||||||
toolbarHtml += '<button class="layui-btn layui-btn-normal layui-btn-sm" data-open="' + init.addUrl + '" data-title="添加" data-full="' + init.formFullScreen + '"><i class="fa fa-plus"></i> 添加</button>\n';
|
toolbarHtml += '<button class="layui-btn layui-btn-normal layui-btn-sm" layuimini-content-href="' + init.addUrl + '" data-title="添加" data-full="' + init.formFullScreen + '"><i class="fa fa-plus"></i> 添加</button>\n';
|
||||||
}
|
}
|
||||||
} else if (v === 'delete') {
|
} else if (v === 'delete') {
|
||||||
if (admin.checkAuth('delete', elem)) {
|
if (admin.checkAuth('delete', elem)) {
|
||||||
@@ -1112,7 +1112,8 @@
|
|||||||
formatToolbar.method = '';
|
formatToolbar.method = '';
|
||||||
} else if (toolbar.method === 'blank') {
|
} else if (toolbar.method === 'blank') {
|
||||||
formatToolbar.method = ' href="' + formatToolbar.url + '" target="_blank" ';
|
formatToolbar.method = ' href="' + formatToolbar.url + '" target="_blank" ';
|
||||||
|
} else if (operat.method === 'tab') {
|
||||||
|
formatToolbar.method = ' layuimini-content-href="' + formatToolbar.url + '" data-title="' + formatToolbar.title + '"';
|
||||||
} else {
|
} else {
|
||||||
formatToolbar.method = formatToolbar.method !== '' ? 'data-request="' + formatToolbar.url + '" data-title="' + formatToolbar.title + '" ' : '';
|
formatToolbar.method = formatToolbar.method !== '' ? 'data-request="' + formatToolbar.url + '" data-title="' + formatToolbar.title + '" ' : '';
|
||||||
}
|
}
|
||||||
@@ -2261,39 +2262,7 @@
|
|||||||
window.open(admin.url($(this).attr('href')));
|
window.open(admin.url($(this).attr('href')));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
form: function (url, data, ok, no, ex, refreshTable, close, complete) {
|
|
||||||
if (refreshTable === undefined) {
|
|
||||||
refreshTable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ok){
|
|
||||||
var originalOk = ok;
|
|
||||||
ok = function (res) {
|
|
||||||
originalOk(res);
|
|
||||||
complete()
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
ok = function (res) {
|
|
||||||
res.msg = res.msg || '';
|
|
||||||
admin.msg.success(res.msg, function () {
|
|
||||||
if (close) {
|
|
||||||
admin.api.closeCurrentOpen({
|
|
||||||
refreshTable: refreshTable,
|
|
||||||
onClose: function () {
|
|
||||||
complete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
admin.request.post({
|
|
||||||
url: url,
|
|
||||||
data: data,
|
|
||||||
}, ok, no, ex, complete);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
closeCurrentOpen: function (option) {
|
closeCurrentOpen: function (option) {
|
||||||
option = option || {};
|
option = option || {};
|
||||||
option.refreshTable = option.refreshTable || false;
|
option.refreshTable = option.refreshTable || false;
|
||||||
@@ -2406,6 +2375,7 @@
|
|||||||
// 判断btn是否具备name和value属性,如果有,则加到表单数据里
|
// 判断btn是否具备name和value属性,如果有,则加到表单数据里
|
||||||
var btnName = $(btnElem).attr('name');
|
var btnName = $(btnElem).attr('name');
|
||||||
var btnValue = $(btnElem).attr('value');
|
var btnValue = $(btnElem).attr('value');
|
||||||
|
var backHref = $(btnElem).attr('data-back-href');
|
||||||
if (btnName !== undefined && btnValue !== undefined) {
|
if (btnName !== undefined && btnValue !== undefined) {
|
||||||
data.field[btnName] = btnValue;
|
data.field[btnName] = btnValue;
|
||||||
}
|
}
|
||||||
@@ -2422,7 +2392,48 @@
|
|||||||
complete = complete || function () {
|
complete = complete || function () {
|
||||||
$(form).removeClass('loading');
|
$(form).removeClass('loading');
|
||||||
};
|
};
|
||||||
admin.api.form(url, dataField, ok, no, ex, refresh, close, complete);
|
// admin.api.form(url, dataField, ok, no, ex, refresh, close, complete);
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
var originalOk = ok;
|
||||||
|
ok = function (res) {
|
||||||
|
originalOk(res);
|
||||||
|
complete();
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
ok = function (res) {
|
||||||
|
res.msg = res.msg || '';
|
||||||
|
admin.msg.success(res.msg, function () {
|
||||||
|
if (close) {
|
||||||
|
if (backHref) {
|
||||||
|
var backWindow = admin.findPageId(backHref);
|
||||||
|
console.log(backWindow);
|
||||||
|
console.log(option.refreshTable);
|
||||||
|
|
||||||
|
backWindow.layui.table.reloadData(option.refreshTable);
|
||||||
|
|
||||||
|
admin.findIndexPage(function (window) {
|
||||||
|
window.layui.element.tabDelete('layuiminiTab', backHref);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
admin.api.closeCurrentOpen({
|
||||||
|
refreshTable: refreshTable,
|
||||||
|
onClose: function () {
|
||||||
|
complete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
admin.request.post({
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
}, ok, no, ex, complete);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -3097,6 +3108,51 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return oldValue;
|
return oldValue;
|
||||||
|
},
|
||||||
|
isCurrentIndex() {
|
||||||
|
console.log(window.pageType);
|
||||||
|
|
||||||
|
if (window.pageType && window.pageType == 'index') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
findIndexPage(findCallback, missCallback) {
|
||||||
|
if (!findCallback) {
|
||||||
|
findCallback = function (w) { return w; };
|
||||||
|
}
|
||||||
|
if (!missCallback) {
|
||||||
|
missCallback = function (w) { return w; };
|
||||||
|
}
|
||||||
|
if (this.isCurrentIndex()) {
|
||||||
|
return findCallback(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
var parent = window.parent;
|
||||||
|
if (parent && parent != window) {
|
||||||
|
return parent.ua.findIndexPage(findCallback, missCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
return missCallback(null);
|
||||||
|
},
|
||||||
|
getCurrentPageId() {
|
||||||
|
// pageId就是路径加参数
|
||||||
|
var path = location.pathname;
|
||||||
|
var params = location.search;
|
||||||
|
return path + params;
|
||||||
|
},
|
||||||
|
findPageId(tabId) {
|
||||||
|
var iframeWindow;
|
||||||
|
this.findIndexPage(function(window){
|
||||||
|
window.layui.$('.layui-tab-title li').each(function () {
|
||||||
|
var checkTabId = $(this).attr('lay-id');
|
||||||
|
|
||||||
|
if (checkTabId != null && checkTabId === tabId) {
|
||||||
|
iframeWindow = $(this).find('iframe').contentWindow
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
return iframeWindow
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user