scale.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. const {
  2. post,
  3. config,
  4. getUrlArgObject
  5. } = require('./promise.js');
  6. const $ = require("jquery");
  7. $(function () {
  8. var scaleInfo;
  9. // 用GetQueryString方法从地址栏获取参数,暂时写死
  10. var params = {
  11. "age": getUrlArgObject('age') || 28,
  12. "featureType": getUrlArgObject('featureType') || '21',
  13. "scaleName": getUrlArgObject('scaleName') || '密西根糖尿病周围神经病评分(MDNS)',
  14. "sex": getUrlArgObject('sex') || 1,
  15. "diag": getUrlArgObject('diag') || '肺结核(复诊);',
  16. "lis": getUrlArgObject('lis') ? JSON.parse(getUrlArgObject('lis')) : [],
  17. "symptom": getUrlArgObject('symptom') || '',
  18. "other": getUrlArgObject('other') || '',
  19. "pacs": getUrlArgObject('pacs') || '',
  20. "vital": getUrlArgObject('vital') || ''
  21. }
  22. if (getUrlArgObject('scaleName')) {
  23. post(config.pushScale, params).then((res) => {
  24. const data = res.data.data
  25. if (res.data.code == 0) {
  26. scaleInfo = data;
  27. console.log('scaleInfo', scaleInfo)
  28. for (var i = 0; i < scaleInfo.length; i++) {
  29. if (scaleInfo[i].type == 1) {
  30. var scaleList = JSON.parse(scaleInfo[i].content)
  31. console.log('scaleList', scaleList)
  32. renderCalcu(scaleList)
  33. } else {
  34. $('.content').append(scaleInfo[i].content)
  35. }
  36. }
  37. $('input').on('change', function (e) {
  38. var indexList = $(this).attr('data-index').split(',')
  39. for (var i = 0; i < scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details.length; i++) {
  40. scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details[i].select = 0
  41. }
  42. scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details[indexList[3]].select = 1
  43. const className = $(this).parent().parent().parent().attr('data-group')
  44. for (let i = 0; i < $('.' + className).length; i++) {
  45. $('.' + className).eq(i).removeClass('noSelect')
  46. }
  47. })
  48. $('.calcuBtn').on('click', function () {
  49. let allSelect = true
  50. for (let i = 0; i < scaleList.group.length; i++) {
  51. for (let j = 0; j < scaleList.group[i].rows.length; j++) {
  52. if (scaleList.group[i].rows[j].required == 1) {
  53. let itemSelect = false
  54. for (let x = 0; x < scaleList.group[i].rows[j].row.length; x++) {
  55. for (let y = 0; y < scaleList.group[i].rows[j].row[x].details.length; y++) {
  56. if (scaleList.group[i].rows[j].row[x].details[y].select == 1) {
  57. itemSelect = true
  58. }
  59. }
  60. }
  61. if (!itemSelect) {
  62. allSelect = false
  63. $('.' + i + j).addClass('noSelect')
  64. }
  65. }
  66. }
  67. }
  68. if (!allSelect) {
  69. $('.modal').css('display', 'block');
  70. let timer = setTimeout(() => {
  71. $('.modal').css('display', 'none');
  72. }, 2000);
  73. $('.closeModal').click(function () {
  74. $('.modal').css('display', 'none');
  75. if (timer) {
  76. clearTimeout(timer)
  77. }
  78. })
  79. }
  80. if (allSelect) {
  81. getCalcuResult(scaleList)
  82. }
  83. })
  84. }
  85. })
  86. }
  87. })
  88. function renderCalcu(scaleList) {
  89. $("h1").html(scaleList.scaleName);
  90. var str = ''
  91. for (var j = 0; j < scaleList.group.length; j++) {
  92. str += '<div class="groupBox"> <div class="groupName">' + scaleList.group[j].groupName + '</div>';
  93. for (var x = 0; x < scaleList.group[j].rows.length; x++) {
  94. for (var y = 0; y < scaleList.group[j].rows[x].row.length; y++) {
  95. var str2 = ''
  96. for (var z = 0; z < scaleList.group[j].rows[x].row[y].details.length; z++) {
  97. str2 += '<span class="groupRowRadio"><input type="radio" data-index="' + j + ',' + x + ',' + y + ',' + z + '" name="' + j + x + y + '" id="' + j + x + y + z
  98. if (scaleList.group[j].rows[x].row[y].details[z].select == 1) {
  99. str2 += ' checked="checked"'
  100. }
  101. str2 += '" />' + '<label for="' + j + x + y + z + '">' + scaleList.group[j].rows[x].row[y].details[z].detailName + '(' + scaleList.group[j].rows[x].row[y].details[z].score + ')' + '</label>'
  102. if (scaleList.group[j].rows[x].row[y].details[z].state == 1) {
  103. str2 += '<span class="groupRowRecommend">智能推荐</span>'
  104. }
  105. str2 += '</span>'
  106. }
  107. str += '<div class="groupRowWrapper ' + j + x + '" data-group="' + j + x + '" id="' + j + x + y + '"><div class="groupRowName"> <span class="groupRowIndex">'
  108. if (y == 0) {
  109. str += (x + 1) + '.'
  110. }
  111. str += '</span>' + scaleList.group[j].rows[x].row[y].name + '</div><div class="groupRowBox">' + str2 + '</div>' + '</div>'
  112. }
  113. }
  114. if (scaleList.group[j].groupCalculate.isShow == 1) {
  115. str += '<div class="calcu">计分:' + scaleList.group[j].groupCalculate.result.value + ' ' + scaleList.group[j].groupCalculate.result.text + '</div>'
  116. }
  117. str += '</div>'
  118. }
  119. var calcuStr = '<div class="allCalcuBox"><span class="allCalcu">总分:'
  120. if (scaleList.calculate && scaleList.calculate.result) {
  121. calcuStr += scaleList.calculate.result.value + ' ' + scaleList.calculate.result.text
  122. }
  123. calcuStr += '</span><span class="calcuBtn">得分</span></div>'
  124. var allStr = '<div class="calcuWrapper">' + str + calcuStr + '</div>'
  125. $('.content').append(allStr)
  126. }
  127. function getCalcuResult(data) {
  128. const param = {
  129. type: 1,
  130. data: data
  131. }
  132. post(config.calculate, param).then((res) => {
  133. const dataResult = res.data.data
  134. if (res.data.code == 0) {
  135. data.calculate.result = dataResult.calcalculate.result
  136. for (let i = 0; i < data.group.length; i++) {
  137. for (let j = 0; j < dataResult.group.length; j++) {
  138. if (data.group[i].groupName == dataResult.group[j].groupName) {
  139. data.group[j].groupCalculate.result = dataResult.group[i].groupCalculate.result
  140. }
  141. }
  142. }
  143. if ($('.calcu')) {
  144. for (let i = 0; i < $('.calcu').length; i++) {
  145. let calcuItemName = $('.calcu').eq(i).prev().find('.groupName').html();
  146. let calcuItem = data.group.filter(function (item) {
  147. return item.groupName == calcuItemName
  148. })[0]
  149. $('.calcu').eq(i).html('计分:' + calcuItem.groupCalculate.result.value + ' ' + calcuItem.groupCalculate.result.text)
  150. }
  151. }
  152. $('.allCalcu').eq(0).html('总分:' + data.calculate.result.value + ' ' + data.calculate.result.text)
  153. } else {
  154. alert(res.msg)
  155. }
  156. })
  157. }