批量删除

//批量删除
function deleteAll(url) {
    var ids = new Array();
    $("input[name='radio_name']").each(function () {
        var check = $(this).is(":checked");
        if (check) {
            ids.push($(this).val());
        }
    });
    if (ids.length <= 0) {
        layer.msg('请选择要删除的记录', {
            icon: 2,
            time: 1000
        });
        return;
    }
    var span = "<span style='color:red;font-size:16px;'>" + ids.length + "</span>";
    layer.confirm("确认删除选中的" + span + "条记录吗?", {
        btn: ['确认', '取消'] //按钮
    }, function () {
        var loadId = load();
        common.httpMobileJson({
            type: 'POST',
            url: url,
            data: {
                ids: ids.join(",")
            },
            success: function (data) {
                //token失效
                if (data.code == '101') {
                    clearCookieAndLogout();
                }
                if (data.code == '102') {
                    layer.msg(data.info, {
                        icon: 2,
                        time: 1000
                    }); //1是勾的图片,2是X的图标
                } else {
                    getDataPage(1);
                    layer.msg('删除成功', {
                        icon: 1,
                        time: 1000
                    });
                }
                $('#selectall_id').prop("checked", false);
                close(loadId);
            },
            error: function (e) {
                console.log("操作失败");
                close(loadId);
            }
        });
    }, function () {});
}

 

posted @ 2017-09-27 11:13  monkye  阅读(193)  评论(0编辑  收藏  举报