109 lines
3.7 KiB
JavaScript
109 lines
3.7 KiB
JavaScript
|
|
|
|
app.controller('ReviewProjectMemberController', ['$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;
|
|
|
|
vm.teacher = false; //教师
|
|
vm.assistant = false; //教辅
|
|
vm.student = false; //学生.
|
|
|
|
vm.tmpteacher = false; //教师
|
|
vm.tmpassistant = false; //教辅
|
|
vm.tmpstudent = false; //学生
|
|
|
|
|
|
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 {
|
|
console.log(response);
|
|
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;
|
|
|
|
for(var i in vm.current_roles_id){
|
|
if(vm.current_roles_id[i] == 9){
|
|
vm.teacher = true;
|
|
vm.tmpteacher = true;
|
|
}
|
|
else if(vm.current_roles_id[i] == 7){
|
|
vm.assistant = true;
|
|
vm.tmpassistant = true;
|
|
}
|
|
else if(vm.current_roles_id[i] == 10){
|
|
vm.student = true;
|
|
vm.tmpstudent = true;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
vm.cancel = function(){
|
|
// vm.alertService.showMessage('提示', '您确定不对角色进行变更吗?', function(){
|
|
// window.history.back();
|
|
// });
|
|
window.history.back();
|
|
};
|
|
|
|
vm.edit_member_role = function(){
|
|
if((vm.teacher == vm.tmpteacher)&& (vm.assistant == vm.tmpassistant)&&(vm.student == vm.tmpstudent)){
|
|
vm.alertService.showMessage('提示', "该用户当前已是该角色");
|
|
return;
|
|
}
|
|
|
|
if((vm.teacher == false)&& (vm.assistant == false)&&(vm.student == false)){
|
|
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,
|
|
teacher_flag:vm.teacher,
|
|
assistant_flag:vm.assistant,
|
|
student_flag:vm.student
|
|
}).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});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
vm.selectRole = function(role_id){
|
|
if (role_id == 7){
|
|
if(!vm.teacher){
|
|
vm.assistant = !vm.assistant;
|
|
}
|
|
}
|
|
else if (role_id == 9){
|
|
if(!vm.assistant){
|
|
vm.teacher = !vm.teacher;
|
|
}
|
|
}
|
|
else if (role_id == 10){
|
|
vm.student = !vm.student;
|
|
}
|
|
}
|
|
|
|
}] ); |