<!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>
                            <label>推送标题：</label>
                            <input type="text" name="pushTitle"/>
                        </li>
                        <li>
                            <label>跳转类型：</label>
                            <select name="jumpType">
                                <option value="">全部</option>
                                <option th:each="target : ${@banner.getUpushType()}" th:value="${target.id}" th:text="${target.name}"></option>
                            </select>
                        </li>
                        <li>
                            <label>设备类型：</label>
                            <select name="pushRange">
                                <option value="">全部</option>
                                <option value="2">IOS</option>
                                <option value="3">Android</option>
                            </select>
                        </li>
                        <!--<li>
                            <label>用户类型：</label>
                            <select name="specifyType">
                                <option value="">全部</option>
                                <option value="2">全部用户</option>
                                <option value="1">指定用户</option>
                            </select>
                        </li>-->
                        <li>
                            <label>是否发送通知：</label>
                            <select name="isPush">
                                <option value="">全部</option>
                                <option value="2">不发送</option>
                                <option value="1">发送推送消息</option>
                            </select>
                        </li>
                        <!--<li>
                            <label>消息类型：</label>
                            <select name="messageType">
                                <option value="">全部</option>
                                <option value="2">系统消息</option>
                                <option value="1">会员消息</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="$.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="admin:upush:create">
                <i class="fa fa-plus"></i> 添加
            </a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var detailFlag = [[${@permission.hasPermi('admin:upush:detail')}]];

    var prefix = ctx + "admin/upush";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/create",
            detailUrl: prefix + "/detail/{id}",
            modalName: "推送",
            columns: [
                {
                    field: 'upushId',
                    title: 'ID'
                },
                {
                    field: 'pushTitle',
                    title: '推送标题'
                },
                {
                    field: 'jumpName',
                    title: '跳转类型'
                },
                {
                    field: 'jumpContent',
                    title: '跳转内容',
                    formatter: function(value, row, index) {
                        if (row.jumpContent != '') {
                            return row.jumpContent
                        } else {
                            return row.jumpValue
                        }
                    }
                },
                {
                    field: 'messageShowType',
                    title: '消息类型',
                    formatter: function(value, row, index) {
                        if (row.messageShowType == 2) {
                            return "普通文本"
                        }
                        if (row.messageShowType == 1) {
                            return "图文排版"
                        }
                    }
                },
                /*{
                    field: 'specifyType',
                    title: '用户类型',
                    formatter: function(value, row, index) {
                        if (row.specifyType == 2) {
                            return "全部用户"
                        }
                        if (row.specifyType == 1) {
                            return "指定手机号"
                        }
                    }
                },*/
                {
                    field: 'isPush',
                    title: '是否发通知',
                    formatter: function(value, row, index) {
                        if (row.isPush == 1) {
                            return "发送"
                        }
                        if (row.isPush == 2) {
                            return "不发送"
                        }
                    }
                },
                {
                    field: 'pushRange',
                    title: '设备类型',
                    formatter: function(value, row, index) {
                        if (row.pushRange == 1) {
                            return "ALL"
                        }
                        if (row.pushRange == 2) {
                            return "IOS"
                        }
                        if (row.pushRange == 3) {
                            return "Android"
                        }
                    }
                },
                {
                    field: 'pushedName',
                    title: '发送人'
                },
                {
                    field: 'createdAt',
                    title: '添加时间'
                },
                {
                    field: 'pushTime',
                    title: '推送时间'
                },
                {
                    field: '',
                    title: '推送结果',
                    formatter: function(value, row, index) {
                        var taskId = row.taskId;
                        var msgId = row.msgId;
                        var errorCode = row.errorCode;
                        return 'taskId：'+taskId+'<br>'+'msgId：'+msgId+'<br>'+'errorCode：'+errorCode;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.upushId + '\')"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
        };

        $.table.init(options);

    });
</script>
</body>
</html>