<!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 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "wsyy/quantum";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "时间段设置",
            columns: [
                {
                    field: 'wsyyQuantumId',
                    title: 'ID',
                },
                {
                    field: 'timeQuantum',
                    title: '时间段'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
            ]
        };
        $.table.init(options);
    });
    /* 调度任务状态显示 */
    function statusTools(row) {
        if (row.status == 1) {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="start(\'' + row.wsyyQuantumId + '\',\'' + 2 + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="start(\'' + row.wsyyQuantumId + '\',\'' + 1 + '\')"></i> ';
        }
    }

    /* 启用此时间段 */
    function start(id, status) {
        $.operate.post(prefix + "/changeStatus", {"wsyyQuantumId": id, "status": status});
    }
</script>
</body>
</html>