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

80 lines
2.9 KiB
JavaScript
Raw Normal View History

2016-07-27 14:30:19 +08:00
app.controller('EditProjectMemberController', ['$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 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_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+'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('tab_num',null);
// window.history.back();
$location.path("/project").search({id: project_id,tag:1});
2016-07-27 14:30:19 +08:00
});
}
});
};
vm.selectRole = function(role_id){
vm.current_edit_member.roles_id = role_id;
}
}] );