新增/编辑
success: function () {
//释放焦点,解决回车时无限弹出的问题
$(':focus').blur();
}
删除
//删除
layer.confirm('删除记录,确定吗?', {
icon: 0,
success: function () {
//释放焦点,解决回车时无限弹出的问题
$(':focus').blur();
//回车确定
this.enterEsc = function (event) {
if (event.keyCode === 13 || event.keyCode === 32) {
$(".layui-layer-btn0").click();
return false; //阻止系统默认回车事件
}else if(event.keyCode == 27){
$(".layui-layer-btn1").click();
return false;
}
};
$(document).on('keydown', this.enterEsc); //监听键盘事件
},
end:function(){
$(document).off('keydown',this.enterEsc); //解除键盘关闭事件
}
}, function() {
//执行
$.ajax({
url: '/garageInfo/deleteGarageInfoById',
type: 'post',
data: {id: row.garageId},
async: true,//true为异步,false为同步
success: function(data,status,xhr){
if(data.status == 0){//成功
$("#tb_Table").bootstrapTable('refresh');
}else if(data.status == -1){//失败
layer.alert(data.msg, {icon: 0});
}else{//异常
layer.alert("异常:" + xhr.responseText, {icon: 2});
}
},
error:function(xhr,status,error){
layer.alert("失败:" + xhr.responseText, {icon: 2});
}
});
//关闭弹窗
layer.closeAll();
}, function() {
});
完整新增/编辑/删除
//新增
$("#btn_Add").bind('click',function(){
layer.open({
type: 2,
skin: 'layui-layer-molv',
title: '新增',
shadeClose: true,
shade: 0.4,
maxmin: false,
//area: ['800px', '500px'],
area: ['800px', '600px'],
//area: ['900px', '600px'],
//area: ['900px', '650px'],
content: '/garageInfo/addGarageInfoHtml',
end: function () {
//子窗口向父窗体传参数(取消时不刷新)
var returnVal = $("#childReturnData").val();
if(returnVal == "save"){
$("#tb_Table").bootstrapTable('refresh');
}
//复位
$("#childReturnData").val("");
},
success: function () {
//释放焦点,解决回车时无限弹出的问题
$(':focus').blur();
}
});
});
//绑定列表中各按钮的事件
window.operateEvents = {
'click .modify': function(e,value,row,index){
//编辑
var id = row.garageId;
layer.open({
type: 2,
skin: 'layui-layer-molv',
title: '编辑',
shadeClose: true,
shade: 0.4,
maxmin: false,
//area: ['800px', '500px'],
area: ['800px', '600px'],
//area: ['900px', '600px'],
//area: ['900px', '650px'],
content: '/garageInfo/modifyGarageInfoHtml?id=' + id,
end: function () {
//子窗口向父窗体传参数(取消时不刷新)
var returnVal = $("#childReturnData").val();
if(returnVal == "save"){
$("#tb_Table").bootstrapTable('refresh');
}
//复位
$("#childReturnData").val("");
},
success: function () {
//释放焦点,解决回车时无限弹出的问题
$(':focus').blur();
}
});
},
'click .delete': function(e,value,row,index) {
//删除
layer.confirm('删除记录,确定吗?', {
icon: 0,
success: function () {
//释放焦点,解决回车时无限弹出的问题
$(':focus').blur();
//回车确定
this.enterEsc = function (event) {
if (event.keyCode === 13 || event.keyCode === 32) {
$(".layui-layer-btn0").click();
return false; //阻止系统默认回车事件
}else if(event.keyCode == 27){
$(".layui-layer-btn1").click();
return false;
}
};
$(document).on('keydown', this.enterEsc); //监听键盘事件
},
end:function(){
$(document).off('keydown',this.enterEsc); //解除键盘关闭事件
}
}, function() {
//执行
$.ajax({
url: '/garageInfo/deleteGarageInfoById',
type: 'post',
data: {id: row.garageId},
async: true,//true为异步,false为同步
success: function(data,status,xhr){
if(data.status == 0){//成功
$("#tb_Table").bootstrapTable('refresh');
}else if(data.status == -1){//失败
layer.alert(data.msg, {icon: 0});
}else{//异常
layer.alert("异常:" + xhr.responseText, {icon: 2});
}
},
error:function(xhr,status,error){
layer.alert("失败:" + xhr.responseText, {icon: 2});
}
});
//关闭弹窗
layer.closeAll();
}, function() {
});
}
};
手动抽取(其他按钮)(其他操作)
//手动抽取
$("#btn_ManualGenerate").bind('click',function(){
layer.confirm('手动抽取学员服务跟踪数据,确定吗?', {
icon: 0,
success: function () {
//释放焦点,解决回车时无限弹出的问题
$(':focus').blur();
//回车确定
this.enterEsc = function (event) {
if (event.keyCode === 13 || event.keyCode === 32) {
$(".layui-layer-btn0").click();
return false; //阻止系统默认回车事件
}else if(event.keyCode == 27){
$(".layui-layer-btn1").click();
return false;
}
};
$(document).on('keydown', this.enterEsc); //监听键盘事件
},
end:function(){
$(document).off('keydown',this.enterEsc); //解除键盘关闭事件
}
}, function() {
//执行
$.ajax({
url: '/studentService/manualGenerate',
type: 'post',
data: {},
async: true,//true为异步,false为同步
success: function(data) {
if(data != "success"){
layer.alert(data);
return;
}
$("#tb_Table").bootstrapTable('refresh');
}
});
//关闭弹窗
layer.closeAll();
}, function() {
});
});
|