删除班级时增加提示确定信息

This commit is contained in:
yuanke 2016-07-07 14:55:41 +08:00
parent 7859bf9c32
commit 3a6470b1f3
2 changed files with 24 additions and 15 deletions

View File

@ -10,5 +10,6 @@
<a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a> <a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a>
</form> </form>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert> <my-alert message="alertService_1.message" title="alertService_1.title" visible="alertService_1.visible" cb="alertService_1.cb"></my-alert>
<my-alert2 message="alertService_2.message" title="alertService_2.title" visible="alertService_2.visible" cb="alertService_2.cb"></my-alert2>
</div> </div>

View File

@ -14,7 +14,12 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale
}); });
} }
vm.alertService = alertService.create(); //单弹框
vm.alertService_1 = alertService.create();
//双弹框
vm.alertService_2 = alertService.create();
vm.addClass = function(){ vm.addClass = function(){
vm.syllabus.courses.push({}); vm.syllabus.courses.push({});
}; };
@ -22,18 +27,21 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale
vm.deleteClass = function(index){ vm.deleteClass = function(index){
var course = vm.syllabus.courses[index]; var course = vm.syllabus.courses[index];
if(course.id >0){ if(course.id >0){
$http.post(config.apiUrl+'courses/'+course.id+'/del', { vm.alertService_2.showMessage('提示', '您确定要删除该班级吗?', function() {
token: auth.token() $http.post(config.apiUrl+'courses/'+course.id+'/del', {
}).then(function(response){ token: auth.token()
if(response.data.status!=0){ }).then(function(response){
vm.alertService.showMessage('出错了', response.data.message); if(response.data.status!=0){
} else { vm.alertService_1.showMessage('出错了', response.data.message);
vm.alertService.showMessage('提示', '删除班级成功', function(){ } else {
vm.syllabus.courses.splice(index, 1); vm.alertService_1.showMessage('提示', '删除班级成功', function(){
}); vm.syllabus.courses.splice(index, 1);
} });
console.log(response.data.data); }
console.log(response.data.data);
});
}); });
} else { } else {
vm.syllabus.courses.splice(index, 1); vm.syllabus.courses.splice(index, 1);
} }
@ -63,9 +71,9 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale
courses: courses courses: courses
}).then(function(response){ }).then(function(response){
if(response.data.status!=0){ if(response.data.status!=0){
vm.alertService.showMessage('出错了', response.data.message); vm.alertService_1.showMessage('出错了', response.data.message);
} else { } else {
vm.alertService.showMessage('提示', '保存课程成功', function(){ vm.alertService_1.showMessage('提示', '保存课程成功', function(){
window.history.back(); window.history.back();
}); });
} }