staticInfoOut.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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. require("./jquery-migrate");
  20. const jqprint = require("../js/jquery.PrintArea")
  21. let printing = require('./../images/printing.png');
  22. let printing2 = require('./../images/printing2.png');
  23. let showName,noticeName,clinicalPathwayName,showLis=[],selectedDrop=0,selectedTab=0
  24. //如果是子窗口,隐藏网页查看按钮
  25. if(window.opener){
  26. selectedDrop=getUrlArgObject("d")||0;
  27. selectedTab=getUrlArgObject("t")||0;
  28. $("#openWin").hide();
  29. }
  30. let icond = require('./../images/d.png').replace(/^undefined/g, '')
  31. function getInfomation() {
  32. // var param = {
  33. // "type": getUrlArgObject('type'),
  34. // "name": getUrlArgObject('name'),
  35. // "position": getUrlArgObject('position'),
  36. // "contentTypes":[1,2,3]
  37. // };
  38. var param = {
  39. "type": getUrlArgObject('type'),
  40. "hospitalId": getUrlArgObject('hospitalId'),
  41. "hisName": getUrlArgObject('hisName'),
  42. "hisDetailName": getUrlArgObject('hisDetailName'),
  43. "contentTypes":[1,2,3]
  44. };
  45. //showName = param.hisName;
  46. // if (param.type == 5 || param.type == 51) {
  47. // param.type = 12;
  48. // param.name = uname;
  49. // }
  50. post(config.getStaticKnowledgeForHIS, param).then((res) => {
  51. if(res.data.code==='0'){
  52. const data = res.data.data
  53. var str = '';
  54. var anchors = '';
  55. let sName ='';
  56. if (!data||data.length===0) {
  57. showEmpty();
  58. return;
  59. }
  60. showLis=data
  61. for(let i = 0;i < showLis.length;i++){
  62. let tmp = showLis[i]
  63. str+=`<li data-idx="${i}" title="${tmp.name}(${tmp.hisName})">${tmp.name}(${tmp.hisName})</li>`
  64. }
  65. $(".showWhich ul").html(str);
  66. sName=showLis[selectedDrop].name+"("+showLis[selectedDrop].hisName+")";
  67. $(".showWhichSelect").html(sName).attr("title",sName)
  68. showName = data[selectedDrop].name+"("+data[selectedDrop].hisName+")";
  69. showInfoSelect()
  70. showInfo(data[selectedDrop])
  71. renderTitleShow();
  72. $('.content img').bind('contextmenu', function(){
  73. return false
  74. })
  75. }else{
  76. showEmpty();
  77. }
  78. })
  79. }
  80. getInfomation();
  81. function showEmpty(){
  82. const str=`<div class="empty"><img src="../images/empty3.png" alt=""><p>暂无静态知识</p></div>`;
  83. $(".tabBox").html(str).css("border-bottom","none");
  84. $("body").css('background','#fff');
  85. }
  86. function showInfo(data){
  87. var detailList = data.details
  88. var scale = data.scale
  89. var staticKnowList = detailList['静态知识']
  90. var noticeInfo = detailList['注意事项']
  91. var clinicalPathwayInfo = detailList['临床路径']
  92. var name = data.name
  93. noticeName = data.noticeName || "注意事项"
  94. clinicalPathwayName = data.clinicalPathwayName || "临床路径"
  95. var scaleInfo = data.scale ? data.scale.scaleDetails : ''
  96. // $("h1").css({
  97. // "color": "#267FD7",
  98. // "borderBottom": "4px solid #E9E9E9",
  99. // "padding": "0px 60px 50px 0px"
  100. // });
  101. renderTab(detailList, scale)
  102. staticKnowList&&renderContent(staticKnowList,'staticKnowledge')
  103. noticeInfo&&renderContent(noticeInfo,'notice')
  104. clinicalPathwayInfo&&renderContent(clinicalPathwayInfo,'clinicalPathway')
  105. scaleInfo && renderContentscale(scaleInfo, 'scale', name)
  106. }
  107. function showInfoSelect(){
  108. $('.showWhich li').click(function(){
  109. let idx = $(this).attr('data-idx')
  110. let name = $(this).html(),str=''
  111. selectedDrop=idx;
  112. selectedTab=0;
  113. showName = showLis[idx].name+"("+showLis[idx].hisName+")";
  114. showInfo(showLis[idx])
  115. renderTitleShow();
  116. $('.content .infos').scrollTop(0)
  117. $(".showWhich ul").css("display","none")
  118. $(".showWhichSelect").html(name).attr("title",name)
  119. })
  120. $(".showWhichSelect").click(function(e){
  121. e.stopPropagation()
  122. $(".showWhich ul").slideToggle()
  123. })
  124. $(document).click(function(){
  125. $(".showWhich ul").css("display","none")
  126. })
  127. }
  128. function renderTitleShow(){
  129. document.title = showName;
  130. $(".titleCont .title").html($(".tabList .tab:eq("+selectedTab+")").attr("data-title"));
  131. }
  132. function renderContent(list, contentWrapClassName){
  133. $(`.${contentWrapClassName} .infos`).html('');
  134. $(`.${contentWrapClassName} .anchors ul`).html('');
  135. for (var i = 0; i < list.length; i++) {
  136. var item = list[i];
  137. item.content = item.content&&item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
  138. anchors = '<li><i></i><a href="#' + contentWrapClassName+i +
  139. '">' + item.title + '</a></li><li class="anchor-line"></li>';
  140. str = '<div class="infoBox"><div class="title"> <h2 class="titleH2" id="' + contentWrapClassName+i +
  141. '">'
  142. if (getUrlArgObject('type') == 8) {
  143. str += '【' + item.title + '】'
  144. } else {
  145. str += item.title
  146. }
  147. str += '</h2></div>' +
  148. '<div class="contentWrapper"><pre>' + item.content + '</pre><div></div>';
  149. str = `<div class="infoWrapper">${str}</div>`
  150. $(`.${contentWrapClassName} .infos`).append(str);
  151. $(`.${contentWrapClassName} .anchors ul`).append(anchors);
  152. }
  153. function addScrollEvent() {
  154. var scrollTop = $(`.${contentWrapClassName} .infos`).scrollTop()
  155. var divHeight = 0;
  156. for (var i = 0; i < list.length; i++) {
  157. divHeight = divHeight + parseInt($('#'+contentWrapClassName+i).css('height')) + parseInt($('#'+contentWrapClassName+i).parent().next().css('height')) + 20
  158. if (divHeight > scrollTop) {
  159. var anchor = 2 * i;
  160. $(`.${contentWrapClassName} .anchors ul`).children().eq(anchor).addClass('active').siblings().removeClass('active');
  161. return;
  162. }
  163. }
  164. }
  165. $(`.${contentWrapClassName} .infos`).scroll(throttle(addScrollEvent, 200));
  166. addLinkClickEvent(contentWrapClassName);
  167. adjustHeight();
  168. adjustWidth()
  169. }
  170. function renderContentscale(list, contentWrapClassName, name) {
  171. var pushInfo = []
  172. anchors = '<li><i></i><a href="#' + contentWrapClassName +
  173. '">' + name + '</a></li><li class="anchor-line"></li>';
  174. str = '<p class="scaletitle">' + name + '</p>'
  175. $(`.${contentWrapClassName} .infos .infos-box`).append(str);
  176. $(`.${contentWrapClassName} .anchors ul`).append(anchors);
  177. for (var i = 0; i < list[0].detailList.length; i++) {
  178. var item = list[0].detailList[i];
  179. console.log(item)
  180. if (item.textType == 11) {
  181. item.content = item.content && item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
  182. str = '<div class="infoBox scaleBox" data-id="' + item.id + '"><div class="title"> <h2 class="titleH2" id="' + contentWrapClassName + i +
  183. '">'
  184. str += item.content
  185. str += '</h2></div>'
  186. str = `<div class="infoWrapper">${str}</div>`
  187. $(`.${contentWrapClassName} .infos .infos-box`).append(str);
  188. for (var j = 0; j < item.subList.length; j++) {
  189. var items = item.subList[j];
  190. for (var k = 0; k < items.detailList.length; k++) {
  191. var it = items.detailList[k];
  192. it.content = it.content && it.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
  193. str = '<div class="contentList" data-id="' + it.parentId + '"><div class="item-list">';
  194. if (it.selectType == 1) {
  195. str += '<p class="item-title">' + it.content + '</p>'
  196. } else if (it.selectType == 2) {
  197. str += '<p class="item-titles">' + it.content + '</p>'
  198. }
  199. str += '<div class="item-content" data-id="' + it.id + '">'
  200. str += '</div></div></div>'
  201. $(".scale .infos .infos-box .infoWrapper .infoBox[data-id=" + it.parentId + "]").append(str);
  202. for (var l = 0; l < it.subList[0].detailList.length; l++) {
  203. var its = it.subList[0].detailList[l];
  204. its.content = its.content && its.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
  205. str = '<div class="radio" name="scale' + its.parentId + '" value="' + its.score + '">';
  206. if (it.selectType == 1 && item.resultType == 1) {
  207. str += '<label><input class="radio_type" type="checkbox" name="scale' + its.parentId + '" value="' + its.score + '"/>'
  208. } else if (it.selectType == 2 && item.resultType == 1) {
  209. str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.score + '" />'
  210. } else if (it.selectType == 1 && item.resultType == 2) {
  211. str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="checkbox" value="' + its.result + '" data_obj="' + its.result + '"/>'
  212. } else if (it.selectType == 2 && item.resultType == 2) {
  213. str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.result + '" data_obj="' + its.result + '"/>'
  214. }
  215. str += its.content
  216. if (item.resultType == 1) {
  217. str += '<span class="num">' + '(' + its.score + ')' + '</span>'
  218. }
  219. str += '</label>'
  220. str += `${item.match ? `<img class="recommend" src=${recommend} />` : ``}</div>`
  221. $(".scale .infos .infos-box .infoWrapper .infoBox[data-id=" + it.parentId + "] .contentList .item-content[data-id=" + its.parentId + "]").append(str);
  222. }
  223. }
  224. }
  225. }
  226. if (item.textType == 13) {
  227. for (var m = 0; m < item.subList[0].detailList[0].subList[0].detailList.length; m++) {
  228. var itl = item.subList[0].detailList[0].subList[0].detailList[m]
  229. let arr = {
  230. content: JSON.parse(itl.content),
  231. result: itl.result,
  232. pushInfo: itl.pushInfo
  233. }
  234. pushInfo.push(arr)
  235. }
  236. }
  237. }
  238. str = '<div class="scalebot">'
  239. str += '<p class="score"></p>'
  240. str += '<button class="but">结果</button></div>'
  241. str += '<div class="result"><div class="result_box"><p class="hel">?</p><span>结果:</span><p id="result_title" class="result_title"></p><textarea id="inputs"></textarea></div></div>'
  242. str += `<div class="foot"><div class="foot_box"><div class="printing"><img src=${printing} class="slideImg"/>打印</div><div class="copy">确认并复制结果</div></div></div>`
  243. $(`.${contentWrapClassName} .infos .infos-box`).append(str);
  244. // str = `<div class="foot"><div class="foot_box"><div class="printing"><img src=${printing} class="slideImg"/>打印</div><div class="copy">确认并复制结果</div></div></div>`
  245. // $(`.${contentWrapClassName} .infos`).after(str);
  246. function addScrollEvent() {
  247. var scrollTop = $(`.${contentWrapClassName} .infos .infos-box`).scrollTop()
  248. var divHeight = 0;
  249. for (var i = 0; i < list.length; i++) {
  250. divHeight = divHeight + parseInt($('#' + contentWrapClassName + i).css('height')) + parseInt($('#' + contentWrapClassName + i).parent().next().css('height')) + 20
  251. if (divHeight > scrollTop) {
  252. var anchor = 2 * i;
  253. $(`.${contentWrapClassName} .anchors ul`).children().eq(anchor).addClass('active').siblings().removeClass('active');
  254. return;
  255. }
  256. }
  257. }
  258. $(`.${contentWrapClassName} .infos .infos-box`).scroll(throttle(addScrollEvent, 200));
  259. addLinkClickEvent(contentWrapClassName);
  260. adjustHeight();
  261. adjustWidth()
  262. getcheck()
  263. getResult(pushInfo)
  264. copy()
  265. getprinting()
  266. }
  267. function getprinting() {
  268. $('.printing').click(function () {
  269. $('.foot').hide()
  270. $('.hel').hide()
  271. $('#Print').css({
  272. 'height': 'auto', //高度自动
  273. }).jqprint();
  274. $('.foot').show()
  275. $('.hel').show()
  276. })
  277. }
  278. function getcheck() {
  279. $('input:radio').click(function () {
  280. var domName = $(this).attr('name');
  281. var $radio = $(this);
  282. if ($radio.data('waschecked') == true) {
  283. $radio.prop('checked', false);
  284. $("input:radio[name='" + domName + "']").data('waschecked', false);
  285. } else {
  286. $radio.prop('checked', true);
  287. $("input:radio[name='" + domName + "']").data('waschecked', false);
  288. $radio.data('waschecked', true);
  289. }
  290. console.log("选中状态:", $(this).prop("checked"));
  291. console.log($("input:radio[name='" + domName + "']:checked").val());
  292. });
  293. }
  294. function copy() {
  295. $(".copy").click(function () {
  296. var texts = document.getElementById("result_title").innerText;
  297. if (texts == '') {
  298. return
  299. }
  300. var inputs = document.getElementById("inputs");
  301. inputs.value = texts; // 修改文本框的内容(赋值内容)
  302. inputs.select(); // 选中文本
  303. document.execCommand("copy"); // 执行浏览器复制命令
  304. Toast('复制成功', 500)
  305. setTimeout(() => {
  306. window.close()
  307. }, 500)
  308. })
  309. }
  310. function getResult(pushInfo) {
  311. $(".but").click(function () {
  312. let arr = [];
  313. let num = 0
  314. let result
  315. let key = false
  316. $(".contentList").each(function (i) {
  317. if ($(this).find('input[type="radio"]:checked').val() == undefined) {
  318. $(this).find(".item-titles").addClass('chColor');
  319. } else {
  320. $(this).find(".item-titles").removeClass('chColor');
  321. }
  322. if ($(this).find('input[type="checkbox"]:checked').val() == undefined) {
  323. $(this).find(".item-title").addClass('chColor');
  324. } else {
  325. $(this).find(".item-title").removeClass('chColor');
  326. }
  327. });
  328. if (!$(".contentList").find(".item-title").hasClass('chColor')) {
  329. $('input[type="radio"]:checked').each(function () {
  330. if (Number($(this).val())) {
  331. num += parseFloat($(this).val())
  332. } else {
  333. arr.push($(this).attr("data_obj"))
  334. }
  335. });
  336. $('input[type="checkbox"]:checkbox:checked').each(function () {
  337. if (Number($(this).val())) {
  338. num += parseFloat($(this).val())
  339. } else {
  340. arr.push($(this).attr("data_obj"))
  341. }
  342. });
  343. tmp = arr.join(",");
  344. if (pushInfo.length > 0) {
  345. for (var i = 0; i < pushInfo.length; i++) {
  346. if (pushInfo[i].content.max >= num >= pushInfo[i].content.min) {
  347. if (tmp) {
  348. result = pushInfo[i].result + ';' + tmp
  349. } else {
  350. result = pushInfo[i].result
  351. }
  352. }
  353. }
  354. } else {
  355. result = tmp
  356. }
  357. $(".result_title").attr({
  358. "title": result
  359. });
  360. $(".hel").attr({
  361. "title": result
  362. });
  363. $(".result_title").html(result);
  364. $(".score").html('总分:' + num + '分');
  365. $(".score").css('display', 'block')
  366. $(".result").css('display', 'block')
  367. $(".foot").css('display', 'block')
  368. } else {
  369. Toast('温馨提示:必填选项不能为空~', 500)
  370. }
  371. })
  372. $(".printing").hover(
  373. function () {
  374. $(".slideImg").attr("src", printing2);
  375. }, function () {
  376. $(".slideImg").attr("src", printing);
  377. });
  378. }
  379. function addLinkClickEvent(contentWrapClassName) {
  380. $(`.${contentWrapClassName} .anchors li:first`).addClass("active");
  381. $(`.${contentWrapClassName} .anchors li>a`).on("click", function () {
  382. const that = this
  383. setTimeout(function(){
  384. $(`.${contentWrapClassName} .anchors .active`).removeClass('active');
  385. $(that).parent().addClass("active");
  386. },20)
  387. });
  388. }
  389. function renderTab(detailList, scale){
  390. $(".tabList").html('')
  391. if(detailList['静态知识']){
  392. $(".tabList").append(`<span class="tab" data-module="staticKnowledge" data-title="`+showName+`">静态知识</span>`)
  393. //$(".titleCont .title").html(showName);
  394. }
  395. if(detailList['临床路径']){
  396. $(".tabList").append(`<span class="tab" data-module="clinicalPathway" data-title="`+clinicalPathwayName+`">临床路径</span>`)
  397. //$(".titleCont .title").html(clinicalPathwayName);
  398. }
  399. if(detailList['注意事项']){
  400. $(".tabList").append(`<span class="tab" data-module="notice" data-title="`+noticeName+`">注意事项</span>`)
  401. //$(".titleCont .title").html(noticeName);
  402. }
  403. if (scale) {
  404. $(".tabList").append(`<span class="tab" data-module="scale" data-title="` + showName + `">评估内容</span>`)
  405. //$(".tabBox .title").html(noticeName);
  406. }
  407. $(".tabList .tab").eq(selectedTab).addClass("activeTab")
  408. let defaultModuleName = $(".tabList .tab").eq(selectedTab).attr("data-module")
  409. $(`.${defaultModuleName}`).css("display","block")
  410. bindTabClick()
  411. }
  412. function bindTabClick(){
  413. $(".tabList .tab").on("click", function(){
  414. const moduleName = $(this).attr("data-module")
  415. //const display = $(`.${moduleName}`).css("display")
  416. selectedTab=$('.tabList .tab').index(this);
  417. $(".titleCont .title").html($(this).attr('data-title'));
  418. //if(display == "none"){
  419. $(".activeTab").removeClass("activeTab")
  420. $(this).addClass("activeTab")
  421. $(".container").css("display","none")
  422. $(`.${moduleName}`).css("display","block")
  423. $(`.${moduleName} .infos`).scrollTop(0)
  424. //}
  425. })
  426. $("#openWin").on("click",function(){
  427. const type= getUrlArgObject('type');
  428. const hospitalId= getUrlArgObject('hospitalId');
  429. const hisName= getUrlArgObject('hisName');
  430. const hisDetailName= getUrlArgObject('hisDetailName');console.log(selectedDrop)
  431. openNewWin("staticInfoOut.html?hospitalId="+encodeURIComponent(hospitalId)+"&hisName="+encodeURIComponent(hisName)+"&hisDetailName="+encodeURIComponent(hisDetailName||'')+"&type="+encodeURIComponent(type)+"&d="+selectedDrop+"&t="+selectedTab);
  432. })
  433. }
  434. function adjustHeight() {
  435. var ht = window.innerHeight || document.documentElement.clientHeight;
  436. $(".content,.content .infos").height(ht - 198 + "px");
  437. /*$(".anchors").height(ht - 258 + "px");*/
  438. }
  439. function adjustWidth() {
  440. var wt = window.innerWidth || document.documentElement.clientWidth;
  441. $(".titleH2").width(wt- 0.2*wt -33 - 200 - 17 - 40 -15 + 'px')
  442. //$("pre").width(wt- 0.2*wt - 200 + 'px')
  443. }
  444. $(window).on('resize', function(){
  445. adjustHeight()
  446. adjustWidth()
  447. })