prescription-tabs.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. var request = getRequest(),
  2. tab = request.tab || 0,
  3. sessionId = request.sessionId, //续方咨询的sessionId 格式: 居民code+咨询code+咨询类型( 8 )
  4. patiCode = request.patiCode || '',
  5. consultCode,
  6. prescriptionCode = request.code || '',
  7. teamCode = request.teamCode || '',
  8. jwCode; //基卫那边存储的原处方的code
  9. var docInfo = window.localStorage.getItem("docInfo");
  10. docInfo = JSON.parse(docInfo);
  11. var fromTabIdx = tab; // 记录前一个Tab索引,用于返回按钮
  12. //初始tab的链接
  13. var links = [{
  14. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  15. name: '咨询',
  16. class: ''
  17. },{
  18. url: 'prescription-detail.html?from=tab&code='+prescriptionCode,
  19. name: '续方详情',
  20. class: ''
  21. },{
  22. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  23. name: '订单跟踪',
  24. class: '',
  25. },{
  26. url: 'about:blank',
  27. name: '体征记录',
  28. class: 'hidden'
  29. },{
  30. url: 'about:blank',
  31. name: '检查检验',
  32. class: ''
  33. },{
  34. url: 'jw-prescription-info.html?from=tab&code='+jwCode+'&patient='+patiCode,
  35. name: '诊断/处方',
  36. class: ''
  37. },{
  38. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  39. name: '历史续方',
  40. class: ''
  41. }];
  42. $(function(){
  43. if(!prescriptionCode){
  44. //没有续方的code,就从咨询中获取对应的code
  45. getPrescriptionInfo();
  46. }else{
  47. //有续方的code,通过code获得续方详情
  48. getPrescriptionInfoByCode();
  49. }
  50. })
  51. function initPage(){
  52. if(!(docInfo.isLeader == '1')){
  53. links[0].class="hidden";
  54. }
  55. links[tab].class="active";
  56. var html = template('tab_tmp', {list: links});
  57. $("#tabs").append(html);
  58. parent.document.getElementById('main').src = links[tab].url;
  59. $("#tabs").on('click', 'a', function(){
  60. var $this = $(this),
  61. $li = $this.parent();
  62. fromTabIdx = $("#tabs li.active").index();
  63. $li.siblings().removeClass("active");
  64. $li.addClass("active");
  65. tab = $this.data('index');
  66. parent.document.getElementById('main').src = links[tab].url+'&from=tab';
  67. })
  68. }
  69. function toPrePrescriptionTab() {
  70. if(fromTabIdx!=null && fromTabIdx != undefined) {
  71. $("#tabs li").eq(fromTabIdx).find('a').trigger('click')
  72. }
  73. }
  74. top.toPrePrescriptionTab = toPrePrescriptionTab
  75. function getPrescriptionInfo(){
  76. patiCode = sessionId.split("_")[0];
  77. consultCode = sessionId.split("_")[1];
  78. var params = { consult: consultCode};
  79. consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
  80. if(res.status == 200){
  81. prescriptionCode = res.data.code;
  82. jwCode = res.data.jwCode;
  83. updateLinkInfo();
  84. if(res.data.status < 50){ //支付成功前不会有订单记录
  85. links[2].class="hidden";
  86. }
  87. initPage();
  88. }else{
  89. toastr && toastr.warning(res.msg);
  90. }
  91. });
  92. }
  93. function getPrescriptionInfoByCode(){
  94. var params = {
  95. code: prescriptionCode,
  96. type: docInfo.isLeader == '1' ? 1 : 2
  97. };
  98. consultingAPI.getPrescriptionInfoByCode({data: params}).then(function(res){
  99. if(res.status == 200){
  100. patiCode = res.data.patient.code;
  101. jwCode = res.data.prescription.jwCode;
  102. updateLinkInfo();
  103. if(res.data.prescription.status < 50){ //支付成功前不会有订单记录
  104. links[2].class="hidden";
  105. }
  106. initPage();
  107. }else{
  108. toastr && toastr.warning(res.msg);
  109. }
  110. });
  111. }
  112. function updateLinkInfo(){
  113. links = [{
  114. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  115. name: '咨询',
  116. class: ''
  117. },{
  118. url: 'prescription-detail.html?from=tab&code='+prescriptionCode,
  119. name: '续方详情',
  120. class: ''
  121. },{
  122. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  123. name: '订单跟踪',
  124. class: '',
  125. },{
  126. url: 'about:blank',
  127. name: '体征记录',
  128. class: 'hidden'
  129. },{
  130. url: 'about:blank',
  131. name: '检查检验',
  132. class: ''
  133. },{
  134. url: 'jw-prescription-info.html?from=tab&code='+jwCode+'&patient='+patiCode,
  135. name: '诊断/处方',
  136. class: ''
  137. },{
  138. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  139. name: '历史续方',
  140. class: ''
  141. }];
  142. console.log(links);
  143. }