LayUI批量删除用户

需要加载LayUI的table模块 

var table = layui.table;
	  //监听表格复选框选择
	  table.on('checkbox(demo)', function(obj){
	    var checkStatus = table.checkStatus('idTest');
	     data=checkStatus.data;
	     ids=[];
	     data.forEach(function(n,i){
	          ids.push(n.id);
	        });
	        console.log(ids);  
	    $('.delete-many-btn').off("click").on("click",function(){
	        if(ids!=null){
	          layer.confirm('确定要删除选中的用户吗?', function(index){
	            $.ajax({
	               url:'/why123/user/deleteUsers?ids='+ids,
	               type:'post',
	               dataType:'json',
	               success:function(result){
	                if(result.y=="y"){           	
	                	layer.alert('删除成功', {
	                	  icon: 1,
	                	  skin: 'layer-ext-moon'
	                	});	
	                   window.location.reload();
	                }else{
	                 alert("删除出错");
	               }          
	               },
	               error:function(){
	                  alert("删除时发生了错误");
	               }          
	            });
	            
	          });
	          }      
	    }); 
	 
	  });

猜你喜欢

转载自blog.csdn.net/qq_39098505/article/details/81706486