//批量删除学员信息
public function deleteMany() {
$id = input('post.'); //判断id是数组还是一个数值
if(is_array($id)){
foreach($id['data'] as $v){
$ids[] = $v['value'];
}
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$id;
}
$list=model("students")->where($where)->delete();
if($list==true) {
$this->success("成功删除{$list}条!");
}else{
$this->error('批量删除失败!');
}
}
<a href="javascript:;" id="del" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a>
{volist name='studentsList' id='vo'}
<th width="15"><input type="checkbox" class="all" ></th>
<th width="30">ID号</th>
<th width="30">姓名</th>
<td><input name='id[]' type="checkbox" value="{$vo.id}"></td>
<td>{$vo.id}</td>
<td>{$vo.edu_name}</td>
{/volist}
// 删除操作js
$('#del').click(function() {
if($(':checked').size() > 0) {
layer.confirm('确定要删除吗?', {
btn: ['确定','取消'], //按钮
shade: false //不显示遮罩
}, function(){
$.post("{:url('students/deleteMany')}",{data: $('form').serializeArray()}, function(data) {
layer.msg('恭喜,已批量删除', {icon: 1, time: 1000});
setTimeout(function() {
location.reload();
}, 1000);
});
}, function(){
layer.msg('取消了删除!', {time: 1000});
});
} else {
layer.alert('没有选择!');
}
});