/**
 * 用户绑定角色
 */
$(function(){

	var userId = $('#userId').val();

    var tree = $('#bindrole_tree_id').zTreeInit({
        hasCheckbox	: true,
        url		: Config.ROOT + '/authoriz/loadUserRoleTree?userId=' + userId
    });
	
	$("#authorization_bindrole_btn").click(function() {
    	var nodes = tree.getCheckedNodes(), roleIds = [];
		$(nodes).each(function(node){
			roleIds.push(this.oid);
		});
		App.Ajax.request({
			url		: Config.ROOT+'/authoriz/saveUserRoleRelation',
			params	: {
				'userId': userId,
				'roleIds': roleIds.join(',')
			},
			success: function(result){

			}
		});
	});
});