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

81 lines
3.0 KiB
JavaScript

app.controller('EditProjectMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
common.checkLogin();
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.current_edit_member = null;
vm.alertService = alertService.create();
var project_id = $routeParams.id;
var user_id = $routeParams.user_id;
if(!vm.current_edit_member){
$http.post(config.apiUrl+'projects/get_member_info', {
token: auth.token(),
id: project_id,
user_id:user_id
}).then(function(response){
if(response.data.status!=0){
vm.alertService.showMessage('提示', response.data.message);
} else {
project_id = response.data.project_id;
user_id = response.data.user_id;
vm.current_edit_member = response.data.member_info;
vm.current_edit_member.roles_id = vm.current_edit_member.roles_id[0];
vm.current_roles_id = vm.current_edit_member.roles_id;
}
});
}
console.log(vm.current_edit_member);
vm.cancel = function(){
// vm.alertService.showMessage('提示', '您确定不对角色进行变更吗?', function(){
// window.history.back();
// });
window.history.back();
};
vm.edit_member_role = function(){
if(vm.current_roles_id == vm.current_edit_member.roles_id){
vm.alertService.showMessage('提示', "该用户当前已是该角色");
return;
}
$http.post(config.apiUrl+'projects/edit_member_role', {
token: auth.token(),
id: project_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(){
rms.save('project_activities_page',0);
rms.save("project_activities",[]);
rms.save("project_has_more",false);
rms.save("project",null);
rms.save("project_master_members",[]);
rms.save("project_develop_members",[]);
rms.save("project_report_members",[]);
rms.save("review_master_members",[]);
rms.save("review_develop_members",[]);
rms.save('tab_num',null);
// window.history.back();
$location.path("/project").search({id: project_id,tag:1});
});
}
});
};
vm.selectRole = function(role_id){
vm.current_edit_member.roles_id = role_id;
}
}] );