<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AuthorizationForm.aspx.cs" Inherits="Medical.MSystem.SysUser.AuthorizationForm" %>

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/TreeTable/css/jquery.treeTable.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/TreeTable/jquery.treeTable.js" type="text/javascript"></script>
    <script src="../../js/myLib/helper.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
         <input id="item_hidden" type="hidden" runat="server" />
        <div id="Menu" class="pt-body">
            <table class="pt-tree-grid" id="treeGrid">
                <thead>
                    <tr>
                        <td style="width: 200px; padding-left: 20px;">
                            模块
                        </td>
                        <td style="width: 23px; text-align: center;">
                            <label id="checkAllOff" onclick="Authorization.CheckAllLine()" title="全选">&nbsp;</label>
                        </td>
                        <td>
                            权限
                        </td>
                    </tr>
                </thead>
                <tbody><%=GetMenuTreeTable() %></tbody>
            </table>
        </div>
        <div class="pt-padding" style="text-align:center">
            <asp:Button ID="Save" runat="server" onclick="btnSave_Click" style=" display:none" />
            <input type="button" id="btnImport" class="pt-button active" value="导入角色权限" />
            <input type="button" id="btnSave" class="pt-button active" value="保存" />
            <input type="button" class="pt-button active" onclick="top.OpenClose('Authorization_Form')" value="关闭" />
        </div>
    </form>
    <script>
        var Authorization = (function() {
            var CheckAllLinestatus = 0;
            function init() {
                FixedTableHeader("treeGrid", 400);
                $("#treeGrid").treeTable({
                    initialState: "expanded" //collapsed 收缩 expanded展开的
                });
                bindEvents();
            }
            //树表格复选框，点击子，把父也打勾
            function ckbValueObj(e) {
                var item_id = '';
                var arry = e.split('-');
                for (var i = 0; i < arry.length - 1; i++) {
                    item_id += arry[i] + '-';
                }
                item_id = item_id.substr(0, item_id.length - 1);
                if (item_id != "") {
                    $("#" + item_id).attr("checked", true);
                    ckbValueObj(item_id);
                }
            }
            function CheckAllLine() {
                if (CheckAllLinestatus == 0) {
                    CheckAllLinestatus = 1;
                    $("#checkAllOff").attr('title', '反选');
                    $("#checkAllOff").attr('id', 'checkAllOn');
                    $("#treeGrid :checkbox").attr("checked", true);
                    $('#treeGrid tr').find('td').addClass('selected');
                } else {
                    CheckAllLinestatus = 0;
                    $("#checkAllOn").attr('title', '全选');
                    $("#checkAllOn").attr('id', 'checkAllOff');
                    $("#treeGrid :checkbox").attr("checked", false);
                    $('#treeGrid tr').find('td').removeClass('selected');
                }
            }
            function bindEvents() {
                $("#btnSave").click(function() {
                    top.showConfirmMsg('注：确认要保存此操作吗？', function(r) {
                        if (r) {
                            var item = CheckboxValue();
                            $("#item_hidden").val(item);
                            document.getElementById("<%=Save.ClientID%>").click();
                        }
                    });
                });
            }
            init();
            return {
                CheckAllLine: CheckAllLine,
                ckbValueObj: ckbValueObj
            }
        })();
    </script>
</body>
</html>
