appointmentDoctorList.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. (function (c) {
  2. config.init();
  3. var startDate = (new Date()).pattern('yyyy-MM-dd');//起始时间
  4. var endDate = ( new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * 8) ).pattern('yyyy-MM-dd');//结束时间
  5. var selectedDate = window.Fx.getUrlParam('date') || (new Date()).pattern('yyyy-MM-dd');//选择的时间
  6. var a = {
  7. hospitalId: Fx.getUrlParam("hospitalId"),
  8. deptId: Fx.getUrlParam("deptId"),
  9. startDate: startDate,
  10. endDate: endDate
  11. };
  12. //顶部月份
  13. var month = (new Date()).pattern('M');
  14. var e_month = '';
  15. switch (month){
  16. case '1':e_month = 'Jan';break;
  17. case '2':e_month = 'Feb';break;
  18. case '3':e_month = 'Web';break;
  19. case '4':e_month = 'Apr';break;
  20. case '5':e_month = 'May';break;
  21. case '6':e_month = 'Jun';break;
  22. case '7':e_month = 'Jly';break;
  23. case '8':e_month = 'Aug';break;
  24. case '9':e_month = 'Sept';break;
  25. case '10':e_month = 'Oct';break;
  26. case '11':e_month = 'Nov';break;
  27. case '12':e_month = 'Dec';break;
  28. default : e_month = 0;
  29. }
  30. c('#month').html('');
  31. c('#month').append('<span>'+month+'</span>' +
  32. '<span>月</span>' +
  33. '<div>'+e_month+'</div>');
  34. //请求顶部日期
  35. c.ajax({
  36. type: "get",
  37. url: window.apiUrl+"getEnableTime.php?day=8&callback=jsonp",
  38. dataType: "jsonp",
  39. data: c.extend(window.hzAPI.getToken(), a),
  40. jsonp: "callback",
  41. async: false,
  42. crossDomain: true,
  43. complete: window.hzAPI.dialog(false,window.hzAPI.options.timeout,'数据请求中,请稍后'),
  44. success:function (data) {
  45. // console.log(data);
  46. c('.headdate .right').html('');
  47. var ulStr = '';
  48. //生成顶部日期
  49. for(var i in data){
  50. for(var j in data[i]){
  51. if( data[i][j] && j == selectedDate ){
  52. ulStr += '<li name="'+j+'" class="active has-appointment">' +
  53. '<div class="week">'+new Date(j).pattern('E')+'</div>' +
  54. '<div class="day">'+j.split('-')[2]+'</div>' +
  55. '</li>';
  56. }else if( data[i][j]){
  57. ulStr += '<li name="'+j+'" class="has-appointment">' +
  58. '<div class="week">'+new Date(j).pattern('E')+'</div>' +
  59. '<div class="day">'+j.split('-')[2]+'</div>' +
  60. '</li>';
  61. }else if( !data[i][j] && j == selectedDate){
  62. ulStr += '<li name="'+j+'" class="active">' +
  63. '<div class="week">'+new Date(j).pattern('E')+'</div>' +
  64. '<div class="day">'+j.split('-')[2]+'</div>' +
  65. '</li>';
  66. }else {
  67. ulStr += '<li name="'+j+'">' +
  68. '<div class="week">'+new Date(j).pattern('E')+'</div>' +
  69. '<div class="day">'+j.split('-')[2]+'</div>' +
  70. '</li>';
  71. }
  72. }
  73. }
  74. c('.headdate .right').html(ulStr);
  75. //绑定顶部事件
  76. c('.headdate .right li').click(function (e) {
  77. window.location.href = window.location.href.split('&date')[0]+'&date='+c(e.currentTarget).attr('name');
  78. });
  79. },
  80. error: function (error) {
  81. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "网络链接失败");
  82. },
  83. timeout: 9000
  84. });
  85. var b = {
  86. hospitalId: Fx.getUrlParam("hospitalId"),
  87. deptId: Fx.getUrlParam("deptId"),
  88. startDate: startDate,
  89. endDate: startDate,
  90. callback: 'callback'
  91. };
  92. if(window.Fx.getUrlParam('date')){
  93. b = {
  94. hospitalId: Fx.getUrlParam("hospitalId"),
  95. deptId: Fx.getUrlParam("deptId"),
  96. startDate: Fx.getUrlParam("date"),
  97. endDate: Fx.getUrlParam("date"),
  98. callback: 'callback'
  99. }
  100. }
  101. //请求医生
  102. c.ajax({
  103. type: "get",
  104. url: window.apiUrl+"getRegInfo.php",
  105. dataType: "jsonp",
  106. data: c.extend(window.hzAPI.getToken(), b),
  107. jsonp: "callback",
  108. async: false,
  109. crossDomain: true,
  110. complete: window.hzAPI.dialog(false,window.hzAPI.options.timeout,'数据请求中,请稍后'),
  111. success:function (data) {
  112. //todo 返回了false,不允许频繁请求接口
  113. //初始化内容
  114. c('#morning').html('');
  115. c('#afternoon').html('');
  116. if(data!=false && data.Schedules){
  117. var doctorList = data.Schedules.Schedule;
  118. for(var i in doctorList){
  119. var docinfo = doctorList[i];
  120. var docStr = '',btnStr = '';
  121. if(docinfo.AvailableLeftNum > 0){
  122. btnStr = '<button id="'+docinfo.DoctorCode+'" class="btn-green">可预约</button>';
  123. }else{
  124. btnStr = '<button type="button" disabled>已满</button>';
  125. }
  126. docStr = '<li class="doctor">' +
  127. '<div class="avatar" style="overflow: hidden;">' +
  128. '<img src="' + docinfo.ImageUrl + '" alt="">' +
  129. '</div>' +
  130. '<div class="body">' +
  131. '<div class="docname">' + docinfo.DoctorName + '</div>' +
  132. '<div class="doctitle">' + docinfo.DoctorTitle + '</div>' +
  133. '</div>' +
  134. '<div class="right">' + btnStr
  135. '</div>' +
  136. '</li>';
  137. //下午
  138. if(doctorList[i].SessionCode == 'X'){
  139. c('#afternoon').append(docStr);
  140. } else if (doctorList[i].SessionCode == 'S') {
  141. c('#morning').append(docStr);
  142. }
  143. }
  144. }
  145. //添加提示文案
  146. if(c('#afternoon li').length<1){
  147. c('#afternoon').append('<li style="height: '+c('#afternoon').parent().height()+'px;line-height: '+c('#afternoon').parent().height()+'px;text-align: center;">暂无排班记录</li>');
  148. }
  149. //添加提示文案
  150. if(c('#morning li').length<1){
  151. c('#morning').append('<li style="height: '+c('#morning').parent().height()+'px;line-height: '+c('#morning').parent().height()+'px;text-align: center;">暂无排版记录</li>');
  152. }
  153. c('button').click(function (e) {
  154. window.location.href = window.location.origin + window.location.pathname.replace('appointmentDoctorList','doctorWho') + '?hospitalId=' +
  155. window.Fx.getUrlParam('hospitalId') + '&deptId=' + window.Fx.getUrlParam('deptId') +
  156. '&doctorId=' + e.currentTarget.id +'&date=' + selectedDate;
  157. });
  158. },
  159. error: function (error) {
  160. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "网络链接失败");
  161. },
  162. timeout: 9000
  163. });
  164. // hzAPI.getData(window.apiUrl+"?c=api&a=getRegInfo", a, ".right");
  165. })(Zepto);