@page
@model Waste.Web.Entry.Pages.Menu.MenuEditModel
@{
   var menu = Model.menu;
}
<div class="layui-card">
    <form class="form-horizontal layui-form layui-card-body">
        <div class="layui-form-item row">
            <label class="layui-form-label col-md-4" for="Name">名称</label>
            <div class="col-md-4">
                <input type="text" class="layui-input" id="Name" name="Name" value="@Model.menu.Name" placeholder="请输入菜单名称" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item row">
            <label class="layui-form-label col-md-4" for="ParentId">上级菜单</label>
            <div class="col-md-4">
                <select id="ParentId" name="ParentId" lay-search>
                    <option value="00000000-0000-0000-0000-000000000000">请选择上级菜单</option>
                    @foreach (var item in Model.list)
                    {
                        if (item.id == Model.menu.ParentId.ToString())
                        {
                            <option value="@item.id" selected>@item.text</option>
                        }
                        else
                        {
                            <option value="@item.id">@item.text</option>
                        }
                    }
                </select>
            </div>
        </div>
        <div class="layui-form-item row">
            <label class="layui-form-label col-md-4" for="Url">链接</label>
            <div class="col-md-4">
                <input type="text" class="layui-input"  id="UrlAddress" name="UrlAddress" value="@Model.menu.UrlAddress" placeholder="请输入链接地址" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item row">
            <label class="layui-form-label col-md-4" for="Icon">图标</label>
            <div class="col-md-4">
                <input type="text" class="layui-input" id="Icon" name="Icon" value="@Model.menu.Icon" placeholder="请输入图标" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item row">
            <label class="layui-form-label col-md-4" for="SortCode">排序</label>
            <div class="col-md-4">
                <input type="text" class="layui-input" id="SortCode" 
                       name="SortCode" value="@Model.menu.SortCode" placeholder="请输入排序编号" lay-verify="required" />
            </div>
        </div>
        <div class="text-center col-md-12">
            <button class="btn btn-primary btn-lg" lay-filter="submit" type="button" lay-submit>提交</button>
        </div>
    </form>
</div>
@section Scripts{ 
    <script type="text/javascript">
        layui.use(['form', 'common'], function () {
            var form = layui.form, common = layui.common;
            form.on("submit(submit)", function (data) {
                if ('@Model.menu.Id' != null) {
                data.field['id'] = '@Model.menu.Id';
            }
            common.ajax({
                    url: "/api/system/submitformmenu",
                    type: "post",
                    data: data.field
                });
            })
        });
    </script>
} 