<%@ page language="java" contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fastboot" prefix="fb"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro"%>
<fb:ui src="base/main">

    <fb:property name="title">添加新菜单</fb:property>

    <fb:script type="text/javascript">
        <script>
            layui.use(['tool', 'form'],
                function () {
                    // 操作对象
                    var $ = layui.$, tool = layui.tool, form = layui.form;
                    // 监听提交
                    form.on('submit(go)', function (data) {
                        tool.submit('${base}/menu/submit', $("#inputForm").serializeArray());
                        return false;
                    });

                    $("#href").on("blur", function(){
                        let href =  $("#href").val();
                        if(href.trim().length == 0){
                            return;
                        }
                        $("#permission").val(href.replace("/",":"))
                    })
                });


        </script>

    </fb:script>

    <fb:layout>
        <form id="inputForm"  class="layui-form layui-form-pane" action="" lay-filter="inputForm">

            <input type="hidden" name="isMenu"  value="0">
            <div class="layui-form-item">
                <label class="layui-form-label">父级菜单 </label>
                <div class="layui-input-block">
                    <label class="layui-form-label">无</label>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">name </label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入名称" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">href </label>
                <div class="layui-input-block">
                    <input type="text" id="href"  name="href"  lay-verType="tips" autocomplete="off" placeholder="请输入href" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">权限标识 </label>
                <div class="layui-input-block">
                    <input type="text" id="permission" name="permission" lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="权限标识" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">icon </label>
                <div class="layui-input-block">
                    <input type="text" name="icon"  lay-verType="tips" autocomplete="off" placeholder="请输入icon" class="layui-input">

                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">排序 </label>
                <div class="layui-input-block">
                    <input type="text" name="sort"  value="${sort}"
                           lay-verify="number" lay-verType="tips" autocomplete="off" placeholder="请输入排序" class="layui-input">
                </div>
            </div>
            <button id="submit" lay-submit lay-filter="go" hidden="true" />
            <button id="reset" type="reset" hidden="true" />
        </form>

    </fb:layout>
</fb:ui>