<!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('企业微信门户首页banner图列表')" />
    <style>

        .tableImage_l{
            border-radius:2px;
            width: 73px;
            height: 32px;
        }
    </style>
</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="title"/>
                            </li>
                            <li class="select-time">
                                <p>创建时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </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>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addNew()" shiro:hasPermission="wxportal:banner:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="editBanner()" shiro:hasPermission="wxportal:banner:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="wxportal:banner:remove">
                    <i class="fa fa-remove"></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" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wxportal:banner:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wxportal:banner:remove')}]];
        var prefix = ctx + "wxportal/banner";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "企业微信门户首页banner图",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'bannerId',
                    title : 'id',
                    visible: false
                },

                {
                    field : 'title', 
                    title : '标题'
                },
                {
                    field : 'imgUrl',
                    title : 'banner图    ',
                    formatter: function(value, row, index) {
                        var str="";
                        if(ctx=="/"){
                            str = value;
                        }else{
                            str = ctx+value;
                        }
                        return $.table.imageView(str,390,730,"tableImage_l img-view");

                    }
                },
                {
                    field : 'contextUrl', 
                    title : '内容地址'
                },
                {
                    field : 'des', 
                    title : '内容摘要'
                },
                {
                    field : 'remark', 
                    title : '备注'
                },
                {
                    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="editBanner(\'' + row.bannerId + '\')"><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.bannerId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function addNew(){
            $.modal.openFull("添加" + $.table._option.modalName, $.operate.addUrl(0));

        }
        function editBanner(id){
            if($.common.isEmpty(id) && $.table._option.type == table_type.bootstrapTreeTable) {
                var row = $.bttTable.bootstrapTreeTable('getSelections')[0];
                if ($.common.isEmpty(row)) {
                    $.modal.alertWarning("请至少选择一条记录");
                    return;
                }
                var url = $.table._option.updateUrl.replace("{id}", row[$.table._option.uniqueId]);
                $.modal.openFull("修改" + $.table._option.modalName, url);
            } else {
                $.modal.openFull("修改" + $.table._option.modalName, $.operate.editUrl(id));
            }
        }
    </script>
</body>
</html>