<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/8/3
  Time: 14:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="webkit">
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <jsp:include page="../../common.jsp"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/page/umeditor/themes/default/css/umeditor.css">
    <script type="text/javascript" src="${ctx}/page/umeditor/third-party/template.min.js"></script>
    <script type="text/javascript" src="${ctx}/page/umeditor/umeditor.config.js"></script>
    <script type="text/javascript" src="${ctx}/page/umeditor/umeditor.min.js"></script>
    <script type="text/javascript" src="${ctx}/page/umeditor/lang/zh-cn/zh-cn.js"></script>
    <style>
        .layui-input, .layui-textarea {
            border-color: #606060;
        }

        .layui-form-select dl {
            z-index: 9999;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" style="width: 90%">
    <input name="id" value="${entity.id}" hidden/>

    <div class="layui-form-item">
        <label class="layui-form-label">页面code</label>
        <div class="layui-input-block">
            <input name="code" value="${entity.code}" placeholder="请输入页面Code" class="layui-input"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">页面名称</label>
        <div class="layui-input-block" style="margin-left:0px">
            <div class="layui-input-block">
                <input name="name" value="${entity.name}" placeholder="请输入页面名称" class="layui-input"/>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">简介内容</label>
        <div class="layui-input-block">
            <textarea name="content" id="content" placeholder="请输入内容"
                      class="layui-textarea">${entity.content}</textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="button" id="close" class="layui-btn layui-btn-primary">关闭</button>
        </div>
    </div>
</form>

<script>
    layui.use(['form', 'upload', 'element', 'layer'], function () {
        var form = layui.form;
        var layer = layui.layer;
        var element = layui.element;

        var um = UM.getEditor('content');
        um.setWidth("100%");

        element.init();

        $('#close').click(function () {
            parent.layer.closeAll();
        });

        //监听提交
        form.on('submit(formDemo)', function (data) {
            var index = layer.load(1, {shade: [0.1, '#000']});
            var params = data.field;
            params.content = um.getContent();
            debugger;
            $.ajax({
                url: '${ctx}/appGuide/saveOrUpdate',
                method: 'post',
                data: JSON.stringify(params),
                dataType: 'JSON',
                contentType: "application/json",
                success: function (res) {
                    layer.close(index);
                    if (res.code == 200) {
                        layer.alert(res.data, function () {
                            parent.location.reload();
                        })
                    } else {
                        layer.msg(res.message, {
                            icon: 5
                        });
                    }
                }
            })
            return false;
        });
    });
</script>
</body>
</html>
