prescription-tabs.js 5.0 KB

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