<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增通知公告')" />
    <th:block th:include="include :: select2-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-notice-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">通知标题：</label>
                <div class="col-sm-8">
                    <input name="noticeTitle" class="form-control" type="text" required>
                </div>
            </div>
            <input type="hidden" id="noticeType" name="noticeType">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">通知类型：</label>
                <div class="col-sm-8">
                    <select id="noticeType1" class="form-control select2-multiple">
                        <option value="1" selected>系统通知</option>
                        <option value="2">个人通知</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">个人id：</label>
                <div class="col-sm-8">
                    <input name="userId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">note:</label>
                <div class="col-sm-8">
                    <input name="userId" class="form-control" type="text" value="当类型为个人通知的时候个人id必填" disabled="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">通知内容：</label>
                <div class="col-sm-8">
                    <script id="editor" name="noticeContent" type="text/plain" style="height: 300px;"></script>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: ueditor-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "business/notice"
        $("#form-notice-add").validate({
            focusCleanup: true
        });

        var ue = UE.getEditor('editor');
        function getContentTxt() {
            return UE.getEditor('editor').getContentTxt();
        }

        // $('#noticeType1').on('select2:select', function (e) {
        //     var a=$('#noticeType1').val();
        //     $("#noticeType").val(a);
        // });
        //
        // $('#noticeType1').on('change', function (e) {
        //     var a=$('#noticeType1').val();
        //     $("#noticeType").val(a);
        // });

        function submitHandler() {
            if ($.validate.form()) {
                var a=$('#noticeType1').val();
                $("#noticeType").val(a);
                var text = getContentTxt();
                if (text == '' || text.length == 0) {
                    $.modal.alertWarning("请输入通知内容！");
                    return;
                }
                $.operate.save(prefix + "/add", $('#form-notice-add').serialize());
            }
        }
    </script>
</body>
</html>