prescription-tabs.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. fv_id, //随访的id
  11. fv_class; //随访的类别
  12. var docInfo = window.localStorage.getItem("docInfo");
  13. docInfo = JSON.parse(docInfo);
  14. var fromTabIdx = request.fromTabIdx; // 记录前一个Tab索引,用于返回按钮
  15. var reqLinkList = []; //记录切换tab时访问的路径集合,方便返回操作时,不修改之前请求路径的参数
  16. //初始tab的链接
  17. var links = [{
  18. index: 1,
  19. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  20. name: '咨询',
  21. class: ''
  22. },{
  23. index: 2,
  24. url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
  25. name: '续方详情',
  26. class: ''
  27. },{
  28. index: 3,
  29. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  30. name: '订单跟踪',
  31. class: '',
  32. },{
  33. index: 4,
  34. url: 'body-record.html?from=tab&patiCode='+patiCode,
  35. name: '体征记录',
  36. class: ''
  37. },{
  38. index: 5,
  39. url: 'jianchajianyan.html?from=tab&patient='+patiCode,
  40. name: '检查检验',
  41. class: ''
  42. },{
  43. index: 6,
  44. url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
  45. name: '诊断/处方',
  46. class: ''
  47. },{
  48. index: 7,
  49. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  50. name: '历史续方',
  51. class: ''
  52. },{
  53. index: 8,
  54. url: 'fv-survey.html?from=tab&fv_id='+fv_id+'&code='+prescriptionCode,
  55. name: '问卷调查',
  56. class: ''
  57. },{
  58. index: 9,
  59. url: 'page/followup/followup-main.html?fv_id='+fv_id+'&patiCode='+patiCode+'&fv_class='+fv_class+'&prescriptionCode='+prescriptionCode,
  60. name: '随访记录',
  61. class: ''
  62. }];
  63. $(function(){
  64. setTitle(patiName+"续方咨询");
  65. if(!prescriptionCode){
  66. //没有续方的code,就从咨询中获取对应的code
  67. //这种情况下,患者的签约团队一定是医生所在的团队的id
  68. teamCode = docInfo.adminTeamCode;
  69. getPrescriptionInfo();
  70. }else{
  71. //有续方的code,通过code获得续方详情
  72. getPrescriptionInfoByCode();
  73. }
  74. })
  75. // 判断是否有体征设备
  76. function judgeDeviceFn() {
  77. var recordDevice = {patient: patiCode, page: 1, pagesize: 1};
  78. bodyRecordApis.getPatientDevice({data: recordDevice}).then(function(res){
  79. if(res.status == 200){
  80. if(res.data.length == 0){
  81. //没有绑定设备
  82. links[3].class="hidden";
  83. initPage();
  84. } else {
  85. judgeRecordFn()
  86. }
  87. }else{
  88. showWarningMsg(res.msg)
  89. }
  90. })
  91. }
  92. // 判断是否有体征记录
  93. function judgeRecordFn() {
  94. var recordData = {patient: patiCode};
  95. bodyRecordApis.getBodyRecoredLast({data: recordData}).then(function(res){
  96. if(res.status == 200){
  97. if(!res.data.xt && !res.data.xy) {
  98. links[3].class="hidden";
  99. }
  100. initPage();
  101. }else{
  102. showWarningMsg(res.msg)
  103. }
  104. })
  105. }
  106. function initPage(){
  107. links[tab].class="active";
  108. var html = template('tab_tmp', {list: links});
  109. $("#tabs").append(html);
  110. parent.document.getElementById('main').src = links[tab].url;
  111. reqLinkList.push(links[tab].url);
  112. $("#tabs").on('click', 'a', function(){
  113. var $this = $(this),
  114. $li = $this.parent();
  115. if($this.text() == "随访记录"){
  116. tab = $this.data('index');
  117. top.layer.open({
  118. type: 2,
  119. title: '随访记录',
  120. shadeClose: false,
  121. // shade: false,
  122. // maxmin: true, //开启最大化最小化按钮
  123. area: ['800px', '570px'],
  124. content: links[tab].url
  125. });
  126. return false;
  127. }else{
  128. fromTabIdx = $("#tabs li.active").index();
  129. $li.siblings().removeClass("active");
  130. $li.addClass("active");
  131. tab = $this.data('index');
  132. reqLinkList.push(links[tab].url+'&from=tab&fromTabIdx='+fromTabIdx);
  133. var url = links[tab].url+'&from=tab&fromTabIdx='+fromTabIdx;
  134. }
  135. parent.document.getElementById('main').src = url;
  136. })
  137. }
  138. function toPrePrescriptionTab() {
  139. //页面返回的操作不做trigger操作
  140. var oldUrl = reqLinkList.pop();
  141. var fromTabIdx = oldUrl.split("fromTabIdx=")[1];
  142. var length = reqLinkList.length;
  143. if(length>0){
  144. //应跳转去的页面是
  145. // var url = reqLinkList[reqLinkList.length -1];
  146. if(fromTabIdx){
  147. $("#tabs li").removeClass("active");
  148. $("#tabs li").eq(fromTabIdx).addClass("active");
  149. }
  150. }
  151. history.go(-1);
  152. }
  153. top.toPrePrescriptionTab = toPrePrescriptionTab;
  154. //跳转去置顶的tab
  155. function gotoPrescriptionTab(index){
  156. console.log(index);
  157. var url = links[index -1].url;
  158. console.log(url);
  159. $("#tabs li").removeClass("active");
  160. $("#tabs li").eq(index -1).addClass("active");
  161. reqLinkList.push(url);
  162. parent.document.getElementById('main').src = url;
  163. }
  164. parent.gotoPrescriptionTab = gotoPrescriptionTab;
  165. function getPrescriptionInfo(){
  166. patiCode = sessionId.split("_")[0];
  167. consultCode = sessionId.split("_")[1];
  168. var params = { consult: consultCode};
  169. consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
  170. if(res.status == 200){
  171. prescriptionCode = res.data.code;
  172. jwCode = res.data.jwCode;
  173. var followup = res.data.followup;
  174. if(followup && followup !="null"){
  175. followup = JSON.parse(followup);
  176. fv_id = followup.id;
  177. fv_class = followup.followupClass;
  178. }
  179. updateLinkInfo();
  180. if(res.data.status < 50){ //支付成功前不会有订单记录
  181. links[2].class="hidden";
  182. }
  183. if(!followup || followup == "null"){
  184. links[7].class="hidden";
  185. links[8].class="hidden";
  186. }
  187. judgeDeviceFn();
  188. }else{
  189. showWarningMsg(res.msg);
  190. }
  191. });
  192. }
  193. function getPrescriptionInfoByCode(){
  194. var params = {
  195. code: prescriptionCode,
  196. type: docInfo.isLeader == '1' ? 1 : 2
  197. };
  198. consultingAPI.getPrescriptionInfoByCode({data: params}).then(function(res){
  199. if(res.status == 200){
  200. patiCode = res.data.patient.code;
  201. jwCode = res.data.prescription.jwCode;
  202. consultCode = res.data.prescription.consult;
  203. sessionId = patiCode + '_' + consultCode+'_8';
  204. //获得随访的信息
  205. if(res.data.followup && res.data.followup != "null"){
  206. fv_id = res.data.followup.id;
  207. fv_class = res.data.followup.followupClass;
  208. }
  209. updateLinkInfo();
  210. //如果不是该续方所在团队的团队长,则不可以显示咨询tab,也不显示随访tab
  211. if(res.data.prescription.doctor != docInfo.code){
  212. links[0].class="hidden";
  213. links[7].class="hidden";
  214. links[8].class="hidden";
  215. }
  216. if(!res.data.followup){
  217. links[7].class="hidden";
  218. links[8].class="hidden";
  219. }
  220. if(res.data.prescription.status < 50){ //支付成功前不会有订单记录
  221. links[2].class="hidden";
  222. }
  223. judgeDeviceFn();
  224. }else{
  225. showWarningMsg(res.msg);
  226. }
  227. });
  228. }
  229. function updateLinkInfo(){
  230. links = [{
  231. index: 1,
  232. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  233. name: '咨询',
  234. class: ''
  235. },{
  236. index: 2,
  237. url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
  238. name: '续方详情',
  239. class: ''
  240. },{
  241. index: 3,
  242. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  243. name: '订单跟踪',
  244. class: '',
  245. },{
  246. index: 4,
  247. url: 'body-record.html?from=tab&patiCode='+patiCode,
  248. name: '体征记录',
  249. class: ''
  250. },{
  251. index: 5,
  252. url: 'jianchajianyan.html?from=tab&patient='+patiCode,
  253. name: '检查检验',
  254. class: ''
  255. },{
  256. index: 6,
  257. url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
  258. name: '诊断/处方',
  259. class: ''
  260. },{
  261. index: 7,
  262. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  263. name: '历史续方',
  264. class: ''
  265. },{
  266. index: 8,
  267. url: 'fv-survey.html?from=tab&fv_id='+fv_id+'&code='+prescriptionCode,
  268. name: '问卷调查',
  269. class: ''
  270. },{
  271. index: 9,
  272. url: 'page/followup/followup-main.html?fv_id='+fv_id+'&patiCode='+patiCode+'&fv_class='+fv_class+'&prescriptionCode='+prescriptionCode,
  273. name: '随访记录',
  274. class: ''
  275. }];
  276. }