questionaires.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. var request = GetRequest();
  2. var pro_id = request['pro_id'],
  3. prescriptionCode = request['prescriptionCode'];
  4. var project_data;
  5. var $form = $("#question_form");
  6. var d = dialog({contentType:'load', skin:'bk-popup'});
  7. var dd = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'});
  8. function toast(msg){
  9. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
  10. }
  11. var initPage = function(){
  12. project_data = gTemplate[pro_id];
  13. var nameObj = {1:'症状',2:'体征及生活方式问卷'}
  14. var classes="";
  15. if(pro_id == 1){classes='1'}
  16. if(pro_id == 2){classes='2,4'}
  17. $('title').text(nameObj[pro_id])
  18. var params3 = {
  19. prescriptioncode:prescriptionCode,
  20. followupProject:classes
  21. }
  22. d.show()
  23. sendPost('patient/prescription/followupcontent/getinfo', params3, 'json', 'get',function(){
  24. d.close()
  25. toast('请求失败')
  26. }, function(res){
  27. d.close()
  28. if(res.status == 200){
  29. if(! $.isEmptyObject(res.data)){
  30. for(var key in project_data){
  31. project_data[key].value = res.data[key];
  32. }
  33. nextdo(false)
  34. }else{
  35. nextdo(true)
  36. }
  37. }
  38. })
  39. function nextdo(isBtn){
  40. var html = template("item", {data:project_data})
  41. $form.append(html);
  42. initMobiscroll()
  43. bindEvents()
  44. if(isBtn){
  45. $('#btn_group').show()
  46. $('#question_form').css('pointer-events','')
  47. }else{
  48. $('#btn_group').hide()
  49. $('#question_form').css('pointer-events','none')
  50. }
  51. }
  52. },
  53. initMobiscroll = function(){
  54. //绑定数字键盘
  55. $.each(document.querySelectorAll('input[type=number]'), function(index, el){
  56. var name = el.name;
  57. if(name=="HEART_RATE" || name == "HEIGHT" || name=="DAILY_SMOKING" || name=="CONTROL_EXERCISE_DURATION_MINS" || name=="SOMKING_EXP" || name=="EXERCISE_DURATION_MINS" || name=="EXERCISE_DURATION_MINS_EXP"){
  58. $(el).mobiscroll().numpad({
  59. theme: 'ios',
  60. display: 'bottom',
  61. lang: 'zh',
  62. placeholder: '0',
  63. fill: 'rtl',
  64. allowLeadingZero: true,
  65. template: 'ddd',
  66. scale:0,
  67. buttons: ['set','cancel'],
  68. onSelect: function(valueText, inst){
  69. var value = parseFloat($('.mbsc-np-dsp').text());
  70. $(this).val(value);
  71. }
  72. })
  73. }else if(name == "WEIGHT" || name=="DRINK_EXP" || name=="DAILY_DRINKING" || name=="DAILY_STAPLE" || name == "WEIGHT_EXP"){
  74. $(el).mobiscroll().numpad({
  75. theme: 'ios',
  76. display: 'bottom',
  77. lang: 'zh',
  78. placeholder: '0',
  79. fill: 'rtl',
  80. allowLeadingZero: true,
  81. template: 'ddd.d',
  82. scale:0,
  83. buttons: ['set','cancel'],
  84. onSelect: function(valueText, inst){
  85. var value = parseFloat($('.mbsc-np-dsp').text());
  86. $(this).val(value);
  87. }
  88. })
  89. }else{
  90. $(el).mobiscroll().numpad({
  91. theme: 'ios',
  92. display: 'bottom',
  93. lang: 'zh',
  94. placeholder: '0',
  95. buttons: ['set','cancel'],
  96. onSelect: function(valueText, inst){
  97. var value = parseFloat($('.mbsc-np-dsp').text());
  98. $(this).val(value);
  99. }
  100. })
  101. }
  102. })
  103. },
  104. bindEvents = function(){
  105. // 判断checkbox和radio控件
  106. $form.on("change","input[type=radio]",function(){
  107. $("#disable_save").hide();
  108. $("#active_save").show();
  109. var $this = $(this)
  110. if($this.attr('name') == "DAILY_DRINKING_f" || $this.attr('name') == "DAILY_SMOKING_f"){
  111. if($this.val()>0){//针对类型5
  112. $this.closest('ul').find('input[name=DAILY_SMOKING]').show()
  113. $this.closest('ul').find('input[name=DAILY_DRINKING]').show()
  114. $this.closest('ul').find('input[name=DAILY_SMOKING]').val('')
  115. $this.closest('ul').find('input[name=DAILY_DRINKING]').val('')
  116. }else{
  117. $this.closest('ul').find('input[name=DAILY_SMOKING]').hide()
  118. $this.closest('ul').find('input[name=DAILY_DRINKING]').hide()
  119. $this.closest('ul').find('input[name=DAILY_SMOKING]').val(0)
  120. $this.closest('ul').find('input[name=DAILY_DRINKING]').val(0)
  121. }
  122. }
  123. })
  124. $form.on("change","input[type!=radio]",function(){
  125. if(this.type =='checkbox'){
  126. if(this.checked){
  127. this.value = 1;
  128. nextDo(this)
  129. }else{
  130. this.value = 0;
  131. nextDo(this)
  132. }
  133. }
  134. if(this.type !='checkbox'){
  135. nextDo(this)
  136. }
  137. function nextDo($this){
  138. if($this.value && $this.value!="0"){
  139. $("#disable_save").hide();
  140. $("#active_save").show();
  141. }else{
  142. var list = $("input[type!=radio]"),
  143. len = list.length,
  144. empty = true;
  145. for(i=0; i< len; i++){
  146. var value = list[i].value;
  147. if(value && value!="0"){
  148. empty = false;
  149. }
  150. }
  151. if(empty){
  152. if(pro_id == 1){//有选低血糖特殊处理
  153. if($('input[name=HYPOG_REACT_CODE]:checked').val() == undefined){
  154. $("#disable_save").show();
  155. $("#active_save").hide();
  156. }
  157. }else{
  158. $("#disable_save").show();
  159. $("#active_save").hide();
  160. }
  161. }
  162. }
  163. }
  164. })
  165. $("#active_save").on("tap", function(){
  166. dd.show()
  167. var url = "patient/prescription/followupcontent/saveinfo",
  168. params = [],
  169. data = {};
  170. function addData(num,d){
  171. var alldata = {};
  172. alldata.followupProject = num;
  173. alldata.projectData = d;
  174. return alldata
  175. }
  176. $form.serializeArray().map(function(x){data[x.name]=x.value;});
  177. data = _.omit(data,'DAILY_SMOKING_f','DAILY_DRINKING_f')//过滤辅助判断
  178. if(pro_id == 2){
  179. var obj2={},obj4={};
  180. obj4 = _.omit(data,'HEART_RATE','HEIGHT','WEIGHT')
  181. obj2 = _.pick(data,'HEART_RATE','HEIGHT','WEIGHT')
  182. params.push(addData(2,obj2))
  183. params.push(addData(4,obj4))
  184. }
  185. if(pro_id == 1){
  186. params.push(addData(1,data))
  187. }
  188. sendPost(url,{followupProjectData:JSON.stringify(params),prescriptioncode:prescriptionCode,sendIM:"true"}, 'json', 'post',function(){
  189. dd.close()
  190. toast('请求失败')
  191. }, function(res){
  192. dd.close()
  193. if(res.status == 200){
  194. toast('提交成功')
  195. setTimeout(function(){
  196. window.history.back()
  197. },500)
  198. }
  199. })
  200. })
  201. }
  202. $(function(){
  203. //初始化页面内容
  204. initPage();
  205. })