prescription-tabs.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 = request.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: 'jianchajianyan.html?from=tab&patient='+patiCode,
  31. name: '检查检验',
  32. class: ''
  33. },{
  34. url: 'jw-prescription-list.html?from=tab&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. links[tab].class="active";
  53. var html = template('tab_tmp', {list: links});
  54. $("#tabs").append(html);
  55. parent.document.getElementById('main').src = links[tab].url;
  56. $("#tabs").on('click', 'a', function(){
  57. var $this = $(this),
  58. $li = $this.parent();
  59. fromTabIdx = $("#tabs li.active").index();
  60. $li.siblings().removeClass("active");
  61. $li.addClass("active");
  62. tab = $this.data('index');
  63. parent.document.getElementById('main').src = links[tab].url+'&from=tab';
  64. })
  65. }
  66. function toPrePrescriptionTab() {
  67. if(fromTabIdx!=null && fromTabIdx != undefined) {
  68. $("#tabs li").eq(fromTabIdx).find('a').trigger('click')
  69. }
  70. }
  71. top.toPrePrescriptionTab = toPrePrescriptionTab
  72. function getPrescriptionInfo(){
  73. patiCode = sessionId.split("_")[0];
  74. consultCode = sessionId.split("_")[1];
  75. var params = { consult: consultCode};
  76. consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
  77. if(res.status == 200){
  78. prescriptionCode = res.data.code;
  79. jwCode = res.data.jwCode;
  80. updateLinkInfo();
  81. if(res.data.status < 50){ //支付成功前不会有订单记录
  82. links[2].class="hidden";
  83. }
  84. initPage();
  85. }else{
  86. toastr && toastr.warning(res.msg);
  87. }
  88. });
  89. }
  90. function getPrescriptionInfoByCode(){
  91. var params = {
  92. code: prescriptionCode,
  93. type: docInfo.isLeader == '1' ? 1 : 2
  94. };
  95. consultingAPI.getPrescriptionInfoByCode({data: params}).then(function(res){
  96. if(res.status == 200){
  97. patiCode = res.data.patient.code;
  98. jwCode = res.data.prescription.jwCode;
  99. consultCode = res.data.prescription.consult;
  100. sessionId = patiCode + '_' + consultCode+'_8';
  101. updateLinkInfo();
  102. //如果不是该续方所在团队的团队长,则不可以显示咨询tab
  103. if(res.data.prescription.doctor != docInfo.code){
  104. links[0].class="hidden";
  105. }
  106. if(res.data.prescription.status < 50){ //支付成功前不会有订单记录
  107. links[2].class="hidden";
  108. }
  109. initPage();
  110. }else{
  111. toastr && toastr.warning(res.msg);
  112. }
  113. });
  114. }
  115. function updateLinkInfo(){
  116. links = [{
  117. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  118. name: '咨询',
  119. class: ''
  120. },{
  121. url: 'prescription-detail.html?from=tab&code='+prescriptionCode,
  122. name: '续方详情',
  123. class: ''
  124. },{
  125. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  126. name: '订单跟踪',
  127. class: '',
  128. },{
  129. url: 'about:blank',
  130. name: '体征记录',
  131. class: 'hidden'
  132. },{
  133. url: 'jianchajianyan.html?from=tab&patient='+patiCode,
  134. name: '检查检验',
  135. class: ''
  136. },{
  137. url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
  138. name: '诊断/处方',
  139. class: ''
  140. },{
  141. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  142. name: '历史续方',
  143. class: ''
  144. }];
  145. console.log(links);
  146. }