socialforge/public/javascripts/wechat/controllers/edit_class_member.js

72 lines
2.5 KiB
JavaScript
Raw Normal View History

2016-07-27 14:30:19 +08:00
app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.current_edit_member = null;
vm.alertService = alertService.create();
var course_id = $routeParams.id;
var user_id = $routeParams.user_id;
if(!vm.current_edit_member){
$http.post(config.apiUrl+'courses/get_member_info', {
token: auth.token(),
id: course_id,
user_id:user_id
}).then(function(response){
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message);
} else {
course_id = response.data.course_id;
user_id = response.data.user_id;
vm.current_edit_member = response.data.member_info;
vm.current_roles_id = vm.current_edit_member.roles_id;
}
});
}
console.log(vm.current_edit_member);
vm.cancel = function(){
vm.alertService.showMessage('提示', '您确定不对角色进行变更吗?', function(){
// rms.save("project_master_members",[]);
// rms.save("project_develop_members",[]);
// rms.save("project_report_members",[]);
window.history.back();
// $location.path("/project").search({id: project_id});
});
};
vm.edit_member_role = function(){
if(vm.current_roles_id == vm.current_edit_member.roles_id){
vm.alertService.showMessage('提示', "该用户当前已是该角色");
return;
}
$http.post(config.apiUrl+'courses/edit_member_role', {
token: auth.token(),
id: course_id,
user_id:vm.current_edit_member.user.id,
role_id:vm.current_edit_member.roles_id
}).then(function(response){
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message);
} else {
vm.alertService.showMessage('提示', '修改角色成功', function(){
// window.history.back();
$location.path("/class").search({id: course_id,tag:1});
2016-07-27 14:30:19 +08:00
});
}
});
};
vm.selectRole = function(role_id){
vm.current_edit_member.roles_id = role_id;
}
}] );