var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		id : 'paging',
		l_column : [ {
			colkey : "reviewId",
			width : "50px",
			hide : true
		}, {
			colkey : "spendTime",
			name : "发布时间",
			/*renderData : function( rowindex ,data, rowdata, colkeyn) {
				return new Date(rowdata.spendTime).format("yyyy-MM-dd hh:mm:ss");
			}*/
		}, {
			colkey : "content",
			name : "内容",
			align:"left",
			width : "450px",
		}, {
			colkey : "anon",
			name : "是否匿名",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				if(rowdata.anon=='1'){
					return "是";
				}else{
					return "否";
				}
			}
		}, {
			colkey : "spendName",
			name : "评论人",
		}],
		jsonUrl : rootPath + '/article/review/find.shtml',
		checkbox : true,
		serNumber : false,
		checkValue:'reviewId'
	});


	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();// 初始化传参数
		grid.setOptions({
			data : searchParams
		});
	});

	$("#delBtn").click("click", function() {
		deleteReview();
	});

});

function deleteReview() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('确认删除当前评论？', function(index) {
		var _URL = rootPath + '/article/review/delete.shtml';
		var resp = CommnUtil.ajax(_URL, {
			ids : cbox.join(",")
		}, "json");
		layer.msg(resp.code,{icon: 5});
		if (resp.code == "01") {
			layer.msg(resp.msg,{icon: 1});
			grid.loadData();
		} else {
			layer.msg('删除失败',{icon: 5});
		}
	});
}

