app.controller('StdWishCtrl', [ '$rootScope', '$scope', '$http', '$timeout', '$state', '$stateParams', function($rootScope, $scope, $http, $timeout, $state, $stateParams) { $scope.StdReg = angular.copy($rootScope.ArtStdReg); $scope.conf = []; $scope.currentStep = 'Init'; $scope.params={}; //保存志愿 $scope.saveStdWish = function() { var stdwish=[]; for(var i = 0;i<$scope.conf.length; i++) { if($scope.conf[i]!='' && $scope.conf[i] != undefined ) { stdwish.push($scope.conf[i]); } } $scope.conf=stdwish; if($scope.conf.length == 0) { $.alert('请选择志愿!'); return ; } if(!$scope.params.adjust) { $.alert('请选择是否服从调剂!'); return; } if($scope.params.adjust == '1' && $scope.aspectWish.length!=$scope.conf.length){ $.alert('服从调剂,需要选择所有志愿!'); return ; } for(var i = 0;i<$scope.conf.length; i++) { if($scope.conf[i]=='' || $scope.conf[i] == undefined ) { $.alert('请按顺序选择志愿!'); return; } } $rootScope.ajaxRequest({ url: '../std/wish/save.htm', data:{wish_ids:$scope.conf, adjust: $scope.params.adjust} }, function(response) { $scope.currentStep = 'success'; }); } $scope.listStdWish = function() { $scope.conf = []; //可编辑时间判断 var endTime = new Date($rootScope.FrameParam['wishEditEndTime']); var nowTime = new Date(); if(endTime.getTime() >= nowTime.getTime()) { $scope.params.editFlag = true; } else { $scope.params.editFlag = false; } $rootScope.ajaxRequest({ url: '../std/wish/list.htm', data:{aspect_id:$stateParams.aspect_id== 'null' ? null : $stateParams.aspect_id} }, function(response) { //考生志愿 $scope.wishArr = response.array; for(const wish of $scope.wishArr) { $scope.conf.push(wish.wish_id); $scope.params.adjust = wish.adjust; } }); } $scope.listAspectWish = function() { $rootScope.ajaxRequest({ url: '../cf/aspect/wish/list.htm', data:{aspect_id:$stateParams.aspect_id== 'null' ? null : $stateParams.aspect_id} }, function(response) { if(response.array.length==0) $.alert("不需要填报志愿"); $scope.aspectWish = response.array; }); } $scope.getWishNum = function(index) { var result = ''; switch (index+'') { case '1': result = '一'; break; case '2': result = '二'; break; case '3': result = '三'; break; case '4': result = '四'; break; case '5': result = '五'; break; case '6': result = '六'; break; case '7': result = '七'; break; case '8': result = '八'; break; case '9': result = '九'; break; case '10': result = '十'; break; } return result; } $scope.listStdWish(); $scope.listAspectWish(); } ])