staticInfo.js 21 KB

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