prescription-tabs.js 4.9 KB

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