appointment_info.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. app.controller('AppointmentInfoCtrl', [ '$rootScope', '$scope', '$stateParams', function($rootScope, $scope, $stateParams) {
  2. if ($stateParams == undefined || $stateParams.agent_id == undefined) {
  3. $.alert('参数错误,无法获取考点详细信息', function() {
  4. $rootScope.goWechat();
  5. });
  6. return;
  7. }
  8. $scope.curStep = 'list';
  9. $scope.getAgent = function() {
  10. $rootScope.ajaxRequest({
  11. url : '../enrol/std/appointment/group.htm',
  12. data : {
  13. agent_id : $stateParams.agent_id
  14. }
  15. }, function(response) {
  16. var groupArray = [];
  17. var subjectMap = {};
  18. for (var i = 0; i < response.array.length; i++) {
  19. var subject = response.array[i];
  20. var has = false;
  21. for (var v = 0; v < groupArray.length; v++) {
  22. if (groupArray[v].ly_group_id == subject.ly_group_id) {
  23. has = true;
  24. break;
  25. }
  26. }
  27. if (!has) {
  28. groupArray.push(subject);
  29. subjectMap['SubjectArray_' + subject.ly_group_id] = [];
  30. }
  31. subjectMap['SubjectArray_' + subject.ly_group_id].push(subject);
  32. }
  33. $scope.GroupArray = groupArray;
  34. $scope.SubjectMap = subjectMap;
  35. $scope.curStep = 'list';
  36. });
  37. }
  38. $scope.goStep = function(step) {
  39. $scope.curStep = step
  40. }
  41. $scope.goAppointment = function(g) {
  42. if (g.ly_exam_date != undefined)
  43. return;
  44. $rootScope.ajaxRequest({
  45. url : '../enrol/std/appointment/date.htm',
  46. data : {
  47. ly_group_id : g.ly_group_id
  48. }
  49. }, function(response) {
  50. var array = [];
  51. $scope.currentGroup = g;
  52. for (var i = 0; i < response.array.length; i++) {
  53. var date = response.array[i];
  54. $scope.prepareData(date);
  55. if (date.std_total > 0)
  56. array.push(date);
  57. }
  58. $scope.DateArray = array;
  59. $scope.curStep = 'date';
  60. });
  61. }
  62. $scope.goDate = function(date) {
  63. $scope.curDate = date;
  64. if ($scope.currentGroup.appointment_type == 'DateOrder' || $scope.currentGroup.appointment_type == 'DateRandom') {
  65. // 按天预约的
  66. $.confirm("该面试项目按天预约,面试当天的时段由系统安排,确定要预约【" + date.ly_exam_date + "】吗?", function() {
  67. // 点击确认后的回调函数
  68. $scope.saveAppointment(undefined,undefined);
  69. }, function() {
  70. // 点击取消后的回调函数
  71. });
  72. } else if ($scope.currentGroup.appointment_type == 'HalfdayOrder' || $scope.currentGroup.appointment_type == 'HalfdayRandom') {
  73. // 半天的
  74. $rootScope.ajaxRequest({
  75. url : '../enrol/std/appointment/timetype.htm',
  76. data : {
  77. agent_id : $stateParams.agent_id,
  78. ly_group_id : $scope.currentGroup.ly_group_id,
  79. exam_date : date.ly_exam_date
  80. }
  81. }, function(response) {
  82. var array = [];
  83. for (var i = 0; i < response.array.length; i++) {
  84. var date = response.array[i];
  85. $scope.prepareData(date);
  86. if (date.std_total > 0)
  87. array.push(date);
  88. }
  89. $scope.TimeTypeArray = array;
  90. $scope.curStep = 'timetype';
  91. });
  92. } else {
  93. // 按照时段预约
  94. $rootScope.ajaxRequest({
  95. url : '../enrol/std/appointment/time.htm',
  96. data : {
  97. agent_id : $stateParams.agent_id,
  98. ly_group_id : $scope.currentGroup.ly_group_id,
  99. exam_date : date.ly_exam_date
  100. }
  101. }, function(response) {
  102. var array = [];
  103. for (var i = 0; i < response.array.length; i++) {
  104. var date = response.array[i];
  105. $scope.prepareData(date);
  106. if (date.appointment_status != 'Active')
  107. date.arrange_flag = false;
  108. if (date.std_total > 0)
  109. array.push(date);
  110. }
  111. $scope.TimeArray = array;
  112. $scope.curStep = 'time';
  113. });
  114. }
  115. }
  116. $scope.goTimeType = function(time) {
  117. // 按天预约的
  118. $.confirm("该面试项目按半天预约,面试的具体时段由系统安排,确定要预约【" + date.ly_exam_date + "】的【" + $rootScope.getTimeName(time.time_type) + "】时段吗?", function() {
  119. // 点击确认后的回调函数
  120. $scope.saveAppointment(undefined,time.time_type);
  121. }, function() {
  122. // 点击取消后的回调函数
  123. });
  124. }
  125. $scope.goTime = function(time) {
  126. // 按天预约的
  127. $.confirm("<table><tr><td>预约项目:【" + $scope.currentGroup.group_name + "】</td></tr><tr><td>预约日期:【" + time.ly_exam_date + "】</td></tr><tr><td>预约时段:【" + time.group_time.time_name + "】</td></tr></table>", "请确定预约信息", function() {
  128. // 点击确认后的回调函数
  129. $scope.saveAppointment(time.appointment_id,undefined);
  130. }, function() {
  131. // 点击取消后的回调函数
  132. });
  133. }
  134. $scope.saveAppointment = function(appointment_id, time_type) {
  135. $.showLoading('正在提交预约申请,请稍候');
  136. $rootScope.ajaxRequest({
  137. url : '../enrol/std/appointment/save.htm',
  138. data : {
  139. agent_id : $stateParams.agent_id,
  140. ly_group_id : $scope.currentGroup.ly_group_id,
  141. exam_date : $scope.curDate.ly_exam_date,
  142. appointment_id : appointment_id,
  143. time_type : time_type
  144. }
  145. }, function(response) {
  146. $scope.curStep = 'success';
  147. });
  148. }
  149. $scope.prepareData = function(date) {
  150. if ($scope.currentGroup.province_flag == 'Active') {
  151. if ($rootScope.isProvinceStd()) {
  152. date.std_total = date.province_total;
  153. date.arrange_total = date.arrange_province_total;
  154. } else {
  155. date.std_total = date.outside_total;
  156. date.arrange_total = date.arrange_outside_total;
  157. }
  158. } else {
  159. date.std_total = date.country_total;
  160. date.arrange_total = date.arrange_country_total;
  161. }
  162. if (date.arrange_total == undefined)
  163. date.arrange_total = 0;
  164. if (date.std_total > 0) {
  165. if (date.std_total - date.arrange_total > 0) {
  166. date.arrange_flag = true;
  167. } else {
  168. date.arrange_flag = false;
  169. }
  170. }
  171. }
  172. $scope.getAgent();
  173. } ])