123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- app.controller('StdGraduateSchoolCtrl', function($rootScope, $scope, $http, $timeout, $state, toaster) {
- // function to submit the form after all validation has occurred
- $scope.load = function(){
- if(!$rootScope.stdExamNoticeConfirmed){
- $rootScope.dialogMsg("请先确认诚信承诺书。", function(){});
- $state.go('examNotice');
- }else{
-
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/params/schoolAddrType-schoolOwnerType-yesno',
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.paramList = data.result;
- }
- }).error(function() {
- });
-
- $scope.provinces = $rootScope.provinceAll;
- $scope.areas = [];
- $scope.cities = [];
- $scope.cur_school_areas = [];
- $scope.cur_school_cities = [];
-
- $scope.schoolInfo = {};
- // $scope.schoolInfo.same_with_graduate = $rootScope.frameParams.yes;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/acquire/schoolInfo?session=' + $rootScope.session,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.schoolInfo = data.result;
- if($scope.schoolInfo && $scope.schoolInfo.graduate_school_province){
-
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/schoolByProvince/' + $scope.schoolInfo.graduate_school_province,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.schoolList = data.result;
- }
- }).error(function() {
- });
- }
- }
- }).error(function() {
- });
- }
- }
- $scope.load();
- $scope.selectTab = function(tab){
- $scope.curTab = tab;
- }
- $scope.submitForm = function(isValid) {
- $scope.submitted = true
- // check to make sure the form is completely valid
- if (isValid) {
- if($scope.schoolInfo.same_with_graduate == $rootScope.frameParams.no && $scope.schoolInfo.current_school_id == $scope.schoolInfo.graduate_school_id){
- toaster.pop('error', '复读高中与毕业高中相同,请选择是');
- return;
- }
- if($scope.schoolInfo.same_with_graduate == $rootScope.frameParams.yes){
- $scope.schoolInfo.current_school_province = $scope.schoolInfo.graduate_school_province;
- $scope.schoolInfo.current_school_area = $scope.schoolInfo.graduate_school_area;
- $scope.schoolInfo.current_school_city = $scope.schoolInfo.graduate_school_city;
- $scope.schoolInfo.current_school_address = $scope.schoolInfo.graduate_school_address;
- $scope.schoolInfo.current_school_postcode = $scope.schoolInfo.graduate_school_postcode;
- $scope.schoolInfo.current_school_id = $scope.schoolInfo.graduate_school_id;
- }
- delete $scope.schoolInfo.graduate_school_name;
- delete $scope.schoolInfo.current_school_name;
-
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/acquire/schoolInfo?session=' + $rootScope.session,
- method : 'POST',
- data : angular.toJson($scope.schoolInfo)
- }).success(function(data) {
- if(data.code == 0){
- toaster.pop('success', '保存成功');
- $scope.form.$setPristine();
- }else{
- toaster.pop('error', data.message);
- }
- }).error(function() {
- $scope.load();
- });
- }
- };
- $scope.refreshArea = function(){
- $scope.schoolInfo.graduate_school_area = null;
- $scope.schoolInfo.graduate_school_city = null;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/area/' + $scope.schoolInfo.graduate_school_province,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.areas = data.result;
- }
- }).error(function() {
- });
- }
- $scope.refreshCity = function(){
- $scope.schoolInfo.graduate_school_city = null;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/city/' + $scope.schoolInfo.graduate_school_area,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.cities = data.result;
- }
- }).error(function() {
- });
- }
- $scope.refreshCurSchoolArea = function(){
- $scope.schoolInfo.current_school_area = null;
- $scope.schoolInfo.current_school_city = null;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/area/' + $scope.schoolInfo.current_school_province,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.cur_school_areas = data.result;
- }
- }).error(function() {
- });
- }
- $scope.refreshCurSchoolCity = function(){
- $scope.schoolInfo.current_school_city = null;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/city/' + $scope.schoolInfo.current_school_area,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.cur_school_cities = data.result;
- }
- }).error(function() {
- });
- }
-
- $scope.refreshSchool = function(){
- $scope.schoolInfo.graduate_school_id = null;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/school/' + $scope.schoolInfo.graduate_school_city,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.schoolList = data.result;
- }
- }).error(function() {
- });
- }
-
- $scope.refreshSchoolByProvince = function(){
- $scope.schoolInfo.graduate_school_id = null;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/schoolByProvince/' + $scope.schoolInfo.graduate_school_province,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.schoolList = data.result;
- }
- }).error(function() {
- });
- }
-
- $scope.refreshCurSchool = function(){
- $scope.schoolInfo.current_school_id = null;
- $scope.myPromise = $http({
- url : $rootScope.host_url + '/frame/school/' + $scope.schoolInfo.current_school_city,
- method : 'GET'
- }).success(function(data) {
- if(data.code == 0){
- $scope.curSchoolList = data.result;
- }
- }).error(function() {
- });
- }
- });
|