{layout:default} 
{class:Shop.Admin.admin.Admin_group_menu}
<lbhead>
    <title><%=Tag("编辑菜单")%>-<%=Tag("权限组")%>-<%=Tag("管理权限")%>-<%=site.title%></title>
</lbhead>
<lbfile>
</lbfile>
<lbpath>
    <h3 class="text-themecolor m-b-0 m-t-0"><%=Tag("编辑菜单")%></h3>
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=MenuJump&pid=0"><%=Tag("管理首页")%></a></li>
        <li class="breadcrumb-item"><a href="Admin_Group.aspx"><%=Tag("权限组")%></a></li>
        <li class="breadcrumb-item"><%=Lang(group.Name) %></li>
        <li class="breadcrumb-item active"><%=Tag("编辑菜单")%></li>
    </ol>
</lbpath>
<lbbody>
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-12">
                        <%if (PageReturnMsg == ""){%>
                        <button class="btn btn-primary" onclick="$('input[name=\'id\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));"><i class="ti-check-box"></i> <%=Tag("全选")%></button>
                        <button class="btn btn-success" onclick="SaveMenu();"><i class="ti-check"></i> <%=Tag("保存")%></button>
                        <%}%>
                    </div>
                </div>
                <table class="table table-bordered m-t-20">
                    <%foreach (DB.LebiShop.Lebi_Menu p in models)
                    { %>
                    <thead>
                        <tr>
                            <th colspan="2">
                                <label class="custom-control custom-checkbox">
                                    <input type="checkbox" id="p2_<%=p.id %>" name="id" value="<%=p.id %>" class="custom-control-input" power="true" onclick="selectall(this,<%=p.id %>);" <%=Check(p.id)?"checked":"" %>>
                                    <span class="custom-control-label"><%=Tag(p.Name)%></span>
                                </label>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <%foreach (DB.LebiShop.Lebi_Menu p2 in GetMenu(p.id))
                        {
                        %>
                        <tr>
                            <td class="text-nowrap">
                                <label class="custom-control custom-checkbox">
                                    <input type="checkbox" id="p3_<%=p2.id %>" name="id" value="<%=p2.id %>" class="custom-control-input" p2_<%=p.id %>="true" power="true" onclick="selectall(this,<%=p2.id %>);" <%=Check(p2.id)?"checked":"" %>>
                                    <span class="custom-control-label"><%=Tag(p2.Name)%></span>
                                </label>
                            </td>
                            <td>
                                <div class="input-group">
                                    <%
                                    foreach (DB.LebiShop.Lebi_Menu p3 in GetMenu(p2.id)){
                                    %>
                                    <label class="custom-control custom-checkbox m-r-20">
                                        <input type="checkbox" id="p4_<%=p3.id %>" name="id" value="<%=p3.id %>" class="custom-control-input" p2_<%=p.id %>="true" p3_<%=p2.id %>="true" power="true" <%=Check(p3.id)?"checked":"" %>>
                                        <span class="custom-control-label"><%=Tag(p3.Name)%></span>
                                    </label>
                                    <%}%>
                                </div>
                            </td>
                        </tr>
                        <%}%>
                    </tbody>
                    <%} %>
                </table>
            </div>
        </div>
    </div>
    <script>
        function SaveMenu() {
            var postData = GetFormJsonData("power");
            var url = "<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=SaveMenu&gid=<%=group.id %>";
            RequestAjax(url, postData, function () { MsgBox(1, "<%=Tag("操作成功")%>", "javascript:window.close()")});
        }
        function selectall(obj,id){
            var flag=$(obj).is(":checked");
            $("input[" + $(obj).attr('id')+"='true']").each(function () {
                if(flag)
                    $(this).attr("checked", true);
                else
                    $(this).attr("checked", false);
                
            });
        }
    </script>
</lbbody>