request-config.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //@ sourceURL=request-config.js
  2. $(function () {
  3. $(".selectpicker").selectpicker({
  4. dropuAuto: false
  5. });
  6. initDeptSelect();
  7. //告警阈值
  8. $.ajax({
  9. type: "GET",
  10. url: '/thmz/getConfigByKey?key=alarm_num',
  11. dataType: "json",
  12. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  13. success: function (res) {
  14. if (res == '401' || res == 401) {
  15. window.location.href = '/thmz/login/view'
  16. return;
  17. }
  18. $("#alarmNum").val(res.data.configValue);
  19. }
  20. });
  21. $('#send').click(function () {
  22. //修改告警设置
  23. $.ajax({
  24. type: "POST",
  25. contentType: "application/json;charset=UTF-8",
  26. url: '/thmz/setConfig',
  27. dataType: "json",
  28. data: JSON.stringify({"configKey": "alarm_num","configValue": $("#alarmNum").val()}),
  29. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  30. success: function (res) {
  31. if (res == '401' || res == 401) {
  32. window.location.href = '/thmz/login/view'
  33. return;
  34. }
  35. if (res.code == 0) {
  36. //修改告警人员
  37. var doctor=$("#doctor").val();
  38. var doctorStr=null;
  39. if(doctor!=null && doctor.length>0){
  40. for (var i=0;i<doctor.length;i++){
  41. if(doctorStr==null){
  42. doctorStr=doctor[i];
  43. }else {
  44. doctorStr+=","+doctor[i];
  45. }
  46. }
  47. }
  48. $.ajax({
  49. type: "POST",
  50. contentType: "application/json;charset=UTF-8",
  51. url: '/thmz/setConfig',
  52. dataType: "json",
  53. data: JSON.stringify({"configKey": "alarm_user","configValue": doctorStr}),
  54. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  55. success: function (res) {
  56. if (res == '401' || res == 401) {
  57. window.location.href = '/thmz/login/view'
  58. return;
  59. }
  60. if (res.code == 0) {
  61. successMesage(res);
  62. } else {
  63. errorMesage(res);
  64. }
  65. }
  66. });
  67. } else {
  68. errorMesage(res);
  69. }
  70. }
  71. });
  72. });
  73. });
  74. /**
  75. * 挂号列表中的科室列表
  76. */
  77. function initDeptSelect() {
  78. //科室列表
  79. $.ajax({
  80. type: "GET",
  81. url: '/thmz/allMzUnitCode',
  82. dataType: "json",
  83. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  84. success: function (data) {
  85. if (data == '401' || data == 401) {
  86. window.location.href = '/thmz/login/view'
  87. return;
  88. }
  89. var html = '<option value=""></option>';
  90. $.each(data.data, function (commentIndex, comment) {
  91. html += '<option value="' + comment.code + '">' + comment.name + '(' + comment.pyCode + ')</option>';
  92. });
  93. $('#deptNo').empty();
  94. $('#deptNo').html(html);
  95. $('#deptNo').selectpicker('refresh');
  96. $("#deptNo").selectpicker('val', '1400002');
  97. $("#deptNo").selectpicker('refresh');
  98. initDoctorSelect();
  99. }
  100. });
  101. }
  102. /**
  103. * 挂号列表中的医生列表初始化
  104. */
  105. function initDoctorSelect() {
  106. //医生列表
  107. $.ajax({
  108. type: "GET",
  109. url: '/thmz/listEmployeeByDepts?depts=' + $('#deptNo').val(),
  110. //url: '/thmz/listEmployeeByDepts?depts=null',
  111. dataType: "json",
  112. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  113. success: function (res) {
  114. if (res == '401' || res == 401) {
  115. window.location.href = '/thmz/login/view'
  116. return;
  117. }
  118. var html = '<option value=""></option>';
  119. $.each(res.data, function (commentIndex, comment) {
  120. html += '<option value="' + comment.employeeCode + '">' + comment.employeeName + ' (' + comment.deptName + ') </option>';
  121. });
  122. $('#doctor').empty();
  123. $('#doctor').html(html);
  124. $('#doctor').selectpicker('destroy').selectpicker('refresh');
  125. //告警人员设置
  126. $.ajax({
  127. type: "GET",
  128. url: '/thmz/getConfigByKey?key=alarm_user',
  129. dataType: "json",
  130. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  131. success: function (res) {
  132. if (res == '401' || res == 401) {
  133. window.location.href = '/thmz/login/view'
  134. return;
  135. }
  136. var doctorStr=res.data.configValue;
  137. if(doctorStr!=null && doctorStr!=''){
  138. var arr =doctorStr.split(",");
  139. $("#doctor").selectpicker('val', arr);
  140. $("#doctor").selectpicker('refresh');
  141. }
  142. }
  143. });
  144. }
  145. });
  146. }