123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- app.controller('AppointmentInfoCtrl', [ '$rootScope', '$scope', '$stateParams', function($rootScope, $scope, $stateParams) {
- if ($stateParams == undefined || $stateParams.agent_id == undefined) {
- $.alert('参数错误,无法获取考点详细信息', function() {
- $rootScope.goWechat();
- });
- return;
- }
- $scope.curStep = 'list';
- $scope.getAgent = function() {
- $rootScope.ajaxRequest({
- url : '../enrol/std/appointment/group.htm',
- data : {
- agent_id : $stateParams.agent_id
- }
- }, function(response) {
- var groupArray = [];
- var subjectMap = {};
- for (var i = 0; i < response.array.length; i++) {
- var subject = response.array[i];
- var has = false;
- for (var v = 0; v < groupArray.length; v++) {
- if (groupArray[v].ly_group_id == subject.ly_group_id) {
- has = true;
- break;
- }
- }
- if (!has) {
- groupArray.push(subject);
- subjectMap['SubjectArray_' + subject.ly_group_id] = [];
- }
- subjectMap['SubjectArray_' + subject.ly_group_id].push(subject);
- }
- $scope.GroupArray = groupArray;
- $scope.SubjectMap = subjectMap;
- $scope.curStep = 'list';
- });
- }
- $scope.goStep = function(step) {
- $scope.curStep = step
- }
- $scope.goAppointment = function(g) {
- if (g.ly_exam_date != undefined)
- return;
- $rootScope.ajaxRequest({
- url : '../enrol/std/appointment/date.htm',
- data : {
- ly_group_id : g.ly_group_id
- }
- }, function(response) {
- var array = [];
- $scope.currentGroup = g;
- for (var i = 0; i < response.array.length; i++) {
- var date = response.array[i];
- $scope.prepareData(date);
- if (date.std_total > 0)
- array.push(date);
- }
- $scope.DateArray = array;
- $scope.curStep = 'date';
- });
- }
- $scope.goDate = function(date) {
- $scope.curDate = date;
- if ($scope.currentGroup.appointment_type == 'DateOrder' || $scope.currentGroup.appointment_type == 'DateRandom') {
- // 按天预约的
- $.confirm("该面试项目按天预约,面试当天的时段由系统安排,确定要预约【" + date.ly_exam_date + "】吗?", function() {
- // 点击确认后的回调函数
- $scope.saveAppointment(undefined,undefined);
- }, function() {
- // 点击取消后的回调函数
- });
- } else if ($scope.currentGroup.appointment_type == 'HalfdayOrder' || $scope.currentGroup.appointment_type == 'HalfdayRandom') {
- // 半天的
- $rootScope.ajaxRequest({
- url : '../enrol/std/appointment/timetype.htm',
- data : {
- agent_id : $stateParams.agent_id,
- ly_group_id : $scope.currentGroup.ly_group_id,
- exam_date : date.ly_exam_date
- }
- }, function(response) {
- var array = [];
- for (var i = 0; i < response.array.length; i++) {
- var date = response.array[i];
- $scope.prepareData(date);
- if (date.std_total > 0)
- array.push(date);
- }
- $scope.TimeTypeArray = array;
- $scope.curStep = 'timetype';
- });
- } else {
- // 按照时段预约
- $rootScope.ajaxRequest({
- url : '../enrol/std/appointment/time.htm',
- data : {
- agent_id : $stateParams.agent_id,
- ly_group_id : $scope.currentGroup.ly_group_id,
- exam_date : date.ly_exam_date
- }
- }, function(response) {
- var array = [];
- for (var i = 0; i < response.array.length; i++) {
- var date = response.array[i];
- $scope.prepareData(date);
- if (date.appointment_status != 'Active')
- date.arrange_flag = false;
- if (date.std_total > 0)
- array.push(date);
- }
- $scope.TimeArray = array;
- $scope.curStep = 'time';
- });
- }
- }
- $scope.goTimeType = function(time) {
- // 按天预约的
- $.confirm("该面试项目按半天预约,面试的具体时段由系统安排,确定要预约【" + date.ly_exam_date + "】的【" + $rootScope.getTimeName(time.time_type) + "】时段吗?", function() {
- // 点击确认后的回调函数
- $scope.saveAppointment(undefined,time.time_type);
- }, function() {
- // 点击取消后的回调函数
- });
- }
- $scope.goTime = function(time) {
- // 按天预约的
- $.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() {
- // 点击确认后的回调函数
- $scope.saveAppointment(time.appointment_id,undefined);
- }, function() {
- // 点击取消后的回调函数
- });
- }
- $scope.saveAppointment = function(appointment_id, time_type) {
- $.showLoading('正在提交预约申请,请稍候');
- $rootScope.ajaxRequest({
- url : '../enrol/std/appointment/save.htm',
- data : {
- agent_id : $stateParams.agent_id,
- ly_group_id : $scope.currentGroup.ly_group_id,
- exam_date : $scope.curDate.ly_exam_date,
- appointment_id : appointment_id,
- time_type : time_type
- }
- }, function(response) {
- $scope.curStep = 'success';
- });
- }
- $scope.prepareData = function(date) {
- if ($scope.currentGroup.province_flag == 'Active') {
- if ($rootScope.isProvinceStd()) {
- date.std_total = date.province_total;
- date.arrange_total = date.arrange_province_total;
- } else {
- date.std_total = date.outside_total;
- date.arrange_total = date.arrange_outside_total;
- }
- } else {
- date.std_total = date.country_total;
- date.arrange_total = date.arrange_country_total;
- }
- if (date.arrange_total == undefined)
- date.arrange_total = 0;
- if (date.std_total > 0) {
- if (date.std_total - date.arrange_total > 0) {
- date.arrange_flag = true;
- } else {
- date.arrange_flag = false;
- }
- }
- }
- $scope.getAgent();
- } ])
|