<!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="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>所属商户：</p>
                            <select id="merchantId" class="form-control" name="merchantId">
                                <option value="">------全部------</option>
                                <option th:each="post:${mts}"
                                        th:value="${post.merchantId}"
                                        th:text="${post.merchantName}"></option>
                            </select>
                        </li>
                        <li>
                            <p>文章标题：</p>
                            <input type="text" name="articleTitle"/>
                        </li>
                        <li>
                            <p>文章状态：</p>
                            <select name="articleStatus" th:with="type=${@dict.getType('cms_article_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <p>热点标志：</p>
                            <select name="hotFlag" th:with="type=${@dict.getType('cms_hot_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="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>
                            <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="resetPre()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="bussiness_cms:article:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <!--     <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
                    shiro:hasPermission="bussiness_cms:article:edit">
                     <i class="fa fa-edit"></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 comentFlag = [[${@permission.hasPermi('bussiness_cms:comment:list')}]];
    var editFlag = [[${@permission.hasPermi('bussiness_cms:article:edit')}]];
    var removeFlag = [[${@permission.hasPermi('bussiness_cms:article:remove')}]];
    var examineFlag = [[${@permission.hasPermi('bussiness_cms:article:examine')}]];
    var articleStatusDatas = [[${@dict.getType('cms_article_examine_statusall')}]];
    var copyFlagDatas = [[${@dict.getType('cms_copy_flag')}]];
    var hotFlagDatas = [[${@dict.getType('cms_hot_flag')}]];
    var commentFlagDatas = [[${@dict.getType('cms_comment_flag')}]];
    var topFlagDatas = [[${@dict.getType('cms_top_flag')}]];
    var prefix = ctx + "bussiness_cms/article";

    function resetPre() {
        $.form.reset();
        $("#merchantId").val($("#merchantId").val()).trigger("change");
    }

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "文章信息",
            sortName: "createTime",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            },
                {
                    field: 'articleId',
                    title: '文章ID'
                }, {
                    field: 'merchantName',
                    title: '所属商户',
                    formatter: function (value) {
                        if (!value)
                            return '系统商户';
                        return value;
                    }
                },
                {
                    field: 'articleTitle',
                    title: '文章标题'
                },
                {
                    field: 'articleAuthor',
                    title: '作者'
                },

                {
                    field: 'articleStatus',
                    title: '文章状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(articleStatusDatas, value);
                    }
                },
                {
                    field: 'materialUrl',
                    title: '封面',
                    formatter: function (value) {
                        if (value) {
                            return "<img src='"
                                + value
                                + "' style='height: 36px;' target='_blank' tile='点击查看' onclick='$.operate.alertPic(\""
                                + value
                                + "\")'></img>";
                        }
                    }
                },
                {
                    field: 'categoryName',
                    title: '文章栏目'
                },
                {
                    field: 'copyFlag',
                    title: '转载标志',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(copyFlagDatas, value);
                    }
                }, {
                    field: 'staticUrl',
                    title: '静态页面',
                    align: 'center',
                    width: "100px",
                    formatter: function (v, row) {
                        var url = prefix + "/detail/" + row.articleId;
                        return '<a  target="_blank" class="btn btn-success btn-xs" href="' + url + '" onclick="return beforePreView(this.href)"><i class="fa fa-eye"></i>查看</a>';
                    }
                },
                {
                    field: 'hotFlag',
                    title: '热点标志',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(hotFlagDatas, value);
                    }
                },
                {
                    field: 'commentFlag',
                    title: '开启评论',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(commentFlagDatas, value);
                    }
                },
                {
                    field: 'topFlag',
                    title: '置顶标志',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(topFlagDatas, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    visible: false
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true,
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.articleStatus != 1) {
                            actions.push('<a class="btn btn-primary btn-xs ' + examineFlag + '" href="javascript:void(0)" onclick="examine(\'' + row.articleId + '\')"><i class="fa fa-credit-card"></i>审核</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.articleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + comentFlag + '" href="javascript:void(0)" onclick="comentPage(\'' + row.articleId + '\')"><i class="fa fa-bars"></i>评论</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.articleId + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    var beforePreView = function (v) {
        if (v) {
            return true;
        }
        $.modal.alertWarning("页面不存在!");
        return false;
    }

    function comentPage(commentTid) {
        $.modal.openFull("评论列表", ctx + "/bussiness_cms/comment/comment_list?commentTid=" + commentTid);
    }

    function examine(articleId) {
        $.modal.open("文章信息审核", prefix + "/examine/" + articleId);
    }
</script>
</body>BBBB
</html>