prescription-tabs.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. //初始tab的链接
  12. var links = [{
  13. url: 'prescription-consulting.html?sessionId='+sessionId,
  14. name: '咨询',
  15. class: ''
  16. },{
  17. url: 'about:blank',
  18. name: '续方详情',
  19. class: ''
  20. },{
  21. url: 'order-tracking.html?code='+prescriptionCode,
  22. name: '订单跟踪',
  23. class: '',
  24. },{
  25. url: 'about:blank',
  26. name: '体征记录',
  27. class: 'hidden'
  28. },{
  29. url: 'about:blank',
  30. name: '检查检验',
  31. class: ''
  32. },{
  33. url: 'jw-prescription-info.html?code='+jwCode+'&patient='+patiCode,
  34. name: '诊断/处方',
  35. class: ''
  36. },{
  37. url: 'prescription-list.html?teamCode='+teamCode+'&patient='+patiCode,
  38. name: '历史续方',
  39. class: ''
  40. }];
  41. $(function(){
  42. if(!prescriptionCode){
  43. //没有续方的code,就从咨询中获取对应的code
  44. getPrescriptionInfo();
  45. }else{
  46. //有续方的code,通过code获得续方详情
  47. getPrescriptionInfoByCode();
  48. }
  49. })
  50. function initPage(){
  51. if(!(docInfo.isLeader == '1')){
  52. links[0].class="hidden";
  53. }
  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. $li.siblings().removeClass("active");
  62. $li.addClass("active");
  63. tab = $this.data('index');
  64. parent.document.getElementById('main').src = links[tab].url;
  65. })
  66. }
  67. function getPrescriptionInfo(){
  68. patiCode = sessionId.split("_")[0];
  69. consultCode = sessionId.split("_")[1];
  70. var params = { consult: consultCode};
  71. consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
  72. if(res.status == 200){
  73. prescriptionCode = res.data.code;
  74. jwCode = res.data.jwCode;
  75. updateLinkInfo();
  76. if(res.data.status < 50){ //支付成功前不会有订单记录
  77. links[2].class="hidden";
  78. }
  79. initPage();
  80. }else{
  81. toastr && toastr.warning(res.msg);
  82. }
  83. });
  84. }
  85. function getPrescriptionInfoByCode(){
  86. var params = {
  87. code: prescriptionCode,
  88. type: docInfo.isLeader == '1' ? 1 : 2
  89. };
  90. consultingAPI.getPrescriptionInfoByCode({data: params}).then(function(res){
  91. if(res.status == 200){
  92. patiCode = res.data.patient.code;
  93. jwCode = res.data.prescription.jwCode;
  94. updateLinkInfo();
  95. if(res.data.prescription.status < 50){ //支付成功前不会有订单记录
  96. links[2].class="hidden";
  97. }
  98. initPage();
  99. }else{
  100. toastr && toastr.warning(res.msg);
  101. }
  102. });
  103. }
  104. function updateLinkInfo(){
  105. links = [{
  106. url: 'prescription-consulting.html?sessionId='+sessionId,
  107. name: '咨询',
  108. class: ''
  109. },{
  110. url: 'about:blank',
  111. name: '续方详情',
  112. class: ''
  113. },{
  114. url: 'order-tracking.html?code='+prescriptionCode,
  115. name: '订单跟踪',
  116. class: '',
  117. },{
  118. url: 'about:blank',
  119. name: '体征记录',
  120. class: 'hidden'
  121. },{
  122. url: 'about:blank',
  123. name: '检查检验',
  124. class: ''
  125. },{
  126. url: 'jw-prescription-info.html?code='+jwCode+'&patient='+patiCode,
  127. name: '诊断/处方',
  128. class: ''
  129. },{
  130. url: 'prescription-list.html?teamCode='+teamCode+'&patient='+patiCode,
  131. name: '历史续方',
  132. class: ''
  133. }];
  134. console.log(links);
  135. }