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

161 lines
6.0 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','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
2016-08-22 14:09:29 +08:00
// common.checkLogin();
2016-07-27 14:30:19 +08:00
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.current_edit_member = null;
vm.alertService = alertService.create();
//双弹框
vm.alertService_2 = alertService.create();
2016-07-27 14:30:19 +08:00
var project_id = $routeParams.id;
var user_id = $routeParams.user_id;
vm.buttongrey = true;
2016-07-27 14:30:19 +08:00
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,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});
});
2016-07-27 14:30:19 +08:00
} else {
project_id = response.data.project_id;
user_id = response.data.user_id;
vm.current_edit_member = response.data.member_info;
2016-08-02 15:50:15 +08:00
vm.current_edit_member.roles_id = vm.current_edit_member.roles_id[0];
2016-07-27 14:30:19 +08:00
vm.current_roles_id = vm.current_edit_member.roles_id;
}
});
}
console.log(vm.current_edit_member);
vm.cancel = function(){
2016-08-01 13:54:10 +08:00
// vm.alertService.showMessage('提示', '您确定不对角色进行变更吗?', function(){
// window.history.back();
// });
window.history.back();
2016-07-27 14:30:19 +08:00
};
vm.deleteMember = function(user_id){
vm.alertService_2.showMessage('提示', "是否确认删除成员",function(){
$http({
method: 'POST',
url: apiUrl + "projects/" + project_id+"/deletemember",
data:{token:auth.token(),user_id:user_id}
}).then(function successCallback(response) {
console.log(response.data);
if(response.data.status == 0){
vm.alertService.showMessage('提示', response.data.message,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});
});
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
});
});
};
2016-07-27 14:30:19 +08:00
vm.edit_member_role = function(){
if(vm.buttongrey == true){
2016-07-27 14:30:19 +08:00
return;
}
if(vm.current_edit_member.show){
//删除成员
vm.deleteMember(vm.current_edit_member.user.id);
}
else{
if(vm.current_roles_id == vm.current_edit_member.roles_id){
vm.alertService.showMessage('提示', "该用户当前已是该角色");
return;
2016-07-27 14:30:19 +08:00
}
$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});
});
}
});
}
2016-07-27 14:30:19 +08:00
};
vm.selectRole = function(role_id){
vm.current_edit_member.roles_id = role_id;
if(vm.current_roles_id == vm.current_edit_member.roles_id){
vm.buttongrey = true;
}
else{
vm.buttongrey = false;
}
};
vm.clickChangeRole = function(){
vm.current_edit_member.show = !vm.current_edit_member.show;
if(vm.current_roles_id == vm.current_edit_member.roles_id){
vm.buttongrey = true;
}
else{
vm.buttongrey = false;
}
};
2016-07-27 14:30:19 +08:00
}] );