monitor-program.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. Request = GetRequest();
  2. var selectedTab = Request['selectedTab'],
  3. $xtUl = $('#xt-ul'),
  4. $xyUl = $('#xy-ul'),
  5. $scroll = $('#iScroll');
  6. var d = dialog({
  7. contentType: 'load',
  8. skin: 'bk-popup'
  9. });
  10. $(function(){
  11. if(selectedTab == 2){
  12. $('#jc-Type li').removeClass("active");
  13. $('#jc-Type li:eq(1)').addClass("active");
  14. }
  15. queryXTData();
  16. bindEvents();
  17. })
  18. function queryXTData(){
  19. var url = "/patient/scheme/getPatientScheme",
  20. params = {
  21. type: selectedTab //1血糖 2血压
  22. };
  23. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) {
  24. if(res.status == 200) {
  25. if(selectedTab == 1){
  26. $xyUl.hide();
  27. $xtUl.show();
  28. if(res.data && res.data.name){
  29. //周日放后
  30. var data = res.data
  31. data.list = _.sortBy(res.data.list, function(o) {
  32. return o.dayofweek == 1? 8: o.dayofweek;
  33. })
  34. var html = template('xt-tmp',{data:data})
  35. $('#xt-ul').html(html)
  36. }else{
  37. //获取默认的监测方案
  38. getDefaultScheme(selectedTab);
  39. }
  40. }else{
  41. $xyUl.show();
  42. $xtUl.hide();
  43. //周日放后
  44. if(res.data && res.data.name){
  45. var data = res.data
  46. data.list = _.sortBy(res.data.list, function(o) {
  47. return o.dayofweek == 1? 8: o.dayofweek;
  48. })
  49. var html = template('xy-tmp',{data:data})
  50. $('#xy-ul').html(html)
  51. }else{
  52. //获取默认的监测方案
  53. getDefaultScheme(selectedTab);
  54. }
  55. }
  56. } else {
  57. queryFailed(res);
  58. }
  59. });
  60. }
  61. function getDefaultScheme(type){
  62. var url = "/patient/scheme/getDefaultScheme",
  63. params = {
  64. type: type //1血糖 2血压
  65. };
  66. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) {
  67. if(res.status == 200) {
  68. if(type==1){
  69. //周日放后
  70. var data = res.data
  71. data.list = _.sortBy(res.data.list, function(o) {
  72. return o.dayofweek == 1? 8: o.dayofweek;
  73. })
  74. data.isDefault = 'default';
  75. var html = template('xt-tmp',{data:data})
  76. $('#xt-ul').html(html)
  77. }else{
  78. var data = res.data
  79. data.list = _.sortBy(res.data.list, function(o) {
  80. return o.dayofweek == 1? 8: o.dayofweek;
  81. })
  82. data.isDefault = 'default';
  83. var html = template('xy-tmp',{data:data})
  84. $('#xy-ul').html(html)
  85. }
  86. } else {
  87. queryFailed(res);
  88. }
  89. })
  90. }
  91. function bindEvents(){
  92. //切换类型
  93. $('#jc-Type').on('tap','li',function(){
  94. var $this = $(this)
  95. if(!$this.hasClass('active')){
  96. $this.addClass('active').siblings().removeClass('active');
  97. if($this.attr('data-type') == 2){
  98. selectedTab = 2;
  99. // $xyUl.show();
  100. // $xtUl.hide();
  101. queryXTData();
  102. }else{
  103. selectedTab = 1;
  104. // $xyUl.hide();
  105. // $xtUl.show();
  106. queryXTData();
  107. }
  108. }
  109. })
  110. //展开
  111. $scroll.on('tap','.fa-up',function(){
  112. var $this = $(this)
  113. if($this.hasClass('active')){
  114. $this.removeClass('active')
  115. $this.siblings('.fa-down').hide()
  116. }else{
  117. $this.addClass('active')
  118. $this.siblings('.fa-down').show()
  119. }
  120. })
  121. //绑定默认的监测方案
  122. $('body').on('tap','.select',function(){
  123. var $this = $(this);
  124. var type = $this.attr('data-type')
  125. $this.removeClass('select-active');
  126. setPatientDefaultScheme(type,$this);
  127. })
  128. }
  129. function setPatientDefaultScheme(type,target){
  130. var url = "/patient/scheme/setPatientDefaultScheme",
  131. params = {
  132. type: type //1血糖 2血压
  133. };
  134. sendPost(url, params, 'JSON', 'POST', queryFailed, function(res) {
  135. if(res.status == 200) {
  136. dialog({
  137. contentType: 'tipsbox',
  138. skin: 'bk-popup',
  139. content: '选择成功'
  140. }).show();
  141. target.hide();
  142. $('.discription').hide();
  143. } else {
  144. queryFailed(res);
  145. }
  146. })
  147. }
  148. function queryFailed(res) {
  149. d.close();
  150. if(res && res.msg) {
  151. dialog({
  152. contentType: 'tipsbox',
  153. skin: 'bk-popup',
  154. content: res.msg
  155. }).show();
  156. } else {
  157. dialog({
  158. contentType: 'tipsbox',
  159. skin: 'bk-popup',
  160. content: '加载失败'
  161. }).show();
  162. }
  163. }