<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
  <meta name="decorator" content="base" />
  <meta charset="utf-8">
  <title>新增</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <style>
    .addForm .mark {
      color: #ff5151;
    }
    .edui-default .edui-editor {
      width: 100% !important;
    }
  </style>
</head>
<body>

<div class="layui-card mb-0" style="padding: 10px;">
  <div class="layui-form addForm layui-card-body over" lay-filter="add-form" id="addForm">
    <div class="layui-form-item">
      <label class="layui-form-label"><span class="mark">*</span>公告名称：</label>
      <div class="layui-input-block">
        <input type="text" id="title" name="title" lay-verify="required" class="layui-input" maxlength="30" value="${announcement.title}">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label"><span class="mark">*</span>通知内容：</label>
      <div class="layui-input-block" style="margin-bottom: 10px;min-height: 314px;">
        <script id="container" name="content" type="text/plain">
        </script>
      </div>
    </div>
    <input type="hidden" name="html" lay-verify="htmlRule">
    <input type="hidden" name="objType" lay-verify="xRule">

    <div class="layui-form-item layui-hide ">
      <input type="button" lay-submit lay-filter="btnSubmit" id="btnSubmit" value="确认">
    </div>
  </div>
</div>

<script type="text/javascript" src="${ctxPlugin}/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="${ctxPlugin}/lib/ueditor/1.4.3/ueditor.all.js"></script>
<script type="text/javascript" src="${ctxPlugin}/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    var $;

    function formData() {
        var arr = [];
        /*  $("input:checkbox[name='objTypes']:checked").each(function () {
              arr.push($(this).val());
          });*/
        /* var objType = arr.join(",");*///将数组合并成字符串
        var d = {
            /*  objType: objType,*/
            title: $("#title").val(),
            html: ue.getContent(),
            id: '${id}'
        };
        return d;
    }

    layui.use(['form','table'], function(){
        var form = layui.form;
        $ = layui.$;
        form.verify({
            htmlRule: function(val) {
                if (!ue.hasContents()) {
                    return "通知内容不能为空";
                }
            },
            /*  xRule: function(val){
                  if ($("input:checkbox[name='objTypes']:checked").size() <=0) {
                      return "请选择通知群体";
                  }
              }*/
        });

        (function UEEdit() {
            window.UEDITOR_CONFIG.UEDITOR_HOME_URL = '${ctxPlugin}/lib/ueditor/1.4.3/';
            //防止图片过宽
            ue = UE.getEditor('container', {
                serverUrl: '${ctxPlugin}/lib/ueditor/1.4.3/jsp/controller.jsp',
                toolbars: [['bold', 'italic', 'underline', 'fontborder', 'forecolor', 'backcolor',
                    'fontfamily', 'fontsize', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify',
                    'simpleupload', 'insertimage','fullscreen']],
                autoHeightEnabled: false,
                autoFloatEnabled: false,
                elementPathEnabled: false,
                initialFrameHeight: 260,
                catcherUrlPrefix: '${commonStaticImgPath}',
                zIndex: 1000
            });
            ue.ready(function () {
                ue.setContent('');
                $(this.container).click(function (e) {
                    e.stopPropagation();
                });
                // 解决悬浮问题
                if (UE.browser.ie && UE.browser.version <= 7) {
                    FixIe7Bug();
                }

                $.ajax({
                    url: '${ctx}/notification/show',
                    type: "post",
                    data: {id: '${id}'},
                    dataType: "json",
                    success: function (data) {
                        ue.setContent(data.html);
                    }
                });
            });
        })();

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