<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增时段管理')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-session-add">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">分类：</label>
                <div class="col-sm-8">
                    <select name="siteType" class="form-control" th:with="type=${@dict.getType('site_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">时段：</label>
                <div class="col-sm-8">
                    <input name="session" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">价格：</label>
                <div class="col-sm-8">
                    <input name="price" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">场馆名称：</label>
                <div class="col-sm-8">
                    <select name="venueId" class="form-control">
                        <option th:each="post:${beilvSitesList}" th:value="${post.id}"
                                th:text="${post.venueName}"></option>
                    </select>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/session"
    $("#form-session-add").validate({
        focusCleanup: true,
        rules: {
            price:{
                required: true, // 必填
                digits: true, // 必须为整数
                min: 1 // 最小值为1，确保为正整数
            },
            sort: {
                digits: true
            },
            session: {
                isTimeRange: true
            },
        },
        messages: {
            price: {
                required: "价格不能为空",
                digits: "价格必须为整数",
                min: "价格必须大于0"
            }
        }
    });


    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-session-add').serialize());
        }
    }
</script>
</body>
</html>