<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户评论列表')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="comment_list">
                <div class="select-list">
                    <input type="hidden" name="commentTid" th:value="${commentTid}">
                    <li>
                        <p>评论类型：</p>
                        <select name="commentType" th:with="type=${@dict.getType('cms_comment_type')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <p>置顶标志：</p>
                        <select name="topFlag" th:with="type=${@dict.getType('cms_top_flag')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <p>评论状态：</p>
                        <select name="userStatus" th:with="type=${@dict.getType('cms_user_status')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <p>评论内容：</p>
                        <input type="text" name="commentContent"/>
                    </li>
                    <li>
                        <p>用户ID：</p>
                        <input type="text" name="userId"/>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
               shiro:hasPermission="bussiness_cms:comment:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="bussiness_cms:comment:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel('comment_list')"
               shiro:hasPermission="bussiness_cms:comment:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('bussiness_cms:comment:edit')}]];
    var removeFlag = [[${@permission.hasPermi('bussiness_cms:comment:remove')}]];
    var commentTypeDatas = [[${@dict.getType('cms_comment_type')}]];
    var userStatusDatas = [[${@dict.getType('cms_user_status')}]];
    var topFlagDatas = [[${@dict.getType('cms_top_flag')}]];
    var prefix = ctx + "bussiness_cms/comment";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "用户评论",
            sortName: "topFlag desc,createTime",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            }, {
                field: 'merchantName',
                title: '所属商户',
                formatter: function (value) {
                    if (!value)
                        return '系统商户';
                    return value;
                }
            },
                {
                    field: 'commentId',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'commentTid',
                    title: '目标ID(例如文章id)',
                    visible: false
                },
                {
                    field: 'commentType',
                    title: '评论类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(commentTypeDatas, value);
                    }
                },
                {
                    field: 'commentContent',
                    title: '评论内容'
                },
                {
                    field: 'commentReply',
                    title: '平台意见'
                },
                {
                    field: 'numOpposition',
                    title: '反对数'
                },
                {
                    field: 'numLike',
                    title: '点赞数'
                },
                {
                    field: 'userId',
                    title: '用户id'
                },
                {
                    field: 'userName',
                    title: '用户名称'
                },
                {
                    field: 'userAvatar',
                    title: '用户头像'
                },
                {
                    field: 'userContact',
                    title: '联系方式'
                },
                {
                    field: 'userIp',
                    title: '用户IP'
                },
                {
                    field: 'topFlag',
                    title: '置顶标志',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(topFlagDatas, value);
                    }
                },
                {
                    field: 'userStatus',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(userStatusDatas, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    visible: false
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true,
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.commentId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.commentId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>