$(function(){
//页面白底区块,设置最低高度
if($(".main-wrapper").length>0)
{
$(".main-wrapper").css("min-height",($(window).height()-100)+'px');
}
if($(".main-wrapper-inner").length>0)
{
$(".main-wrapper-inner").css("min-height",($(window).height()-0)+'px');
}
})
//编辑器中的弹框被遮挡了,得做个处理
function fixUeditorLayer()
{
setInterval(function(){
if($('#edui_fixedlayer').length>0)
{
var zindex = $('#edui_fixedlayer').css('z-index');
if(zindex<9000)
{
$('#edui_fixedlayer').css('z-index','9999');
}
}
if($('.edui-editor-toolbarbox').css('position')=='fixed'){
$('.edui-editor-toolbarbox').css('position','absolute');
}
},300);
}
//表单数据转json
$.fn.serializeJson=function(){
var serializeObj={};
var array=this.serializeArray();
// var str=this.serialize();
$(array).each(function(){ // 遍历数组的每个元素
if(serializeObj[this.name]){ // 判断对象中是否已经存在 name,如果存在name
if($.isArray(serializeObj[this.name])){
serializeObj[this.name].push(this.value); // 追加一个值 hobby : ['音乐','体育']
}else{
// 将元素变为 数组 ,hobby : ['音乐','体育']
serializeObj[this.name]=[serializeObj[this.name],this.value];
}
}else{
serializeObj[this.name]=this.value; // 如果元素name不存在,添加一个属性 name:value
}
});
return serializeObj;
};
//美化下拉选择框
$('select.form-select').each(function(){
if(!$(this).hasClass('original')){
dselect(this);
}
})
//删除操作
function delConfirm(url)
{
var url = url;
Swal.fire({
icon: "warning",
title: "确认删除吗?",
html: "
删除后无法恢复!
",
buttonsStyling: false,
showCancelButton: true,
confirmButtonColor: "#556ee6",
cancelButtonColor: '#d33',
width:'28em',
customClass: {
confirmButton: 'btn btn-success mt-2 me-2',
cancelButton: 'btn btn-danger mt-2',
content: 'tex'
},
confirmButtonText: '确定',
cancelButtonText: '取消',
allowOutsideClick: () => !Swal.isLoading(),
showLoaderOnConfirm: true,
preConfirm: () => {
return fetch(url,{method:'get',headers: {"Content-Type": "application/json"}}).then(response => {
return response.json();
}).then(result => {
if(result.error==0){
Swal.fire({
icon: "success",
title: result.msg,
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
}).then(function(oper) {
if (oper.isConfirmed) {
reLoad();
}
})
}else{
Swal.fire({
icon: "error",
title: result.msg,
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
})
}
})
}
}).then(function(result) {
if (result.isConfirmed) {
} else if (result.isDenied) {
//do nothing
}
})
}
//批量删除操作
function multiDelConfirm(url,ids)
{
if(ids.length==0)
{
Swal.fire({
icon: "warning",
title: '您没有选中任何记录',
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
})
return;
}
var url = url;
url = url.split("?");
var params = [];
if(url[1]!='')
{
params = url[1].split("&");
}
params[params.length]="ids="+ids.join(",");
var newUrl = url[0]+'?'+params.join("&");
Swal.fire({
icon: "warning",
title: "确认删除吗?",
html: "删除后无法恢复!
",
buttonsStyling: false,
showCancelButton: true,
confirmButtonColor: "#556ee6",
cancelButtonColor: '#d33',
width:'28em',
customClass: {
confirmButton: 'btn btn-success mt-2 me-2',
cancelButton: 'btn btn-danger mt-2',
content: 'tex'
},
confirmButtonText: '确定',
cancelButtonText: '取消',
allowOutsideClick: () => !Swal.isLoading(),
showLoaderOnConfirm: true,
preConfirm: () => {
return fetch(newUrl,{method:'get',headers: {"Content-Type": "application/json"}}).then(response => {
return response.json();
}).then(result => {
if(result.error==0){
Swal.fire({
icon: "success",
title: result.msg,
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
}).then(function(oper) {
if (oper.isConfirmed) {
reLoad();
}
})
}else{
Swal.fire({
icon: "error",
title: result.msg,
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
})
}
})
}
}).then(function(result) {
if (result.isConfirmed) {
} else if (result.isDenied) {
//do nothing
}
})
}
//批量操作
function multiOperate(url,ids)
{
if(ids.length==0)
{
Swal.fire({
icon: "warning",
title: '您没有选中任何记录',
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
})
return;
}
var url = url;
url = url.split("?");
var params = [];
if(url[1]!='')
{
params = url[1].split("&");
}
params[params.length]="ids="+ids.join(",");
var newUrl = url[0]+'?'+params.join("&");
Swal.fire({
icon: "warning",
title: "确认执行该操作吗?",
html: "执行后无法撤回!
",
buttonsStyling: false,
showCancelButton: true,
confirmButtonColor: "#556ee6",
cancelButtonColor: '#d33',
width:'28em',
customClass: {
confirmButton: 'btn btn-success mt-2 me-2',
cancelButton: 'btn btn-danger mt-2',
content: 'tex'
},
confirmButtonText: '确定',
cancelButtonText: '取消',
allowOutsideClick: () => !Swal.isLoading(),
showLoaderOnConfirm: true,
preConfirm: () => {
return fetch(newUrl,{method:'get',headers: {"Content-Type": "application/json"}}).then(response => {
return response.json();
}).then(result => {
if(result.error==0){
Swal.fire({
icon: "success",
title: result.msg,
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
}).then(function(oper) {
if (oper.isConfirmed) {
reLoad();
}
})
}else{
Swal.fire({
icon: "error",
title: result.msg,
width:'28em',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-primary mt-2'
}
})
}
})
}
}).then(function(result) {
if (result.isConfirmed) {
} else if (result.isDenied) {
//do nothing
}
})
}