在js对象中定义属性和方法的实例。

来源:互联网 发布:韦雪不做淘宝了 编辑:程序博客网 时间:2024/05/16 04:06

关键代码:

//登录用户类
function LoginUser() {
this.dept_pk = 0;
this.dept_name = '';
this.uname = '';
this.role_pks = '';
this.latitude = '';
this.longitude = '';
this.role_authority = [];
this.map_zoom_level = 0;
this.layer = 0;
}

还有:

//权限确认,在没有权限的情况下进行提示

LoginUser.prototype.checkAuthority = function(moduleName,funcName) {

  /**过虑超级管理员使用的菜单**/
  if(window.parent.useruid.toLowerCase()=="superusersqjz"){
  
    return true
  }
  if(moduleName=="评估说明" || moduleName=="风险评估" || moduleName=="整体风险" || moduleName=="初期量表" || moduleName=="中期量表" || moduleName=="末期量表"  ||  moduleName=="风险统计"){
  return true;
  }
var mfname = moduleName+"@"+funcName
    for (var idx=0;idx<this.role_authority.length;idx+=1) {
    if (this.role_authority[idx]===mfname) {
    return true;
    }
    }
Ext.Msg.show({
title: "警告",
width: 330 ,
msg: "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您没有使用【"+moduleName+"——"+funcName+"】功能的权限!如果确定要使用此功能,请和系统管理员联系!",
buttons: Ext.Msg.OK,
icon: Ext.Msg.WARNING
});
    return false;
};


通过如下方法创建实例:

//当前登录用户
var loginUser = new LoginUser();


这样就可以如下使用:

 if (!loginUser.checkAuthority('归档档案','查询'))
    return;



0 0
原创粉丝点击