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

102 lines
3.5 KiB
JavaScript

app.controller('ReviewProjectMemberController', ['$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_review_member = rms.get('current_review_member');
vm.current_project = rms.get('current_project');
vm.alertService = alertService.create();
vm.tip_1 = "";
vm.tip_2 = "";
var project_id = $routeParams.id;
var user_id = $routeParams.user_id;
vm.status = 1;
if(!vm.current_project){
$http.get(config.apiUrl+ 'projects/'+project_id+"?token="+auth.token()).then(
function(response) {
console.log(response.data);
if (response.data.status == 0){
vm.current_project = response.data.data;
console.log("projects");
console.log(response.data.data);
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
if(!vm.current_project){
vm.tip_1 = "该项目不存在或已被删除";
}
}
);
}
if(!vm.current_review_member){
$http.post(config.apiUrl+'projects/review_member_info', {
token: auth.token(),
project_id: project_id,
user_id:user_id
}).then(function(response){
if(response.data.status==-1){
vm.alertService.showMessage('提示', response.data.message);
} else {
vm.status = response.data.status;
vm.current_review_member = response.data.data;
console.log("review_member_info");
console.log(response.data.data);
}
if(!vm.current_review_member){
vm.tip_2 = "该申请不存在";
}
});
}
vm.deal = function(result){
$http.post(config.apiUrl+'projects/deal_join_apply', {
token: auth.token(),
project_id: project_id,
user_id:user_id,
type:result
}).then(function(response) {
if (response.data.status == 0) {
vm.alertService.showMessage('提示', response.data.message, function () {
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);
$location.path("/project").search({id: project_id,tag:1});
});
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
});
};
vm.goProjectMemberList = function(){
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);
if(vm.current_project.is_member){
$location.path("/project").search({id: project_id,tag: 1});
}
else{
$location.path("/project_list")
}
};
}] );