//批删
$('#del_all').click(function(){
var checkAll=$('input[name="abc"]:checked'); //获取全部的复选框
//alert(checkAll);
var length=checkAll.length; //计算长度
var arr=new Array(); //定义数组
var str=""; //定义字符串
//循环
$.each(checkAll,function(k,v){
//判断是否选中
if(checkAll[k].checked){
arr.push(checkAll.eq(k).attr('tid'));
}
//alert(arr);
})
//alert(arr);
//转化为字符串
str=arr.join(',');
//alert(str);
//ajax
var url="?r=admin/all"; //地址
$.get(url,{str:str},function(msg){
if(msg){
//alert(msg);
//window.location.reload(); //刷新页面
//节点删除
$.each(arr,function(k,v){
$('#tr_'+v).remove();
});
}
},'json');
});
//批删后台处理
public function actionAll()
{
//接值
$str=Yii::$app->request->get('str');
//删除
$res=Yii::$app->db->createCommand("delete from `admin` WHERE `admin_id` in ($str)")->execute();
if($res){
echo json_encode(1);
}else{
echo json_encode(0);
}
}
//全选/全不选
$("#quan").click(function(){
if($('input[type="checkbox"]').prop("checked") == true)
{
$('input[type="checkbox"]').prop("checked", false);
}else
{
$('input[type="checkbox"]').prop("checked", true);
}
});
//反选
$("#fan").click(function () {
$('input[type="checkbox"]').each(function () {
$(this).prop("checked", !$(this).prop("checked"));
});
});