123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- //选择居委会 jwcode基卫的code 有直接提交功能
- //<div id="committee"></div>
- var ddd = dialog({contentType:'load', skin:'bk-popup',content:'数据提交中'});
- function selectCommittee(){
- var content = '<div id="sheet" class="mui-popover mui-popover-bottom mui-popover-action">\
- <div id="sheet_committee" style="height:314px;background-color: #fff;position: relative;">\
- <div class="md-title">所属居委会</div>\
- <div class="md-bttn-true">确定</div>\
- <div class="md-bttn-false">取消</div>\
- <ul class="md-tag" id="showTitle"></ul>\
- <div id="district" class="mui-scroll-wrapper md-wrapper">\
- <div class="mui-scroll" style="width:100%!important">\
- <ul class="mui-table-view"></ul>\
- </div>\
- </div>\
- <div id="town" class="mui-scroll-wrapper md-wrapper c-hide">\
- <div class="mui-scroll" style="width:100%!important">\
- <ul class="mui-table-view"></ul>\
- </div>\
- </div>\
- <div id="village" class="mui-scroll-wrapper md-wrapper c-hide">\
- <div class="mui-scroll" style="width:100%!important">\
- <ul class="mui-table-view"></ul>\
- </div>\
- </div>\
- </div>\
- </div>';
- $('body').append(content)
- nextWork()
-
- function nextWork(){
- var $tit = $('#showTitle'),
- $sel0 = '<li class="active">请选择</li>',
- $sel1='',
- $sel2='',
- $list = $('.md-wrapper'),
- $true = $('.md-bttn-true'),
- $false = $('.md-bttn-false');
- var countryCode,
- jwcode,
- countryName;
- $('#selectType').click(function(){
- mui('#sheet').popover('show');
- if(!$tit.text().trim()){
- $tit.html($sel0);
- var data={};
- sendPost('patient/sign/getTownList', data, 'json', 'get', queryAddrFailed ,function(res){
- if(res.status == 200){
- var list="";
- $.map(res.data,function(item,index){
- list +='<li data-code='+item.code+'>'+item.name+'</li>';
- })
- $('#district').find('ul').empty().append(list);
- }else{
- queryAddrFailed(res);
- }
- })
- }
- $true.hide();
- $false.show();
- })
-
- //请求数据
- function queryAddrFailed(res) {
- if (res && res.msg) {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据加载失败'}).show();
- }
- }
-
- mui('#village').scroll({
- bounce: false //是否启用回弹
- }).scrollTo(0,0,100);
- mui('#district').scroll({
- bounce: false //是否启用回弹
- })
- mui('#town').scroll({
- bounce: false //是否启用回弹
- }).scrollTo(0,0,100);
-
- //区
- $('#district').on('click','li',function(){
- var $this = $(this);
- changeList($('#town'),$this);
- $true.hide();
- $false.show();
- $sel1 = '<li>'+$this.text()+'</li>';
- $tit.html($sel1+$sel0);
- var data={
- town:$this.data('code')
- };
- sendPost('patient/sign/getStreetListByTown', data, 'json', 'get', queryAddrFailed ,function(res){
- if(res.status == 200){
- var list="";
- $.map(res.data,function(item,index){
- list +='<li data-code='+item.code+'>'+item.name+'</li>';
- })
- $('#town').find('ul').empty().append(list);
- }else{
- queryAddrFailed(res);
- }
- })
- })
- //街道
- $('#town').on('click','li',function(){
- var $this = $(this);
- changeList($('#village'),$this);
- $true.hide();
- $false.show();
- $sel2 = '<li>'+$this.text()+'</li>';
- $tit.html($sel1+$sel2+$sel0);
- var data={
- street:$this.data('code')
- };
- sendPost('patient/sign/getCountryListByStreet', data, 'json', 'get', queryAddrFailed ,function(res){
- if(res.status == 200){
- var list="";
- if(res.data.length>0){
- $.map(res.data,function(item,index){
- list +='<li data-jwcode='+item.jwCode+' data-code='+item.code+'>'+item.name+'</li>';
- })
- }else{
-
- }
- $('#village').find('ul').empty().append(list);
- }else{
- queryAddrFailed(res);
- }
- })
- })
- //居委会
- $('#village').on('click','li',function(){
- var $this = $(this);
- changeList($('#village'),$this);
- countryCode = $this.attr('data-code');
- jwcode = $this.attr('data-jwcode');
- countryName = $this.text();
- $true.show();
- $false.hide();
- })
-
- $tit.on('click','li',function(){
- var $this = $(this);
- if(! $this.hasClass('active')){
- $this.addClass('active').siblings().removeClass('active');
- $list.hide();
- $list.eq($this.index()).show();
- }
- })
- //取消
- $false.click(function(){
- mui('#sheet').popover('hide');
- })
- //确定
- $true.click(function(){
- mui('#sheet').popover('hide');
- ddd.show();
- var data={
- countryCode:countryCode
- };
- sendPost('patient/sign/updatePatientCountry', data, 'json', 'get',function(){
- ddd.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存失败'}).show();
- },function(res){
- if(res.status == 200){
- ddd.close();
- $('#committee').text(countryName);
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存成功'}).show();
- }else{
- ddd.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存失败'}).show();
- }
- })
- })
-
- function changeList($next,$li){
- $li.addClass('active').siblings().removeClass('active');
- $list.hide();
- $next.show();
- }
- }
- }
- //清空选择
- function clearCommittee(){
- $('#showTitle').text('');
- $('.md-wrapper').hide();
- $('#district').show();
- }
|