staticInfo.js 18 KB

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