/*权限类*/
function jsPopedom()
{

};
/*权限项*/
jsPopedom.Items={
/*客户库导入*/
    OTHER_CSMIMP:"OTHER_CSMIMP",
    /*客户库维护*/
    OTHER_CUSTOMERPRO:"OTHER_CUSTOMERPRO",
    /*部门客户库设置*/
    OTHER_DEPARTMENTSHEET:"OTHER_DEPARTMENTSHEET",
    /*生效审核*/
    OTHER_ACTIVECHECK:"OTHER_ACTIVECHECK",
    /*联系人导出*/
    OTHER_OUTLINKNAME:"OTHER_OUTLINKNAME",
    /*修改联系人*/
    OTHER_UPDATELINKMAN:"OTHER_UPDATELINKMAN",
    /*缴费提醒导出*/
    OTHER_OUTPAYMENT:"OTHER_OUTPAYMENT",
    /*缴费查询导出*/
    OTHER_OUTPAYMENTLIST:"OTHER_OUTPAYMENTLIST",
    /*服务记录导出*/
    OTHER_OUTCUSTOMERDEAL:"OTHER_OUTCUSTOMERDEAL",
    /*打印模板*/
    OTHER_PRINTTEMPLATELIST:"OTHER_PRINTTEMPLATELIST",
    /*维护部门文件目录*/
    MAINTAIN_DEPT_LIST:"MAINTAIN_DEPT_LIST",
    /*维护公司文件目录*/
    MAINTAIN_COMY_LIST:"MAINTAIN_COMY_LIST",
    /*修改部门文件属性*/
    UPDATE_DEPT_FILE: 'UPDATE_DEPT_FILE',
    /*修改公司文件属性*/
    UPDATE_CMPY_FILE: 'UPDATE_CMPY_FILE',
    /*删除部门文件*/
    DELETE_DEPT_FILE: 'DELETE_DEPT_FILE',
    /*删除公司文件*/
    DELETE_CMPY_FILE: 'DELETE_CMPY_FILE',
    /*停用部门文件*/
    DISABLE_DEPT_FILE: 'DISABLE_DEPT_FILE',
    /*停用公司文件*/
    DISABLE_CMPY_FILE: 'DISABLE_CMPY_FILE',
    /*调整文件性质*/
    ADJUST_FILE: 'ADJUST_FILE',
    /*文档级别档案维护*/
    MAINTAIN_FILE_LEVEL:'MAINTAIN_FILE_LEVEL',
    /*文档权限设置维护*/
    MAINTAIN_FILE_ROLESET:'MAINTAIN_FILE_ROLESET',
    /*文档人员关系设置维护*/
    MAINTAIN_FILE_EMPLOYEE:'MAINTAIN_FILE_EMPLOYEE',
    /*文档流程设计维护*/
    MAINTAIN_FILE_FLOW:'MAINTAIN_FILE_FLOW',
    /*停用文档维护*/
    MAINTAIN_FILE_DISABLE:'MAINTAIN_FILE_DISABLE',
    /*信函数据维护*/
    MAINTAIN_WORDTEMPLATE:'MAINTAIN_WORDTEMPLATE'
};
/*获取指定用户权限集合*/
jsPopedom.getUserPopedom=function(UserID)
{
    var dataObj=null;
    var ManagerdataObj=null;
    var arr=new Array();
    try
    {
        /*获取用户权限码集合*/
        var strSql="exec eOA_Sys_GetUserPopedomGroup "+UserID;
        dataObj=DBReader.selectSql(strSql,"PopedomGroup");
        if(DBReader.DObjectIsNull(dataObj)==false)
        {
            var rowCount=dataObj.RecordCount;
            if(rowCount>0)
            {
                dataObj.MoveFirst();
            }
            for(var i=0;i<rowCount;i++)
            {
                arr.push("【"+dataObj.Fields("PURVIEW_CODE").Value+"】");
                dataObj.MoveNext();
            }
            rowCount=null;
        }
        strSql=null;
        /*获取用户是否管理员标识*/
        var strSqlUserInfo="exec eOA_Sys_GetUserInfo "+UserID;
        ManagerdataObj=DBReader.selectSql(strSqlUserInfo,"eOA_Sys_GetUserInfo");
        if(DBReader.DObjectIsNull(ManagerdataObj)==false)
        {
            var rowCount=ManagerdataObj.RecordCount;
            if(rowCount>0)
            {
                ManagerdataObj.MoveFirst();
            }
            arr.push("【IS_DEPTM:"+ManagerdataObj.Fields("IS_DEPTM").Value+"】");
            arr.push("【SUPERM:"+ManagerdataObj.Fields("SUPERM").Value+"】");
            rowCount=null;
        }
        strSqlUserInfo=null;
    }
    catch(e)
    {
        DBReader.Dispose(dataObj);
        DBReader.Dispose(ManagerdataObj);
        arr=null;
        alert(e.message);
    }
    DBReader.Dispose(dataObj);
    DBReader.Dispose(ManagerdataObj);
    CollectGarbage();
    return arr;
};
/*判断指定权限是否存在
arrPopedomGroup：指定用户权限集合
PopedomCode：权限编码
ContainSuperManager：是否启用超级管理员权限
ContainDepartManager：是否启用部门管理员权限
返回值如果是true表示有权限，false表示没有权限
*/
jsPopedom.isHaved=function(arrPopedomGroup,PopedomCode,ContainSuperManager,ContainDepartManager)
{
    var IsHaved=false;
    try
    {
        var PopedomString=arrPopedomGroup.join(',');
        if(typeof(ContainSuperManager)!="undefined" && ContainSuperManager==1)
        {
            /*判断是否是超级管理员*/
            if(PopedomString.indexOf("【SUPERM:1】")!=-1 || PopedomString.indexOf("【SUPERM:true】")!=-1)
            {
                IsHaved=true;
            }
            else if(typeof(ContainDepartManager)!="undefined" && ContainDepartManager==1)
            {
                /*判断是否是部门主管*/
                if(PopedomString.indexOf("【IS_DEPTM:1】")!=-1 || PopedomString.indexOf("【IS_DEPTM:true】")!=-1)
                {
                    IsHaved=true;
                }
                else if(PopedomString.indexOf("【"+PopedomCode+"】")!=-1)
                {
                    IsHaved=true;
                }
                else
                {
                    IsHaved=false;
                }
            }
            else if(PopedomString.indexOf("【"+PopedomCode+"】")!=-1)
            {
                IsHaved=true;
            }
            else
            {
                IsHaved=false;
            }
        }
        else if(typeof(ContainDepartManager)!="undefined" && ContainDepartManager==1)
        {
            /*判断是否是部门主管*/
            if(PopedomString.indexOf("【IS_DEPTM:1】")!=-1 || PopedomString.indexOf("【IS_DEPTM:true】")!=-1)
            {
                IsHaved=true;
            }
            else if(PopedomString.indexOf("【"+PopedomCode+"】")!=-1)
            {
                IsHaved=true;
            }
            else
            {
                IsHaved=false;
            }
        }
        else if(PopedomString.indexOf("【"+PopedomCode+"】")!=-1)
        {
            IsHaved=true;
        }
        else
        {
            IsHaved=false;
        }
        PopedomString="";
        PopedomString=null;
    }
    catch(e)
    {
        alert(e.message);
    }
    CollectGarbage();
    return IsHaved;
};
/*控制权限与控件之间的关系
有权限显示，无权限隐藏
*/
jsPopedom.controlAndPopedom=function(arrPopedomGroup,PopedomCode,ControlID,ContainSuperManager,ContainDepartManager)
{
    try
    {
        var isHavePopedom=jsPopedom.isHaved(arrPopedomGroup,PopedomCode,ContainSuperManager,ContainDepartManager);
        if(isHavePopedom)
        {
            document.getElementById(ControlID).style.display='';
        }
        else
        {
            document.getElementById(ControlID).style.display='none';
        }
        return isHavePopedom;
    }
    catch(e)
    {
        alert(e.message);
    }
    CollectGarbage();
};