feat: 开始全页面提交

This commit is contained in:
augushong
2025-08-15 23:16:13 +08:00
parent 7b5a84bcc3
commit 578fa91d36
4 changed files with 151 additions and 64 deletions

View File

@@ -144,28 +144,28 @@
};
complete = complete || function () {
};
if(no){
if (no) {
var originalNo = no;
no = function (res) {
originalNo(res);
complete();
}
}else{
};
} else {
no = function (res) {
var msg = res.msg == undefined ? '返回数据格式有误' : res.msg;
admin.msg.error(msg);
complete();
return false;
}
};
}
if(ex){
if (ex) {
var originalEx = ex;
ex = function (res) {
originalEx(res);
complete();
}
}else{
};
} else {
ex = function (res) {
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';
} else if (v === 'add') {
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') {
if (admin.checkAuth('delete', elem)) {
@@ -1112,7 +1112,8 @@
formatToolbar.method = '';
} else if (toolbar.method === '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 {
formatToolbar.method = formatToolbar.method !== '' ? 'data-request="' + formatToolbar.url + '" data-title="' + formatToolbar.title + '" ' : '';
}
@@ -2261,39 +2262,7 @@
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) {
option = option || {};
option.refreshTable = option.refreshTable || false;
@@ -2406,6 +2375,7 @@
// 判断btn是否具备name和value属性如果有则加到表单数据里
var btnName = $(btnElem).attr('name');
var btnValue = $(btnElem).attr('value');
var backHref = $(btnElem).attr('data-back-href');
if (btnName !== undefined && btnValue !== undefined) {
data.field[btnName] = btnValue;
}
@@ -2422,7 +2392,48 @@
complete = complete || function () {
$(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;
});
@@ -3097,6 +3108,51 @@
}
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
}
};