<%--
  Created by IntelliJ IDEA.
  User: njc
  Date: 2022/5/9
  Time: 10:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript">
    /**
     * 显示博客标题
     * @param val
     * @param row
     * @returns {*}
     */
    function formatBlogTitle(val, row) {
        return val.title;
    }

    /**
     * 审核
     */
    function commentReview(state) {
        var selectedRows = $("#cr-dg").datagrid("getSelections");
        if (selectedRows.length === 0) {
            $.messager.alert("系统提示", "请至少选择一条要编辑的数据！");
            return;
        }
        var strIds = [];
        for (var i = 0; i < selectedRows.length; i++) {
            strIds.push(selectedRows[i].id);
        }
        var ids = strIds.join(",");
        $.messager.confirm("系统提示", "您确定要审核这<font color=red>" + selectedRows.length + "</font>条数据吗？", function (r) {
            if (r) {
                $.post("${pageContext.request.contextPath}/admin/comment/review.do", {
                    ids: ids,
                    state: state
                }, function (result) {
                    if (result.success) {
                        $.messager.alert("系统提示", "提交成功！");
                        $("#cr-dg").datagrid("reload");
                    } else {
                        $.messager.alert("系统提示", "数据删除失败！");
                    }
                }, "json");
            }
        });
    }
</script>
<table id="cr-dg" title="评论审核管理" class="easyui-datagrid" fitcolumns="true" rownumber="true" pagination="true"
       url="${pageContext.request.contextPath}/admin/comment/list.do?state=0" fit="true" toolbar="#cr-tb">
    <thead>
    <tr>
        <th field="cb" checkbox="true" align="center"></th>
        <th field="id" width="20" align="center">编号</th>
        <th field="blog" width="200" align="center" formatter="formatBlogTitle">博客标题</th>
        <th field="userIp" width="100" align="center">用户IP</th>
        <th field="content" width="200" align="center">评论内容</th>
        <th field="commentDate" width="50" align="center">评论日期</th>
    </tr>
    </thead>
</table>
<div id="cr-tb">
    <a href="javascript:commentReview(1)" class="easyui-linkbutton" iconcls="icon-ok" plain="true">审核通过</a>
    <a href="javascript:commentReview(2)" class="easyui-linkbutton" iconcls="icon-no" plain="true">审核不通过</a>
</div>
