⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 permissions.js

📁 在编写管理信统软件中,您是否对于繁琐的多用户权限管理而头痛?需要对不同的用户设置不同的权限,需要添加/删除用户,并进行相应的管理.您是否对这些功能感到厌烦? 现在,RGP(Red Glove Perm
💻 JS
字号:
var error = false;
var _oTree = null;
var _arrGrant = null;
var _arrDeny = null;

function window.onload()
{
    if(error)
    {
        alert(Message.serverError);
        window.returnValue = {Succeed : false};
        window.close();
    }
    _oTree = document.all.tvRights;
    _oTree.attachEvent("oncheck", tvRightsChecked);
    
    //修正ie web control treeview checkbox的bug。
    _build_arrPermissions();
    //-----------
}

//
//	id:		tvRights
//	event:	oncheck
//
function tvRightsChecked()
{
    var node = _oTree.getTreeNode(event.treeNodeIndex);
    
    //修正ie web control treeview checkbox的bug。
    if(_isInOriginalList(node.getAttribute("PKId"), node.getAttribute("Type")))
    {
        node.setAttribute("checked", !node.getAttribute("checked"));
    }
    //-----------
    
    var checked = node.getAttribute("checked");
    if(checked)
    {
        var parent = node.getParent();
        var brothers = parent.getChildren();
        for(var i = 0; i < brothers.length; i++)
        {
            var brother = brothers[i];
            if( brother.getAttribute("Type") != node.getAttribute("Type") &&
                brother.getAttribute("PKId") == node.getAttribute("PKId"))
            {
                if(brother.getAttribute("checked"))
                {
                    brother.setAttribute("checked", false);
                }
                break;
            }
        }
    }
}

//
//	id:		btnSubmit
//	event:	onclick
//
function btnSubmitClicked()
{
    try
    {
        _build_arrPermissions();
        var updateStr = "<Permissions><StaffId>" + window.dialogArguments.id + "</StaffId><Grant>" + _arrGrant.join("|") + "</Grant><Deny>" + _arrDeny.join("|") + "</Deny></Permissions>";
        var succeed = XmlHttpHelper.transmit(false, "post", "text", "RemoteHandlers/UpdatePermissions.ashx", null, updateStr);
    	
	    if(succeed == "1")
        {
	        window.returnValue = {Succeed : true};
	        window.close();
        }
        else
        {
            alert(Message.serverError);
            window.returnValue = {Succeed : false};
            window.close();
        }
    }
	catch(e)
	{
	    alert(Message.clientError);
	    window.returnValue = {Succeed : false};
	    window.close();
	}
}

//
//	根据用户选择的授权,构建_arrGrant和_arrDeny全局数组。
//
function _build_arrPermissions()
{
    _arrGrant = new Array();
    _arrDeny = new Array();
    _add_permissions(_oTree);
}
function _add_permissions(parent)
{
    var children = parent.getChildren();
    for(var i = 0; i < children.length; i++)
    {
        var child = children[i];
        if(child.getAttribute("Type") == "moduletype")
        {
            _add_permissions(child);
        }
        else if(child.getAttribute("Type") == "module")
        {
            var permissions = child.getChildren();
            for(var j = 0; j < permissions.length; j++)
            {
                var permission = permissions[j];
                if(permission.getAttribute("checked"))
                {
                    if(permission.getAttribute("Type") == "grant")
                    {
                        _arrGrant.push(permission.getAttribute("PKId"));
                    }
                    else if(permission.getAttribute("Type") == "deny")
                    {
                        _arrDeny.push(permission.getAttribute("PKId"));
                    }
                }
            }
        }
    }
}

//
//  判断节点是否在初始选中列表中。(修正ie web control treeview checkbox的bug。)
//
function _isInOriginalList(PKId, Type)
{
    if(Type == "grant")
    {
        for(var i = 0; i < _arrGrant.length; i++)
        {
            if(PKId == _arrGrant[i])
                return true;
        }
    }
    else if(Type == "deny")
    {
        for(var i = 0; i < _arrDeny.length; i++)
        {
            if(PKId == _arrDeny[i])
                return true;
        }
    }
    return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -