<!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('文章分类列表')" />
</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>
                                <input type="text" name="categoryName"/>
                            </li>
                            <li>
                                <p>状态：</p>
                                <select name="categoryStatus" th:with="type=${@dict.getType('sms_use_state')}">
                                    <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="$.treeTable.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>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="bussiness_cms:category:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="bussiness_cms:category:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-tree-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var addFlag = [[${@permission.hasPermi('bussiness_cms:category:add')}]];
        var editFlag = [[${@permission.hasPermi('bussiness_cms:category:edit')}]];
        var removeFlag = [[${@permission.hasPermi('bussiness_cms:category:remove')}]];
        var categoryStatusDatas = [[${@dict.getType('sms_use_state')}]];
        var prefix = ctx + "bussiness_cms/category";

        $(function() {
            var options = {
                code: "categoryId",
                parentCode: "categoryParentId",
                expandColumn: "1",
                uniqueId: "categoryId",
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove/{id}",
                exportUrl: prefix + "/export",
                modalName: "文章分类",
                columns: [{
                    field: 'selectItem', 
                    radio: true
                },
                {
                    field : 'categoryName', 
                    title : '分类名称',
                    align: 'left'
                },
                {
                    field : 'categoryDescription', 
                    title : '分类描述',
                    align: 'left'
                },
                {
                    field : 'createTime', 
                    title : '创建时间',
                    align: 'left'
                },
                {
                    field : 'updateTime', 
                    title : '更新时间',
                    align: 'left'
                },
                {
                    field : 'updateBy', 
                    title : '更新人',
                    align: 'left'
                },
                {
                    field : 'categoryStatus', 
                    title : '状态',
                    align: 'left',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(categoryStatusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    align: 'left',
                    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.categoryId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info  btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.categoryId + '\')"><i class="fa fa-plus"></i>新增</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.categoryId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.treeTable.init(options);
        });
    </script>
</body>
</html>