select-committee.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //选择居委会 jwcode基卫 id:committee
  2. function selectCommittee(){
  3. var content = '<div id="sheet" class="mui-popover mui-popover-bottom mui-popover-action">\
  4. <div id="sheet_committee" style="height:314px;background-color: #fff;position: relative;">\
  5. <div class="md-title">所属居委会</div>\
  6. <div class="md-bttn-true">确定</div>\
  7. <div class="md-bttn-false">取消</div>\
  8. <ul class="md-tag" id="showTitle"></ul>\
  9. <div id="district" class="mui-scroll-wrapper md-wrapper">\
  10. <div class="mui-scroll" style="width:100%!important">\
  11. <ul class="mui-table-view"></ul>\
  12. </div>\
  13. </div>\
  14. <div id="town" class="mui-scroll-wrapper md-wrapper c-hide">\
  15. <div class="mui-scroll" style="width:100%!important">\
  16. <ul class="mui-table-view"></ul>\
  17. </div>\
  18. </div>\
  19. <div id="village" class="mui-scroll-wrapper md-wrapper c-hide">\
  20. <div class="mui-scroll" style="width:100%!important">\
  21. <ul class="mui-table-view"></ul>\
  22. </div>\
  23. </div>\
  24. </div>\
  25. </div>';
  26. $('body').append(content)
  27. nextWork()
  28. function nextWork(){
  29. var $tit = $('#showTitle'),
  30. $sel0 = '<li class="active">请选择</li>',
  31. $sel1='',
  32. $sel2='',
  33. $list = $('.md-wrapper'),
  34. $true = $('.md-bttn-true'),
  35. $false = $('.md-bttn-false');
  36. var countryCode,
  37. jwcountryCode,
  38. countryName;
  39. $('#selectType').click(function(){
  40. mui('#sheet').popover('show');
  41. if(!$tit.text().trim()){
  42. $tit.html($sel0);
  43. var data={};
  44. sendPost('patient/sign/getTownList', data, 'json', 'get', queryAddrFailed,function(res){
  45. if(res.status == 200){
  46. var list="";
  47. $.map(res.data,function(item,index){
  48. list +='<li data-code='+item.code+'>'+item.name+'</li>';
  49. })
  50. $('#district').find('ul').empty().append(list);
  51. }else{
  52. queryAddrFailed()
  53. }
  54. })
  55. }
  56. $true.hide();
  57. $false.show();
  58. })
  59. //请求数据
  60. function queryAddrFailed() {
  61. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup',content:'请求数据失败'}).show();
  62. }
  63. mui('#village').scroll({
  64. bounce: false //是否启用回弹
  65. }).scrollTo(0,0,100);
  66. mui('#district').scroll({
  67. bounce: false //是否启用回弹
  68. })
  69. mui('#town').scroll({
  70. bounce: false //是否启用回弹
  71. }).scrollTo(0,0,100);
  72. //区
  73. $('#district').on('click','li',function(){
  74. var $this = $(this);
  75. changeList($('#town'),$this);
  76. $true.hide();
  77. $false.show();
  78. $sel1 = '<li>'+$this.text()+'</li>';
  79. $tit.html($sel1+$sel0);
  80. var data={
  81. town:$this.data('code')
  82. };
  83. sendPost('patient/sign/getStreetListByTown', data, 'json', 'get', queryAddrFailed ,function(res){
  84. if(res.status == 200){
  85. var list="";
  86. $.map(res.data,function(item,index){
  87. list +='<li data-code='+item.code+'>'+item.name+'</li>';
  88. })
  89. $('#town').find('ul').empty().append(list);
  90. }else{
  91. queryAddrFailed()
  92. }
  93. })
  94. })
  95. //街道
  96. $('#town').on('click','li',function(){
  97. var $this = $(this);
  98. changeList($('#village'),$this);
  99. $true.hide();
  100. $false.show();
  101. $sel2 = '<li>'+$this.text()+'</li>';
  102. $tit.html($sel1+$sel2+$sel0);
  103. var data={
  104. street:$this.data('code')
  105. };
  106. sendPost('patient/sign/getCountryListByStreet', data, 'json', 'get', queryAddrFailed ,function(res){
  107. if(res.status == 200){
  108. var list="";
  109. if(res.data.length>0){
  110. $.map(res.data,function(item,index){
  111. list +='<li data-jwcode='+item.jwCode+' data-code='+item.code+'>'+item.name+'</li>';
  112. })
  113. }else{
  114. }
  115. $('#village').find('ul').empty().append(list);
  116. }else{
  117. queryAddrFailed()
  118. }
  119. })
  120. })
  121. //居委会
  122. $('#village').on('click','li',function(){
  123. var $this = $(this);
  124. changeList($('#village'),$this);
  125. countryCode = $this.attr('data-code');
  126. jwcountryCode = $this.attr('data-jwcode');
  127. countryName = $this.text();
  128. $true.show();
  129. $false.hide();
  130. })
  131. $tit.on('click','li',function(){
  132. var $this = $(this);
  133. if(! $this.hasClass('active')){
  134. $this.addClass('active').siblings().removeClass('active');
  135. $list.hide();
  136. $list.eq($this.index()).show();
  137. }
  138. })
  139. //取消
  140. $false.click(function(){
  141. mui('#sheet').popover('hide');
  142. })
  143. //确定
  144. $true.click(function(){
  145. mui('#sheet').popover('hide');
  146. $('#committee').val(countryName);
  147. $('#committee').attr('data-code',countryCode);
  148. $('#committee').attr('data-jwcode',jwcountryCode);
  149. })
  150. function changeList($next,$li){
  151. $li.addClass('active').siblings().removeClass('active');
  152. $list.hide();
  153. $next.show();
  154. }
  155. }
  156. }