jc-xuanzejumin.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. var self,
  2. teamCode,
  3. diseaseCondition = -1,//居民标签
  4. disease = -1,//慢病类型
  5. deviceType = -1,//设备情况
  6. peopleCodes = [];//选择人数code
  7. // 获取登录相关信息
  8. var getBaseInfo = function(){
  9. self = plus.webview.currentWebview();
  10. teamCode = self.teamCode;
  11. },
  12. // 查询人数
  13. queryPeopleNum = function() {
  14. plus.nativeUI.showWaiting();
  15. var params ={
  16. teamCode:teamCode,
  17. disease:disease,
  18. diseaseCondition:diseaseCondition,
  19. deviceType:deviceType
  20. }
  21. sendPost("doctor/scheme/get/disease/patientcodes",params, function(){
  22. plus.nativeUI.closeWaiting();
  23. mui.toast("请求失败");
  24. }, function(res){
  25. plus.nativeUI.closeWaiting();
  26. if(res.status==200){
  27. peopleCodes = res.data;
  28. $('#allNum').text('全部'+peopleCodes.length+'人');
  29. }else{
  30. mui.toast("查询失败");
  31. }
  32. },'get')
  33. },
  34. // 绑定页面事件
  35. bindEvents = function (){
  36. $("#sendBtn").on('tap',function(){
  37. if(!$('#selTag_dummy').val()){
  38. mui.toast('请选择居民标签');
  39. return;
  40. }
  41. if(peopleCodes.length==0){
  42. mui.toast('至少选一个居民');
  43. return;
  44. }
  45. //取居民code
  46. mui.openWindow({
  47. id: "jc-xuanzefangan",
  48. url: "jc-xuanzefangan.html",
  49. extras: {
  50. pCodes:peopleCodes
  51. }
  52. })
  53. })
  54. }
  55. //慢病类型
  56. function fillSickDropdown(){
  57. var $id = $('#selSick'),
  58. data = [{'code':'-1','name':'全部病种'},{'code':'1','name':'高血压'},{'code':'2','name':'糖尿病'}],
  59. html="";
  60. for(i=0; i<data.length; i++){
  61. if(data[i].code == -1){html += '<option selected value="'+data[i].code+'">'+data[i].name+'</option>';}
  62. else{html += '<option value="'+data[i].code+'">'+data[i].name+'</option>'}
  63. }
  64. $id.html(html);
  65. $id.mobiscroll().select({
  66. theme: 'ios',lang: 'zh',display: 'bottom',rows:4,
  67. onSelect: function ( valueText, inst) {
  68. disease = inst._tempValue;
  69. queryPeopleNum()
  70. }
  71. })
  72. }
  73. //居民标签
  74. function fillTagDropdown(){
  75. var $id = $('#selTag'),
  76. data = [{'code':'-1','name':'全部居民'},{'code':'0','name':'绿标居民'},{'code':'1','name':'黄标居民'},{'code':'2','name':'红标居民'}],
  77. html="";
  78. for(i=0; i<data.length; i++){
  79. if(data[i].code == '-1'){html += '<option selected value="'+data[i].code+'">'+data[i].name+'</option>';}
  80. else{html += '<option value="'+data[i].code+'">'+data[i].name+'</option>'}
  81. }
  82. $id.html(html);
  83. $id.mobiscroll().select({
  84. theme: 'ios',lang: 'zh',display: 'bottom',rows:4,
  85. placeholder:'请选择居民标签',
  86. onSelect: function ( valueText, inst) {
  87. if(inst._tempValue.length == 3){
  88. $('#selTag_dummy').val('全部居民')
  89. diseaseCondition= -1
  90. }else{
  91. diseaseCondition=(inst._tempValue).join(',')
  92. }
  93. if(!$('#selTag_dummy').val()){
  94. $('#allNum').text('')
  95. }else{
  96. queryPeopleNum()
  97. }
  98. },
  99. onChange: function (event, inst){
  100. filterSer(event)
  101. },
  102. onShow: function (event, inst) {
  103. filterSer(inst)
  104. },
  105. })
  106. }
  107. function filterSer(name){
  108. var $li = $('.dw-bf').find('div.dw-li');
  109. $li.addClass('dw-v');
  110. var nameArr = name.split(',');
  111. $.map(nameArr,function(item,index){
  112. if(nameArr[0]){
  113. if(item.trim() == '全部居民'){
  114. var arr = [1,2,3]
  115. $.map(arr,function(it,index){
  116. $li.eq(it).removeClass('dw-v')
  117. })
  118. }else{
  119. var arr = [0]
  120. $.map(arr,function(it,index){
  121. $li.eq(it).removeClass('dw-v')
  122. })
  123. }
  124. }
  125. })
  126. }
  127. //设备绑定
  128. function fillDeptDropdown(){
  129. var $id = $('#selDept'),
  130. data = [{'code':'-1','name':'全部'},{'code':'1','name':'已绑定'},{'code':'0','name':'未绑定'}],
  131. html="";
  132. for(i=0; i<data.length; i++){
  133. if(data[i].code == '-1'){html += '<option selected value="'+data[i].code+'">'+data[i].name+'</option>';}
  134. else{html += '<option value="'+data[i].code+'">'+data[i].name+'</option>'}
  135. }
  136. $id.html(html);
  137. $id.mobiscroll().select({
  138. theme: 'ios',lang: 'zh',display: 'bottom',rows:4,
  139. onSelect: function ( valueText, inst) {
  140. deviceType = inst._tempValue;
  141. queryPeopleNum()
  142. }
  143. })
  144. }
  145. // 处理流程开始
  146. new Promise(function(resolve, reject){
  147. mui.plusReady(function(){
  148. resolve(true)
  149. })
  150. }).then(function(){
  151. getBaseInfo()
  152. bindEvents()
  153. fillTagDropdown()
  154. fillSickDropdown()
  155. fillDeptDropdown()
  156. $('.icon-come').show()
  157. queryPeopleNum()
  158. }).catch(function(e) {
  159. plus.nativeUI.closeWaiting()
  160. console && console.error(e)
  161. })