<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="新增公告" bodyClass="white-bg" libs=["ueditor","bootstrapSelect"]/>
<div class="wrapper wrapper-content ibox-content">
<@f.form id="form-notice-add" class="form-horizontal">
        <div class="alert alert-dismissible callout callout-info animated bounceInDown">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <p><i class="icon fa fa-info"></i><strong>重要提示:</strong>如果选择发布公告,等级是<u>严重</u>才会在登陆页面Top提示,等级是<u>紧急</u>只在登陆之后Top提示,等级是<u>普通</u>则在Top提醒栏提示!</p>
        </div>
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>公告标题：</label>
                    <div class="col-sm-8">
                        <@f.input name="noticeTitle" placeholder="请输入公告标题" required=true/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>公告类型：</label>
                    <div class="col-sm-8">
                        <@f.select name="noticeType" dictType="sys_notice_type" required=true/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">提示标题：</label>
                    <div class="col-sm-8">
                        <@f.input name="noticeTipTitle" maxlength="100" placeholder="提示标题" required=true/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>等级：</label>
                    <div class="col-sm-8">
                        <@f.select name="noticeLevel" dictType="sys_notice_level" required=true/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>有效时长：</label>
                    <div class="col-sm-8">
                        <div class="time-label">
                            <input type="text" class="time-input" id="startTime" placeholder="发布时间" name="startTime" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss" required/>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <h4 class="form-header h4">公告内容</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <div class="col-sm-12">
<#--                        <input id="noticeContent" name="noticeContent" type="hidden">-->
<#--                        &lt;#&ndash;<div class="summernote"></div>&ndash;&gt;-->
<#--                        <script id="noticeContentUE" type="text/plain" style="width:100%;height:300px;"></script>-->
                        <@f.ueditor name="noticeContent"/>
                    </div>
                </div>
            </div>
        </div>
    </@f.form>
    <div class="hr-line-dashed"></div>
    <div class="row" id="_addTab">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="opt.form.submit()"><i class="fa fa-check"></i><@ctx.i18n text = "保存"/></button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="opt.modal.closeTab()"><i class="fa fa-reply-all"></i><@ctx.i18n text = "关闭"/></button>
        </div>
    </div>
</div>
<@footer>
    <script>
        var prefix = baseURL + "sys/notice";

        $("#form-notice-add").validate({
            onkeyup: false,
            rules:{
                startTime:{
                    required: true
                },
                endTime: {
                    required: true,
                    compareDate: "#startTime"
                }
            },
            messages: {
                "startTime":{
                    required: "开始时间不能为空"
                },
                "endTime":{
                    required: "结束时间不能为空",
                    compareDate: "结束日期选择错误!"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if (opt.validate.form()) {
                // var options = {
                //     id:'form-user-add',
                //     delete:['compName','deptName'], /*需要删除提交表单数据*/
                //     conversion:[ /*需要转数据*/
                //         {
                //             name:'deptIdList',
                //             value:'arr'
                //         }
                //     ]
                // };
                // var data = opt.form.dataUp(options);
                // var postIds = opt.form.selectSelects("_role");
                // var status = $("input[id='status']").is(':checked') == true ? 0 :1;
                // data.push({"name": "status", "value": status});
                // data.push({"name": "roleIdList", "value": postIds});
                //$("#noticeContent").val(UE.getEditor('noticeContentUE').getAllHtml());
                //console.log(UE.getEditor('noticeContentUE').getContent());
                opt.operate.saveTab(prefix + "/add", $('#form-notice-add').serialize());
            }
        }
    </script>
</@footer>
</@pageTheme>