parent
60367415fa
commit
48fb02a2d6
@ -0,0 +1,14 @@
|
||||
<div class="post-container">
|
||||
<div loading-spinner></div>
|
||||
|
||||
<div class="blue-title">管理课程</div>
|
||||
<form novalidate name="classForm">
|
||||
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" ng-model="syllabus.title" required placeholder="请输入课程名" /></div>
|
||||
|
||||
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses"><span class="fl ml15 c-grey3">班级</span><input required class="new-class-input ml25" ng-model="course.name" placeholder="请输入班级名" /><a ng-click="deleteClass($index)" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
|
||||
<div class="tac"><a ng-click="addClass()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
|
||||
<a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a>
|
||||
</form>
|
||||
|
||||
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
|
||||
</div>
|
@ -0,0 +1,77 @@
|
||||
|
||||
|
||||
app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
|
||||
var vm = $scope;
|
||||
|
||||
vm.syllabus = rms.get('current_edit_syllobus');
|
||||
console.log(vm.syllabus);
|
||||
|
||||
var syllabus_id = $routeParams.id;
|
||||
if(!vm.syllabus){
|
||||
$http.get(config.apiUrl+"syllabuses/"+syllabus_id+"?token="+auth.token()).then(function(response){
|
||||
console.log(response.data);
|
||||
vm.syllabus = response.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
vm.alertService = alertService.create();
|
||||
vm.addClass = function(){
|
||||
vm.syllabus.courses.push({});
|
||||
};
|
||||
|
||||
vm.deleteClass = function(index){
|
||||
var course = vm.syllabus.courses[index];
|
||||
if(course.id >0){
|
||||
$http.post(config.apiUrl+'courses/'+course.id+'/del', {
|
||||
token: auth.token()
|
||||
}).then(function(response){
|
||||
if(response.data.status!=0){
|
||||
vm.alertService.showMessage('出错了', response.data.message);
|
||||
} else {
|
||||
vm.alertService.showMessage('提示', '删除班级成功', function(){
|
||||
vm.syllabus.courses.splice(index, 1);
|
||||
});
|
||||
}
|
||||
console.log(response.data.data);
|
||||
});
|
||||
} else {
|
||||
vm.syllabus.courses.splice(index, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vm.newClass = function (frm, syllabus) {
|
||||
frm.$setSubmitted();
|
||||
console.log(syllabus);
|
||||
|
||||
if(!frm.$valid){
|
||||
console.log(frm.$error);
|
||||
return;
|
||||
}
|
||||
|
||||
var courses = [];
|
||||
for(var i in vm.syllabus.courses){
|
||||
var course = vm.syllabus.courses[i];
|
||||
if(course.id>0){
|
||||
courses.push(course.name);
|
||||
}
|
||||
}
|
||||
|
||||
$http.post(config.apiUrl+"syllabuses", {
|
||||
token: auth.token(),
|
||||
id: syllabus_id,
|
||||
courses: courses
|
||||
}).then(function(response){
|
||||
if(response.data.status!=0){
|
||||
vm.alertService.showMessage('出错了', response.data.message);
|
||||
} else {
|
||||
vm.alertService.showMessage('提示', '保存课程成功', function(){
|
||||
window.history.back();
|
||||
});
|
||||
}
|
||||
console.log(response.data.data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}] );
|
Loading…
Reference in new issue