scale.js 7.0 KB

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