std_graduate_school.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. app.controller('StdGraduateSchoolCtrl', function($rootScope, $scope, $http, $timeout, $state, toaster) {
  2. // function to submit the form after all validation has occurred
  3. $scope.load = function(){
  4. if(!$rootScope.stdExamNoticeConfirmed){
  5. $rootScope.dialogMsg("请先确认诚信承诺书。", function(){});
  6. $state.go('examNotice');
  7. }else{
  8. $scope.myPromise = $http({
  9. url : $rootScope.host_url + '/frame/params/schoolAddrType-schoolOwnerType-yesno',
  10. method : 'GET'
  11. }).success(function(data) {
  12. if(data.code == 0){
  13. $scope.paramList = data.result;
  14. }
  15. }).error(function() {
  16. });
  17. $scope.provinces = $rootScope.provinceAll;
  18. $scope.areas = [];
  19. $scope.cities = [];
  20. $scope.cur_school_areas = [];
  21. $scope.cur_school_cities = [];
  22. $scope.schoolInfo = {};
  23. // $scope.schoolInfo.same_with_graduate = $rootScope.frameParams.yes;
  24. $scope.myPromise = $http({
  25. url : $rootScope.host_url + '/acquire/schoolInfo?session=' + $rootScope.session,
  26. method : 'GET'
  27. }).success(function(data) {
  28. if(data.code == 0){
  29. $scope.schoolInfo = data.result;
  30. if($scope.schoolInfo && $scope.schoolInfo.graduate_school_province){
  31. $scope.myPromise = $http({
  32. url : $rootScope.host_url + '/frame/schoolByProvince/' + $scope.schoolInfo.graduate_school_province,
  33. method : 'GET'
  34. }).success(function(data) {
  35. if(data.code == 0){
  36. $scope.schoolList = data.result;
  37. }
  38. }).error(function() {
  39. });
  40. }
  41. }
  42. }).error(function() {
  43. });
  44. }
  45. }
  46. $scope.load();
  47. $scope.selectTab = function(tab){
  48. $scope.curTab = tab;
  49. }
  50. $scope.submitForm = function(isValid) {
  51. $scope.submitted = true
  52. // check to make sure the form is completely valid
  53. if (isValid) {
  54. if($scope.schoolInfo.same_with_graduate == $rootScope.frameParams.no && $scope.schoolInfo.current_school_id == $scope.schoolInfo.graduate_school_id){
  55. toaster.pop('error', '复读高中与毕业高中相同,请选择是');
  56. return;
  57. }
  58. if($scope.schoolInfo.same_with_graduate == $rootScope.frameParams.yes){
  59. $scope.schoolInfo.current_school_province = $scope.schoolInfo.graduate_school_province;
  60. $scope.schoolInfo.current_school_area = $scope.schoolInfo.graduate_school_area;
  61. $scope.schoolInfo.current_school_city = $scope.schoolInfo.graduate_school_city;
  62. $scope.schoolInfo.current_school_address = $scope.schoolInfo.graduate_school_address;
  63. $scope.schoolInfo.current_school_postcode = $scope.schoolInfo.graduate_school_postcode;
  64. $scope.schoolInfo.current_school_id = $scope.schoolInfo.graduate_school_id;
  65. }
  66. delete $scope.schoolInfo.graduate_school_name;
  67. delete $scope.schoolInfo.current_school_name;
  68. $scope.myPromise = $http({
  69. url : $rootScope.host_url + '/acquire/schoolInfo?session=' + $rootScope.session,
  70. method : 'POST',
  71. data : angular.toJson($scope.schoolInfo)
  72. }).success(function(data) {
  73. if(data.code == 0){
  74. toaster.pop('success', '保存成功');
  75. $scope.form.$setPristine();
  76. }else{
  77. toaster.pop('error', data.message);
  78. }
  79. }).error(function() {
  80. $scope.load();
  81. });
  82. }
  83. };
  84. $scope.refreshArea = function(){
  85. $scope.schoolInfo.graduate_school_area = null;
  86. $scope.schoolInfo.graduate_school_city = null;
  87. $scope.myPromise = $http({
  88. url : $rootScope.host_url + '/frame/area/' + $scope.schoolInfo.graduate_school_province,
  89. method : 'GET'
  90. }).success(function(data) {
  91. if(data.code == 0){
  92. $scope.areas = data.result;
  93. }
  94. }).error(function() {
  95. });
  96. }
  97. $scope.refreshCity = function(){
  98. $scope.schoolInfo.graduate_school_city = null;
  99. $scope.myPromise = $http({
  100. url : $rootScope.host_url + '/frame/city/' + $scope.schoolInfo.graduate_school_area,
  101. method : 'GET'
  102. }).success(function(data) {
  103. if(data.code == 0){
  104. $scope.cities = data.result;
  105. }
  106. }).error(function() {
  107. });
  108. }
  109. $scope.refreshCurSchoolArea = function(){
  110. $scope.schoolInfo.current_school_area = null;
  111. $scope.schoolInfo.current_school_city = null;
  112. $scope.myPromise = $http({
  113. url : $rootScope.host_url + '/frame/area/' + $scope.schoolInfo.current_school_province,
  114. method : 'GET'
  115. }).success(function(data) {
  116. if(data.code == 0){
  117. $scope.cur_school_areas = data.result;
  118. }
  119. }).error(function() {
  120. });
  121. }
  122. $scope.refreshCurSchoolCity = function(){
  123. $scope.schoolInfo.current_school_city = null;
  124. $scope.myPromise = $http({
  125. url : $rootScope.host_url + '/frame/city/' + $scope.schoolInfo.current_school_area,
  126. method : 'GET'
  127. }).success(function(data) {
  128. if(data.code == 0){
  129. $scope.cur_school_cities = data.result;
  130. }
  131. }).error(function() {
  132. });
  133. }
  134. $scope.refreshSchool = function(){
  135. $scope.schoolInfo.graduate_school_id = null;
  136. $scope.myPromise = $http({
  137. url : $rootScope.host_url + '/frame/school/' + $scope.schoolInfo.graduate_school_city,
  138. method : 'GET'
  139. }).success(function(data) {
  140. if(data.code == 0){
  141. $scope.schoolList = data.result;
  142. }
  143. }).error(function() {
  144. });
  145. }
  146. $scope.refreshSchoolByProvince = function(){
  147. $scope.schoolInfo.graduate_school_id = null;
  148. $scope.myPromise = $http({
  149. url : $rootScope.host_url + '/frame/schoolByProvince/' + $scope.schoolInfo.graduate_school_province,
  150. method : 'GET'
  151. }).success(function(data) {
  152. if(data.code == 0){
  153. $scope.schoolList = data.result;
  154. }
  155. }).error(function() {
  156. });
  157. }
  158. $scope.refreshCurSchool = function(){
  159. $scope.schoolInfo.current_school_id = null;
  160. $scope.myPromise = $http({
  161. url : $rootScope.host_url + '/frame/school/' + $scope.schoolInfo.current_school_city,
  162. method : 'GET'
  163. }).success(function(data) {
  164. if(data.code == 0){
  165. $scope.curSchoolList = data.result;
  166. }
  167. }).error(function() {
  168. });
  169. }
  170. });