maliciousIpLook.js 2.23 KB
$(function () {
    refreshTableRemove();
});

function refreshTableRemove() {
    $("#lookTable").table({
        url: contextPath + "maliciousIp/lookIps",
        dataType: 'json',
        striped: true,
        panelClass: "panel-success",
        loadFilter: function (data) {
            return defaultLoadFilter(data);
        },
        columns: [
        	{
                title: "",
                width:"50px",
                field: "ip",
                formatter: function (value, rowData, rowIndex) {
                	var div = $("<div>");
                    //复选框
                    var checkBox = $("<input name='checkType' type='checkbox' value='"+value+"'>").addClass("ckbox-default").appendTo(div);
                    return div;
                }
            },
            {
                title: "ip",
                width: "230px",
                field: "ip"
            },
            {
                title: "剩余时间(小时)",
                width: "100px",
                field: "ttl"
            }]
    });
}

function checkAllRemove(){
	$("#lookTable input[type='checkbox']").each(function(){
		if($("#checkAllRemove").is(':checked'))
			$(this).prop("checked", true);
		else
			$(this).prop("checked", false);
	});
}

function remove(){
	var listip = "";
	$("#lookTable input[type='checkbox']:checked").each(function(){
		listip += $(this).val() + "|";
	});
	if(listip.length == 0){
		return;
	}
	if(confirm("是否确定要移除如下ip:\r\n" + listip)){
		var params = {};
		params.ips = listip;
		$.ajax({
	        url: '/maliciousIp/removeIp',
	        type: 'POST',
	        data: params,
	        dataType: 'json',
	        success: function (data) {
	            if (!data || data.code != 200) {
	            	alert('系统异常:'+data.message);
	            }else{
	            	if(data.data.status == '0'){
	            		alert('移除成功!');
	            		$("#lookTable input[type='checkbox']:checked").each(function(){
	            			$(this).parent().parent().parent().remove();
	            		});
	            	}else{
	            		alert('移除失败:'+data.data.message);
	            	}
	            }
	        },
	        error: function (data) {
	        	alert('系统异常');
	        }
	    });
	}
}