staticInfoOut.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. if(!Promise){
  2. var Promise = require("bluebird");
  3. // Configure
  4. Promise.config({
  5. longStackTraces: true,
  6. warnings: true // note, run node with --trace-warnings to see full stack traces for warnings
  7. })
  8. }
  9. require('../css/staticInfoOut.less')
  10. const {
  11. post,
  12. throttle,
  13. imageUrlPrefix,
  14. config,
  15. getUrlArgObject,
  16. openNewWin
  17. } = require('./promise.js');
  18. const $ = require("jquery");
  19. let showName,noticeName,clinicalPathwayName,showLis=[]
  20. let icond = require('./../images/d.png').replace(/^undefined/g, '')
  21. function getInfomation() {
  22. // var param = {
  23. // "type": getUrlArgObject('type'),
  24. // "name": getUrlArgObject('name'),
  25. // "position": getUrlArgObject('position'),
  26. // "contentTypes":[1,2,3]
  27. // };
  28. var param = {
  29. "type": getUrlArgObject('type'),
  30. "hospitalId": getUrlArgObject('hospitalId'),
  31. "hisName": getUrlArgObject('hisName'),
  32. "hisDetailName": getUrlArgObject('hisDetailName'),
  33. "contentTypes":[1,2,3]
  34. };
  35. showName = param.hisName;
  36. // if (param.type == 5 || param.type == 51) {
  37. // param.type = 12;
  38. // param.name = uname;
  39. // }
  40. post(config.getStaticKnowledgeForHIS, param).then((res) => {
  41. if(res.data.code==='0'){
  42. const data = res.data.data
  43. var str = '';
  44. var anchors = '';
  45. if (!data||data.length===0) {
  46. showEmpty();
  47. return;
  48. }
  49. $(".titleCont .title").html(showName);
  50. showLis=data
  51. for(let i = 0;i < showLis.length;i++){
  52. let tmp = showLis[i]
  53. str+=`<li data-idx="${i}" title="${tmp.name}">${tmp.name}</li>`
  54. }
  55. $(".showWhich ul").html(str)
  56. $(".showWhichSelect").html(showLis[0].name).attr("title",showLis[0].name)
  57. showName = data[0].name
  58. document.title = showName
  59. showInfoSelect()
  60. showInfo(data[0])
  61. $('.content img').bind('contextmenu', function(){
  62. return false
  63. })
  64. }else{
  65. showEmpty();
  66. }
  67. })
  68. }
  69. getInfomation();
  70. function showEmpty(){
  71. const str=`<div class="empty"><img src="../images/empty3.png" alt=""><p>暂无静态知识</p></div>`;
  72. $(".tabBox").html(str).css("border-bottom","none");
  73. $("body").css('background','#fff');
  74. }
  75. function showInfo(data){
  76. var detailList = data.details
  77. var staticKnowList = detailList['静态知识']
  78. var noticeInfo = detailList['注意事项']
  79. var clinicalPathwayInfo = detailList['临床路径']
  80. noticeName = data.noticeName || "注意事项"
  81. clinicalPathwayName = data.clinicalPathwayName || "临床路径"
  82. // $("h1").css({
  83. // "color": "#267FD7",
  84. // "borderBottom": "4px solid #E9E9E9",
  85. // "padding": "0px 60px 50px 0px"
  86. // });
  87. renderTab(detailList)
  88. staticKnowList&&renderContent(staticKnowList,'staticKnowledge')
  89. noticeInfo&&renderContent(noticeInfo,'notice')
  90. clinicalPathwayInfo&&renderContent(clinicalPathwayInfo,'clinicalPathway')
  91. }
  92. function showInfoSelect(){
  93. $('.showWhich li').click(function(){
  94. let idx = $(this).attr('data-idx')
  95. let name = $(this).html(),str=''
  96. showName = showLis[idx].name
  97. document.title = showName
  98. showInfo(showLis[idx])
  99. $('.content .infos').scrollTop(0)
  100. $(".showWhich ul").css("display","none")
  101. $(".showWhichSelect").html(name).attr("title",name)
  102. })
  103. $(".showWhichSelect").click(function(e){
  104. e.stopPropagation()
  105. $(".showWhich ul").slideToggle()
  106. })
  107. $(document).click(function(){
  108. $(".showWhich ul").css("display","none")
  109. })
  110. }
  111. function renderContent(list, contentWrapClassName){
  112. $(`.${contentWrapClassName} .infos`).html('');
  113. $(`.${contentWrapClassName} .anchors ul`).html('');
  114. for (var i = 0; i < list.length; i++) {
  115. var item = list[i];
  116. item.content = item.content&&item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
  117. anchors = '<li><i></i><a href="#' + contentWrapClassName+i +
  118. '">' + item.title + '</a></li><li class="anchor-line"></li>';
  119. str = '<div class="infoBox"><div class="title"> <h2 class="titleH2" id="' + contentWrapClassName+i +
  120. '">'
  121. if (getUrlArgObject('type') == 8) {
  122. str += '【' + item.title + '】'
  123. } else {
  124. str += item.title
  125. }
  126. str += '</h2></div>' +
  127. '<div class="contentWrapper"><pre>' + item.content + '</pre><div></div>';
  128. str = `<div class="infoWrapper">${str}</div>`
  129. $(`.${contentWrapClassName} .infos`).append(str);
  130. $(`.${contentWrapClassName} .anchors ul`).append(anchors);
  131. }
  132. function addScrollEvent() {
  133. var scrollTop = $(`.${contentWrapClassName} .infos`).scrollTop()
  134. var divHeight = 0;
  135. for (var i = 0; i < list.length; i++) {
  136. divHeight = divHeight + parseInt($('#'+contentWrapClassName+i).css('height')) + parseInt($('#'+contentWrapClassName+i).parent().next().css('height')) + 20
  137. if (divHeight > scrollTop) {
  138. var anchor = 2 * i;
  139. $(`.${contentWrapClassName} .anchors ul`).children().eq(anchor).addClass('active').siblings().removeClass('active');
  140. return;
  141. }
  142. }
  143. }
  144. $(`.${contentWrapClassName} .infos`).scroll(throttle(addScrollEvent, 200));
  145. addLinkClickEvent(contentWrapClassName);
  146. adjustHeight();
  147. adjustWidth()
  148. }
  149. function addLinkClickEvent(contentWrapClassName) {
  150. $(`.${contentWrapClassName} .anchors li:first`).addClass("active");
  151. $(`.${contentWrapClassName} .anchors li>a`).on("click", function () {
  152. const that = this
  153. setTimeout(function(){
  154. $(`.${contentWrapClassName} .anchors .active`).removeClass('active');
  155. $(that).parent().addClass("active");
  156. },20)
  157. });
  158. }
  159. function renderTab(detailList){
  160. $(".tabList").html('')
  161. if(detailList['静态知识']){
  162. $(".tabList").append(`<span class="tab" data-module="staticKnowledge" data-title="`+showName+`">静态知识</span>`)
  163. //$(".titleCont .title").html(showName);
  164. }
  165. if(detailList['临床路径']){
  166. $(".tabList").append(`<span class="tab" data-module="clinicalPathway" data-title="`+clinicalPathwayName+`">临床路径</span>`)
  167. //$(".titleCont .title").html(clinicalPathwayName);
  168. }
  169. if(detailList['注意事项']){
  170. $(".tabList").append(`<span class="tab" data-module="notice" data-title="`+noticeName+`">注意事项</span>`)
  171. //$(".titleCont .title").html(noticeName);
  172. }
  173. $(".tabList .tab").eq(0).addClass("activeTab")
  174. let defaultModuleName = $(".tabList .tab").eq(0).attr("data-module")
  175. $(`.${defaultModuleName}`).css("display","block")
  176. bindTabClick()
  177. }
  178. function bindTabClick(){
  179. $(".tabList .tab").on("click", function(){
  180. const moduleName = $(this).attr("data-module")
  181. const display = $(`.${moduleName}`).css("display")
  182. $(".titleCont .title").html($(this).attr('data-title'));
  183. //if(display == "none"){
  184. $(".activeTab").removeClass("activeTab")
  185. $(this).addClass("activeTab")
  186. $(".container").css("display","none")
  187. $(`.${moduleName}`).css("display","block")
  188. $(`.${moduleName} .infos`).scrollTop(0)
  189. //}
  190. })
  191. $("#openWin").on("click",function(){
  192. const type= getUrlArgObject('type');
  193. const hospitalId= getUrlArgObject('hospitalId');
  194. const hisName= getUrlArgObject('hisName');
  195. const hisDetailName= getUrlArgObject('hisDetailName');
  196. openNewWin("staticInfoOut.html?hospitalId="+encodeURIComponent(hospitalId)+"&hisName="+encodeURIComponent(hisName)+"&hisDetailName="+encodeURIComponent(hisDetailName||'')+"&type="+encodeURIComponent(type));
  197. })
  198. }
  199. function adjustHeight() {
  200. var ht = window.innerHeight || document.documentElement.clientHeight;
  201. $(".content,.content .infos").height(ht - 228 + "px");
  202. }
  203. function adjustWidth() {
  204. var wt = window.innerWidth || document.documentElement.clientWidth;
  205. $(".titleH2").width(wt- 0.2*wt -33 - 200 - 17 - 40 -15 + 'px')
  206. $("pre").width(wt- 0.2*wt - 200 + 'px')
  207. }
  208. $(window).on('resize', function(){
  209. adjustHeight()
  210. adjustWidth()
  211. })
  212. //如果是子窗口,隐藏网页查看按钮
  213. if(window.opener){
  214. $("#openWin").hide();
  215. }