informationOut.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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/informationOut.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. const uname = getUrlArgObject('uname')
  36. // showName = param.name
  37. // if (param.type == 5 || param.type == 51) {
  38. // param.type = 12;
  39. // param.name = uname;
  40. // }
  41. post(config.getStaticKnowledgeForHIS, param).then((res) => {
  42. if(res.data.code==='0'){
  43. const data = res.data.data
  44. var str = '';
  45. var anchors = '';
  46. if (!data||data.length===0) {
  47. showEmpty();
  48. return;
  49. }
  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. }
  74. function showInfo(data){
  75. var detailList = data.details
  76. var staticKnowList = detailList['静态知识']
  77. var noticeInfo = detailList['注意事项']
  78. var clinicalPathwayInfo = detailList['临床路径']
  79. noticeName = data.noticeName || "注意事项"
  80. clinicalPathwayName = data.clinicalPathwayName || "临床路径"
  81. // $("h1").css({
  82. // "color": "#267FD7",
  83. // "borderBottom": "4px solid #E9E9E9",
  84. // "padding": "0px 60px 50px 0px"
  85. // });
  86. renderTab(detailList)
  87. staticKnowList&&renderContent(staticKnowList,'staticKnowledge')
  88. noticeInfo&&renderContent(noticeInfo,'notice')
  89. clinicalPathwayInfo&&renderContent(clinicalPathwayInfo,'clinicalPathway')
  90. }
  91. function showInfoSelect(){
  92. $('.showWhich li').click(function(){
  93. let idx = $(this).attr('data-idx')
  94. let name = $(this).html(),str=''
  95. showName = showLis[idx].name
  96. document.title = showName
  97. showInfo(showLis[idx])
  98. $('.content .infos').scrollTop(0)
  99. $(".showWhich ul").css("display","none")
  100. $(".showWhichSelect").html(name).attr("title",name)
  101. })
  102. $(".showWhichSelect").click(function(e){
  103. e.stopPropagation()
  104. $(".showWhich ul").slideToggle()
  105. })
  106. $(document).click(function(){
  107. $(".showWhich ul").css("display","none")
  108. })
  109. }
  110. function renderContent(list, contentWrapClassName){
  111. $(`.${contentWrapClassName} .infos`).html('');
  112. $(`.${contentWrapClassName} .anchors ul`).html('');
  113. for (var i = 0; i < list.length; i++) {
  114. var item = list[i];
  115. item.content = item.content&&item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
  116. anchors = '<li><i></i><a href="#' + contentWrapClassName+i +
  117. '">' + item.title + '</a></li><li class="anchor-line"></li>';
  118. str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> </span></div> <h2 class="titleH2" id="' + contentWrapClassName+i +
  119. '">'
  120. if (getUrlArgObject('type') == 8) {
  121. str += '【' + item.title + '】'
  122. } else {
  123. str += item.title
  124. }
  125. str += '</h2></div>' +
  126. '<div class="contentWrapper"><pre>' + item.content + '</pre><div></div>';
  127. str = `<div class="infoWrapper">${str}</div>`
  128. $(`.${contentWrapClassName} .infos`).append(str);
  129. $(`.${contentWrapClassName} .anchors ul`).append(anchors);
  130. }
  131. function addScrollEvent() {
  132. var scrollTop = $(`.${contentWrapClassName} .infos`).scrollTop()
  133. var divHeight = 0;
  134. for (var i = 0; i < list.length; i++) {
  135. divHeight = divHeight + parseInt($('#'+contentWrapClassName+i).css('height')) + parseInt($('#'+contentWrapClassName+i).parent().next().css('height')) + 20
  136. if (divHeight > scrollTop) {
  137. var anchor = 2 * i;
  138. $(`.${contentWrapClassName} .anchors ul`).children().eq(anchor).addClass('active').siblings().removeClass('active');
  139. return;
  140. }
  141. }
  142. }
  143. $(`.${contentWrapClassName} .infos`).scroll(throttle(addScrollEvent, 200));
  144. addLinkClickEvent(contentWrapClassName);
  145. adjustHeight();
  146. adjustWidth()
  147. }
  148. function addLinkClickEvent(contentWrapClassName) {
  149. $(`.${contentWrapClassName} .anchors li:first`).addClass("active");
  150. $(`.${contentWrapClassName} .anchors li>a`).on("click", function () {
  151. const that = this
  152. setTimeout(function(){
  153. $(`.${contentWrapClassName} .anchors .active`).removeClass('active');
  154. $(that).parent().addClass("active");
  155. },20)
  156. });
  157. }
  158. function renderTab(detailList){
  159. $(".tabList").html('')
  160. if(detailList['静态知识']){
  161. $(".tabList").append(`<span class="tab" data-module="staticKnowledge">静态知识</span>`)
  162. $(".staticKnowledge h1").html(showName);
  163. }
  164. if(detailList['临床路径']){
  165. $(".tabList").append(`<span class="tab" data-module="clinicalPathway">临床路径</span>`)
  166. $(".clinicalPathway h1").html(clinicalPathwayName);
  167. }
  168. if(detailList['注意事项']){
  169. $(".tabList").append(`<span class="tab" data-module="notice">注意事项</span>`)
  170. $(".notice h1").html(noticeName);
  171. }
  172. $(".tabList .tab").eq(0).addClass("activeTab")
  173. let defaultModuleName = $(".tabList .tab").eq(0).attr("data-module")
  174. $(`.${defaultModuleName}`).css("display","block")
  175. bindTabClick()
  176. }
  177. function bindTabClick(){
  178. $(".tabList .tab").on("click", function(){
  179. const moduleName = $(this).attr("data-module")
  180. const display = $(`.${moduleName}`).css("display")
  181. if(display == "none"){
  182. $(".activeTab").removeClass("activeTab")
  183. $(this).addClass("activeTab")
  184. $(".container").css("display","none")
  185. $(`.${moduleName}`).css("display","block")
  186. $(`.${moduleName} .infos`).scrollTop(0)
  187. }
  188. })
  189. $("#openWin").on("click",function(){
  190. const type= getUrlArgObject('type');
  191. const hospitalId= getUrlArgObject('hospitalId');
  192. const hisName= getUrlArgObject('hisName');
  193. const hisDetailName= getUrlArgObject('hisDetailName');
  194. openNewWin("informationOut.html?hospitalId="+encodeURIComponent(hospitalId)+"&hisName="+encodeURIComponent(hisName)+"&hisDetailName="+encodeURIComponent(hisDetailName)+"&type="+encodeURIComponent(type));
  195. })
  196. }
  197. function adjustHeight() {
  198. var ht = window.innerHeight || document.documentElement.clientHeight;
  199. $(".content").height(ht - 90 + "px");
  200. }
  201. function adjustWidth() {
  202. var wt = window.innerWidth || document.documentElement.clientWidth;
  203. $(".titleH2").width(wt- 0.2*wt -33 - 200 - 17 - 40 -15 + 'px')
  204. $("pre").width(wt- 0.2*wt - 200 + 'px')
  205. }
  206. $(window).on('resize', function(){
  207. adjustHeight()
  208. adjustWidth()
  209. })
  210. //如果是子窗口,隐藏网页查看按钮
  211. if(window.opener){
  212. $("#openWin").hide();
  213. }