后台UI完善,体验优化

前端用户中心功能初始化
This commit is contained in:
2020-04-09 17:03:56 +08:00
parent 9810b08993
commit e1d3af1941
55 changed files with 780 additions and 3233 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -9,8 +9,21 @@ define(['jquery', 'layer', 'message'], function ($, layer) {
form.api.bindevent($("form[role=form]"));
})
}
sent.api.bindGet(); //绑定get请求
sent.api.bindPost(); //绑定post请求
sent.api.bindButtonAction(); //绑定元素get/post请求操作
//全选的实现
$(".check-all").click(function() {
$(this).parents('table').find('tbody td input[type=checkbox]').prop("checked", this.checked);
});
$("table tbody td input[type=checkbox]").click(function() {
var checked = true;
$("table tbody td input[type=checkbox]").each(function(i) {
if (!this.checked) {
checked = false;
}
});
$(".check-all").prop("checked", checked);
});
},
msg: function (text, type) {
text = (type == 'success') ? text + ' 页面即将自动跳转~' : text;
@@ -202,6 +215,11 @@ define(['jquery', 'layer', 'message'], function ($, layer) {
ret = sent.events.onAjaxResponse(ret);
if (ret.code === 1) {
sent.events.onAjaxSuccess(ret, success);
if (ret.url) {
setTimeout(function() {
location.href = ret.url;
}, 1500);
}
} else {
sent.events.onAjaxError(ret, error);
}
@@ -218,11 +236,45 @@ define(['jquery', 'layer', 'message'], function ($, layer) {
}, options);
return $.ajax(options);
},
bindGet: function(){
},
bindPost: function(){
bindButtonAction: function(){
if($('a.ajax-get, button.ajax-get, a.ajax-post, button.ajax-post').length > 0){
$('a.ajax-get, button.ajax-get, a.ajax-post, button.ajax-post').click(function(e){
e.preventDefault();
var target, type, form, query;
var nead_confirm = false;
if ($(this).hasClass('confirm')) {
if (!confirm('确认要执行该操作吗?')) {
return false;
}
}
if ($(this).hasClass('ajax-post')) {
type = "post";
form = $('.' + $(this).data('form'));
if ($(this).attr('hide-data') === 'true') { //无数据时也可以使用的功能
form = $('.hide-data');
query = form.serialize();
} else if (form.get(0) == undefined) {
return false;
} else if (form.get(0).nodeName == 'FORM') {
if ($(this).attr('url') !== undefined) {
target = $(this).attr('url');
} else {
target = form.get(0).action;
}
query = form.serialize();
} else if (form.get(0).nodeName == 'INPUT' || form.get(0).nodeName == 'SELECT' || form.get(0).nodeName == 'TEXTAREA') {
query = form.serialize();
} else {
query = form.find('input,select,textarea').serialize();
}
}else{
type = "get";
}
if ((target = $(this).attr('href')) || (target = $(this).attr('url'))) {
sent.api.ajax({url: target, type: type, data: query})
}
})
}
}
},
utils: {