<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('申请记录')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="record_form">
                    <input type="hidden" id="recordId" name="recordId" th:value="${intRecord.id}">
                </form>
            </div>
            <div class="col-sm-12">
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">

        var editFlag = [[${@permission.hasPermi('apply:record:edit')}]];
        var prefix = ctx + "apply/record";

        function submitHandler() {

        }

        $(function() {
            var options = {
                url: prefix + "/intDetailedList",
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                columns: [{
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },{
                    field: 'intName',
                    align: 'center',
                    title: '接口名称'
                },{
                    field: 'intCode',
                    align: 'center',
                    title: '接口编码'
                },{
                    field: 'strAt',
                    align: 'center',
                    title: '开始时间'
				},{
                    field: 'endAt',
                    align: 'center',
                    title: '结束时间'
				},{
                    field: 'secretKey',
                    align: 'center',
                    title: 'secret_key'
				},{
                    visible: editFlag !== 'hidden',
                    title: '状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                }]
            };
            $.table.init(options);
        });

        /* 状态显示 */
        function statusTools(row) {
            if (row.status === '0') {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
            }
        }

        /* 接口管理-停用 */
        function disable(id) {
            $.modal.confirm("确认要停用该接口吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
            })
        }

        /* 接口管理-启用 */
        function enable(id) {
            $.modal.confirm("确认要启用该接口吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
            })
        }

    </script>
</body>
</html>