staticInfo.js 20 KB

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