<template>
    <section class="content">
        <div class="box box-primary">
            <div class="box-body">
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1 id="itemTitle"></h1>
                </section>
                <div id="toolbar">
                    <div class="col-sm-12">
                        <label for="roomErbanNo" class="qry_col control-label">房间ID:</label>
                        <div class="col-sm-1"><input type="text" class="form-control" name="roomErbanNo" id="roomErbanNo">
                        </div>
                        <label for="targetErbanNo" class="qry_col control-label">用户ID:</label>
                        <div class="col-sm-1"><input type="text" class="form-control" name="targetErbanNo"
                                id="targetErbanNo"></div>
                        <label for="operatorErbanNo" class="qry_col control-label">超管ID:</label>
                        <div class="col-sm-1"><input type="text" class="form-control" name="operatorErbanNo"
                                id="operatorErbanNo"></div>


                        <label for="operateType" class="qry_col control-label">操作类型:</label>
                        <div class="col-sm-2"><select name="operateType" id="operateType" class="col-sm-2 form-control"
                                data-btn-class="btn-warning">
                                <option value="" selected="selected">全部</option>
                                <option value="1">解除房间限制</option>
                                <option value="2">锁麦</option>
                                <option value="3">闭麦</option>
                                <option value="4">抱TA下麦</option>
                                <option value="5">踢出房间</option>
                                <option value="6">加入黑名单</option>
                                <option value="7">关闭房间</option>
                                <option value="8">隐藏房间</option>
                                <option value="9">关闭公屏消息</option>
                                <option value="10">开启公屏消息</option>
                                <option value="11">移除黑名单</option>
                            </select></div>

                        <label class="qry_col control-label">操作时间:</label>
                        <div class="col-sm-2"><input type="text" class="qry_col form-control" name="beginDate"
                                id="beginDate"></div><span class="qry_col">至</span>
                        <div class="col-sm-2"><input type="text" class="qry_col form-control" name="endDate" id="endDate">
                        </div>
                    </div>

                    <div class="col-sm-12">
                        <button id="btnSearch" class="btn btn-default">
                            <i class="glyphicon glyphicon-search"></i>查询
                        </button>
                    </div>

                </div>
                <!-- .content -->
                <div id="table"></div>
            </div>
        </div>
    </section>
</template>

<script>
import TableHelper from '@/utils/bootstrap-table-helper';

export default {
    name: "SuperAdminOperateRecordView",
    setup() {
        return {};
    },
    created() {
        this.$nextTick(function () {
            this.initData();
        });
    },
    methods: {
        initData() {
            $(function () {
                $('#table').bootstrapTable('destroy');
                $('#table').bootstrapTable({
                    columns: [
                        { field: 'roomUid', title: '房主UID', align: 'center', valign: 'middle', width: '5%' },
                        { field: 'roomErbanNo', title: '房间ID', align: 'center', valign: 'middle', width: '5%' },
                        { field: 'title', title: '房间标题', align: 'center', valign: 'middle', width: '10%' },
                        { field: 'targetErbanNo', title: '用户ID', align: 'center', valign: 'middle', width: '5%' },
                        { field: 'targetNick', title: '用户昵称', align: 'center', valign: 'middle', width: '10%' },
                        { field: 'operatorErbanNo', title: '操作超管ID', align: 'center', valign: 'middle', width: '5%' },
                        {
                            field: 'operateType', title: '操作', align: 'center', valign: 'middle', width: '10%',
                            formatter: function (val, row, index) {
                                switch (val) {
                                    case 1:
                                        return '解除房间限制';
                                    case 2:
                                        return '锁麦';
                                    case 3:
                                        return '闭麦';
                                    case 4:
                                        return '抱TA下麦';
                                    case 5:
                                        return '踢出房间';
                                    case 6:
                                        return '加入黑名单';
                                    case 7:
                                        return '关闭房间';
                                    case 8:
                                        return '隐藏房间';
                                    case 9:
                                        return '关闭公屏消息';
                                    case 10:
                                        return '开启公屏消息';
                                    case 11:
                                        return '移除黑名单';
                                    default:
                                        return '-';
                                }

                            }
                        },
                        {
                            field: 'createTime', title: '操作时间', align: 'center', valign: 'middle', width: '10%',
                            formatter: function (val, row, index) {
                                if (val) {
                                    var date = new Date(val);
                                    return date.format('yyyy-MM-dd hh:mm:ss');
                                } else {
                                    return '-';
                                }
                            }
                        }
                    ],
                    undefinedText: '-',
                    cache: false,
                    striped: true,
                    showRefresh: false,
                    pageSize: 20,
                    pagination: true,
                    pageList: [20, 50, 100, 200, 300, 500],
                    search: false,
                    sidePagination: "server", //表示服务端请求
                    queryParamsType: "undefined",
                    queryParams: function queryParams(params) {   //设置查询参数
                        var param = {
                            pageNum: params.pageNumber,
                            pageSize: params.pageSize,
                            roomErbanNo: $('#roomErbanNo').val(),
                            targetErbanNo: $('#targetErbanNo').val(),
                            operatorErbanNo: $('#operatorErbanNo').val(),
                            operateType: $('#operateType').val(),
                            beginDate: $('#beginDate').val(),
                            endDate: $('#endDate').val()
                        };
                        return param;
                    },
                    toolbar: '#toolbar',
                    url: '/admin/super/operate/record/list',
                    onLoadSuccess: function () {  //加载成功时执行
                        console.log("load success");
                    },
                    onLoadError: function () {  //加载失败时执行
                        console.log("load fail");
                    }
                });

                // 查询刷新
                $('#btnSearch').on('click', function () {
                    TableHelper.doRefresh('#table');
                });
                var picker1 = $("#beginDate").datetimepicker({
                    format: 'yyyy-mm-dd hh:ii:00',
                    autoclose: true,
                    todayBtn: true
                });
                var picker2 = $("#endDate").datetimepicker({
                    format: 'yyyy-mm-dd hh:ii:00',
                    autoclose: true,
                    todayBtn: true
                });
                picker1.on('changeDate', function () {
                    var date = $('#beginDate').datetimepicker('getDate');
                    picker2.datetimepicker('setStartDate', date);
                });
                picker2.on('changeDate', function () {
                    var date = $('#endDate').datetimepicker('getDate');
                    picker1.datetimepicker('setEndDate', date);
                });
            });
        }
    },

};
</script>

<style scoped>
.qry_col {
    float: left;
}
</style>