73 lines
2.4 KiB
JavaScript
73 lines
2.4 KiB
JavaScript
app.controller('ClassPublishIssueController', ['$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_course = rms.get('current_course');
|
|
|
|
vm.issuetitle = "";
|
|
vm.issue = "";
|
|
var course_id = $routeParams.id;
|
|
|
|
vm.alertService = alertService.create();
|
|
|
|
if(!vm.current_course){
|
|
$http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then(
|
|
function(response) {
|
|
console.log(response.data);
|
|
if (response.data.status == 0){
|
|
vm.current_course = response.data.data;
|
|
console.log("courses");
|
|
console.log(response.data.data);
|
|
}
|
|
else{
|
|
vm.alertService.showMessage('提示', response.data.message);
|
|
}
|
|
if(!vm.current_course){
|
|
vm.tip_1 = "该班级不存在或已被删除";
|
|
}
|
|
|
|
}
|
|
);
|
|
}
|
|
|
|
vm.cancel = function(){
|
|
window.history.back();
|
|
};
|
|
|
|
//发布问题 即项目讨论区
|
|
vm.publishIssue = function(){
|
|
if(vm.issuetitle.length == 0)
|
|
{
|
|
vm.alertService.showMessage('提示', '标题不能为空');
|
|
return;
|
|
}
|
|
|
|
if(vm.issue.length == 0)
|
|
{
|
|
vm.alertService.showMessage('提示', '内容不能为空');
|
|
return;
|
|
}
|
|
|
|
var text = vm.issue.replace(/\n/g,'<br/>');
|
|
|
|
$http.post(config.apiUrl + "courses/"+course_id+"/publishissue",
|
|
{token: auth.token(),title: vm.issuetitle, text: text}
|
|
).then(function(response){
|
|
if(response.data.status == 0)
|
|
{
|
|
vm.alertService.showMessage('提示', '发布成功',function(){
|
|
rms.save('course_activities_page',0);
|
|
rms.save("course_activities",[]);
|
|
rms.save("course_has_more",false);
|
|
$location.path("/class").search({id: course_id});
|
|
});
|
|
}
|
|
else{
|
|
vm.alertService.showMessage('提示', response.data.message);
|
|
|
|
}
|
|
});
|
|
|
|
};
|
|
|
|
}] ); |