日期:2014-05-17 浏览次数:20923 次
/** * *异步方法* * 此方法用于异步加载所有功能列表 * @return * @throws SQLException */ @RequestMapping(value="/fulist") @ResponseBody public String OperatorFuList(HttpSession session) throws SQLException{ //获取操作人 OperDto operDto = (OperDto) session.getAttribute("operDto"); if(null == operDto){ return "ACTION_ERROR"; } JSONArray object =null; try { //获取所有功能列表 List<FunResource> funList = operatorManService.getAllFuncs(operDto); object = JSONArray.fromObject(funList); } catch (RuntimeException e) { e.printStackTrace(); return ACTION_ERROR; } return object.toString(); } /** * *异步方法* * 根据角色ID查询所拥有的功能列表 * @return * @throws SQLException */ @RequestMapping(value="/rolefunlist") @ResponseBody public String OperatorRoleFunList(HttpSession session) throws SQLException{ //获取操作人 OperDto operDto = (OperDto) session.getAttribute("operDto"); if(null == operDto){ return "ACTION_ERROR"; } JSONArray object =null; try { //根据角色ID查询所拥有的功能列表 List<FunResource> funList = operatorManService.getFuncsByRoleid("0000000005"); object = JSONArray.fromObject(funList); } catch (RuntimeException e) { e.printStackTrace(); return ACTION_ERROR; } return object.toString(); }
function loadFuncs(){ $('#fun_div').html(""); $.getJSON("${AP_ROOT}/operator/fulist", function(data){ $.each(data, function(i,item){ $.getJSON("${AP_ROOT}/operator/rolefunlist", function(data1){ $.each(data1, function(j,item1){ if(item1.funcid==item.funcid){ $('#fun_div').append("<div class='mi_div'><input name='funcid' type='checkbox' class='fun_check' value='"+item.funcid+"' checked='true'/><label class='fun_lable'>"+item.funcname+"</label></div>") }else{ $('#fun_div').append("<div class='mi_div'><input name='funcid' type='checkbox' class='fun_check' value='"+item.funcid+"'/><label class='fun_lable'>"+item.funcname+"</label></div>") } if((i+1)%4==0){ $('#fun_div').append("<br/>") } }); }); }); }); }