<!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 :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/touchscreen/notice";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 185});
        queryHelpInfoList();
    });

    function queryHelpInfoList() {
        var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                sortName: "submitTime",
                sortOrder: "desc",
                modalName: "公示公告",
                columns: [{
                    checkbox: true
                }, {
                    field: 'tsNoticeId',
                    title: 'ID',
                    visible: false
                },
                    {
                        field: 'title',
                        title: '标题',
                        formatter: function (value, row, index) {
                            return formatStr(row.title);
                        }
                    },
                    {
                        field: 'description',
                        title: '描述',
                        formatter: function (value, row, index) {
                            return formatStr(row.description);
                        }
                    },
                    {
                        field: 'submitTime',
                        title: '上次修改时间',
                        sortable: true
                    },
                    {
                        title: '操作',
                        align:
                            'center',
                        formatter:
                            function (value, row, index) {
                                var actions = [];
                                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.tsNoticeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tsNoticeId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                                return actions.join('');
                            }
                    }
                ]
            }
        ;
        $.table.init(options);
    }

    function formatStr(val) {
        if (val > 20) {
            return val.substr(0, 20) + "...";
        } else {
            return val;
        }
    }
</script>
</body>
</html>