<%@ Page Language="c#" Inherits="Web.Wpdcc.quickAccredit" CodeBehind="quickAccredit.aspx.cs" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>系统权限管理</title>
    <!--#include file = "../Css/head.htm" -->
    <style>
        /*解决授权页面IE浏览器下页面滚动条失效问题*/
        html {
            overflow: auto;
        }
    </style>
      <script type="text/javascript" src="../js/TreeView2.js"></script>

    <script type="text/javascript" language="javascript">
        var TURLParams = new Object();
        var TNodeParams = new Object();
        var length;

        function BindValue(returnStr, menuId) {
            TURLParams[TNodeParams[menuId]] = returnStr;
        }

        function setPrivilege(menuId, userId) {
            var pParams = TURLParams[TNodeParams[menuId]];
            showModalDialog("setPrivilege.aspx?menuId=" + menuId + "&pSet=" + pParams + "&userId" + userId, window, "dialogWidth:500px;dialogHeight:300px;help:no;scroll:yes;status:no;resizable:yes");
            //		    $.fancybox({
            //		                    'type': 'iframe',
            //		                    'width'		: 500,
            //		                    'height'	: 250,
            //		                    'hideOnOverlayClick': false,
            //		                    'transitionIn'		: 'elastic',
            //		                    'transitionOut'		: 'elastic',
            //		                    'padding': '0',
            //		                    'href': 'setPrivilege.aspx?menuId=' + menuId + '&pSet=' + pParams + '&userId=' + userId + ''
            //		                    //'onClosed': function () { window.location.href = 'quickAccredit.aspx?pkId='+userId+'&name=<%#Eval("userName") %>'; }
            //		                });

        }

        function closeWindow() {
            window.close();
            //accredit.submit();
        }
        function initValues() {
            var AParams = document.all.Hidden1.value.split('|');
            var BParams = document.all.Hidden2.value.split(';');
            for (i = 0 ; i < AParams.length ; i++) {
                TNodeParams[AParams[i]] = i;
                TURLParams[i] = BParams[i];
            }
            length = AParams.length;
        }
        function changeValue(id, menuId, val) {
            var d = id.indexOf(menuId);
            if (id.substring(0, d) == "canAuditContribute") {
                var itemAdd = document.getElementById("canAdd" + menuId);
                var itemDelete = document.getElementById("canDelete" + menuId);
                var itemRecommand = document.getElementById("canSetRecommand" + menuId);
                var itemTop = document.getElementById("canSetTop" + menuId);
                if (val == "1") {
                    itemAdd.selectedIndex = 0;
                    TURLParams["canAdd" + menuId] = 0;
                    itemAdd.disabled = true;

                    itemDelete.selectedIndex = 0;
                    TURLParams["canDelete" + menuId] = 0;
                    itemDelete.disabled = true;

                    itemRecommand.selectedIndex = 1;
                    TURLParams["canSetRecommand" + menuId] = 1
                    itemRecommand.disabled = false;

                    itemTop.selectedIndex = 1;
                    TURLParams["canSetTop" + menuId] = 1
                    itemTop.disabled = false;
                }
                else if (val == "0") {
                    itemRecommand.selectedIndex = 0;
                    TURLParams["canSetRecommand" + menuId] = 0;
                    itemRecommand.disabled = true;

                    itemTop.selectedIndex = 0;
                    TURLParams["canSetTop" + menuId] = 0;
                    itemTop.disabled = true;

                    itemAdd.selectedIndex = 1;
                    TURLParams["canAdd" + menuId] = 1
                    itemAdd.disabled = false;

                    itemDelete.selectedIndex = 1;
                    TURLParams["canDelete" + menuId] = 1
                    itemDelete.disabled = false;
                }
            }
            TURLParams[id] = val;
        }
        function setValues() {
            var str = '';
            for (i = 0; i < length; i++) {
                str = str + TURLParams[i] + ";"
            }
            document.all.Hidden2.value = str;
            //alert(str);
            return false;
        }

        //关闭弹出层
        function delayClose() {
            //alert("恭喜您，权限分配成功！");
            parent.$.fancybox.close();
        }
    </script>

    <script type="text/javascript" language="javascript">
        //<!--
        function getNodeIndex1(node) {
            var strIndex = "";
            if (node != null) {
                if (node.getAttribute("sibIndex") == null) {
                    if (node.parentElement == null) {
                        return null;
                    }
                    var col = node.parentElement.children.tags("treenode");
                    var i = 0;
                    while (col[i] != node) i++;
                    node.setAttribute("sibIndex", i);
                }
                strIndex = node.getAttribute("sibIndex");
                while (node.getAttribute("parentElement") && node.getAttribute("parentElement").tagName.toLowerCase() == "treenode") {
                    node = node.getAttribute("parentElement");
                    if (node.getAttribute("sibIndex") == null)
                        return null;
                    strIndex = node.getAttribute("sibIndex") + "." + strIndex;
                }
            }
            return strIndex;
        }

        //初始化选中节点
        function initchecknode() {
            var node = treeMenu.getTreeNode("1");
            node.setAttribute("Checked", "false");
            setcheck(node, "false");
            treeMenu.queueEvent('oncheck', getNodeIndex1(node));
            // FindCheckedFromNode(treeMenu);
        }
        //oncheck事件
        function tree_oncheck(tree) {

            var node = treeMenu.getTreeNode(treeMenu.clickedNodeIndex);
            var Pchecked = node.getAttribute("Checked");
            alert(node.getAttribute("Text") + "=" + Pchecked);
            setcheck(node, Pchecked);
            node.setAttribute("Checked", Pchecked);
            treeMenu.queueEvent('oncheck', treeMenu.clickedNodeIndex);

        }
        //设置子节点选中
        function setcheck(node, Pc) {

            var i;
            var ChildNode = new Array();
            ChildNode = node.getChildren();

            if (parseInt(ChildNode.length) == 0)
                return;
            else {
                for (i = 0; i < ChildNode.length; i++) {
                    var cNode;
                    cNode = ChildNode[i];
                    if (parseInt(cNode.getChildren().length) != 0) {
                        setcheck(cNode, Pc);
                    }
                    cNode.setAttribute("Checked", Pc);
                    //    alert(getNodeFromIndex(getNodeIndex1(cNode)));
                    treeMenu.queueEvent('oncheck', getNodeIndex1(cNode));
                }
            }
        }
        //获取所有节点状态
        function FindCheckedFromNode(node, Pc) {
            var i = 0;
            var nodes = new Array();
            nodes = node.getChildren();

            for (i = 0; i < nodes.length; i++) {
                var cNode;
                cNode = nodes[i];
                cNode.setAttribute("Checked", Pc);
                //    alert(getNodeFromIndex(getNodeIndex1(cNode)));
                treeMenu.queueEvent('oncheck', getNodeIndex1(cNode));

                if (parseInt(cNode.getChildren().length) != 0) {
                    FindCheckedFromNode(cNode, Pc);
                }
            }
        }
        //添加选中节点
        function AddChecked(node) {
            //document.accredit.checked.value += node.getAttribute("NodeData");
            // document.accredit.checked.value += ',';
        }
        //添加未选中节点
        function AddUnChecked(node) {
            //document.accredit.unchecked.value += node.getAttribute("NodeData");
            //document.accredit.unchecked.value += ',';
        }
        //-->


        //
        //李聪杰 2006-6-9
        //
        function OnTreeNodeChecked(number, ev) {
            var element = ev.srcElement || ev.target;
            if (!IsCheckBox(element))
                return;

            var isChecked = element.checked;
            //
            var tree = TV2_GetTreeById("treeMenu");
            var node = TV2_GetNode(tree, element);

            TV2_SetChildNodesCheckStatus(node, isChecked);

            var parent = TV2_GetParentNode(tree, node);
            TV2_NodeOnChildNodeCheckedChanged_Zdsoft(tree, parent, true);

        }
    </script>
</head>
<body>
    <form method="post" runat="server" target="_self">
        <div class="list-func-box func-box">
            <div class="hd b">
                <asp:Label ID="userName" runat="server">用户帐号：</asp:Label>
                <div class="user-service ">
                    <span data-original-title="帮助" data-placement="left" data-rel="popover" data-content="若未正常显示菜单树，请把webctrl_client文件夹拷贝到当前站点根目录" data-trigger="hover"><i class="fa fa-question-circle bigger-120 white"></i></span>
                </div>
                <!--/user-service-->
            </div>
            <div class="space-4"></div>
            <div class="container">
                <table border="1px" width="100%">
                    <tr>
                        <td>
                            <asp:TreeView ID="treeMenu" runat="server" ExpandDepth="0" ShowCheckBoxes="All" ShowLines="True" AutoGenerateDataBindings="False">
                            </asp:TreeView>
                            <asp:Label ID="checkLabel" runat="server" Visible="False" ForeColor="Red"></asp:Label>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="ft">
                <div class="action-field text-center">
                    <asp:Button ID="selectTrue" class="btn btn-sm btn-primary" runat="server" Text="全部选中" EnableViewState="False" CausesValidation="False" OnClick="selectTrue_Click"></asp:Button>
                    &nbsp;
                <asp:Button ID="selectFalse" class="btn btn-sm btn-primary" runat="server" Text="全部取消" OnClick="selectFalse_Click"></asp:Button>
                    &nbsp;
                <asp:Button ID="checkButton" class="btn btn-sm btn-primary" runat="server" Text="确 定" OnClick="checkButton_Click"></asp:Button>
                    &nbsp;
                <input name="button" type="button" class="btn btn-sm btn-primary" onclick="parent.$.fancybox.close();" value="关 闭" />
                    <input id="Hidden1" runat="server" type="Hidden" />
                    <input id="Hidden2" runat="server" type="Hidden" />
                </div>
            </div>
        </div>
    </form>
    <script type="text/javascript" language="javascript">
        initValues();
    </script>
    <!--#include file = "../Css/foot.htm" -->
      
</body>
</html>
