<!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" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-lantern-edit" th:object="${sysRidingLantern}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">内容：</label>
                <div class="col-sm-8">
                    <input name="content" th:field="*{content}" class="form-control" type="text" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="startTime" th:value="${#dates.format(sysRidingLantern.startTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="endTime" th:value="${#dates.format(sysRidingLantern.endTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">公告人员：</label>
                <div class="col-sm-8">
                    <select title="请选择" id="userType" name="userType" class="form-control m-b selectpicker" th:with="type=${@dict.getType('sys_lantern_permission')}" multiple>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{userType}"></option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 默认为全部人员</span>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/lantern";

        $(document).ready(function () {
            var formArray = $('#form-lantern-edit').serializeArray();
            var formData = {};
            $(formArray ).each(function(index, obj){
                formData[obj.name] = obj.value;
            });
            console.log('form-lantern-edit',formData);
            $("#userType").selectpicker('val',formData.userType.split(','));
        })

        $("#form-lantern-edit").validate({
            focusCleanup: true,
            rules:{
                content:{
                    required:true
                },
                startTime:{
                    required:true
                },
                endTime:{
                    required:true
                }
            },
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-lantern-edit').serialize());
            }
        }

        $("input[name='startTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>
