<!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>场地Id：</label>
                            <input type="text" name="fieldId"/>
                        </li>
                        <li>
                            上线状态：<select name="isOnline" th:with="type=${@dict.getType('zhengzai_field_is_online')}">
                            <option value="-1">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            认领状态：<select name="claimStatus" th:with="type=${@dict.getType('zhengzai_field_claim_status')}">
                            <option value="-1">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"th:value="${dict.dictValue}"></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="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 dicFieldIsOnline = [[${@dict.getType('zhengzai_field_is_online')}]];
    var dicFieldClaimStatus = [[${@dict.getType('zhengzai_field_claim_status')}]];

    var detailFlag = [[${@permission.hasPermi('slime:field:detail')}]];

    var prefix = ctx + "slime/field";

    $(function () {
        var options = {
            url: prefix + "/list",
            detailUrl: prefix + "/details/{id}",
            sortName: "createdAt",
            sortOrder: "desc",
            modalName: "场地",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'fieldId',
                    title: '场地id'
                },
                {
                    field: 'name',
                    title: '场地名称'
                },
                {
                    field: 'isOnline',
                    title: '上线状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(dicFieldIsOnline, value);
                    }
                },
                {
                    field: 'claimStatus',
                    title: '认领状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(dicFieldClaimStatus, value);
                    }
                },
                {
                    field: 'createdAt',
                    title: '创建时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.common.sprintf("<span>%s</span>", null != value ? value.replace("T"," ").substring(0, 19) : value);
                    }
                },
                {
                    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.fieldId + '\')"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
        };

        $.table.init(options);

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