Request = GetRequest(); var selectedTab = Request['selectedTab'], $xtUl = $('#xt-ul'), $xyUl = $('#xy-ul'), $scroll = $('#iScroll'); var d = dialog({ contentType: 'load', skin: 'bk-popup' }); $(function(){ if(selectedTab == 2){ $('#jc-Type li').removeClass("active"); $('#jc-Type li:eq(1)').addClass("active"); } queryXTData(); bindEvents(); }) function queryXTData(){ var url = "/patient/scheme/getPatientScheme", params = { type: selectedTab //1血糖 2血压 }; sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) { if(res.status == 200) { if(selectedTab == 1){ $xyUl.hide(); $xtUl.show(); if(res.data && res.data.name){ //周日放后 var data = res.data data.list = _.sortBy(res.data.list, function(o) { return o.dayofweek == 1? 8: o.dayofweek; }) var html = template('xt-tmp',{data:data}) $('#xt-ul').html(html) }else{ //获取默认的监测方案 getDefaultScheme(selectedTab); } }else{ $xyUl.show(); $xtUl.hide(); //周日放后 if(res.data && res.data.name){ var data = res.data data.list = _.sortBy(res.data.list, function(o) { return o.dayofweek == 1? 8: o.dayofweek; }) var html = template('xy-tmp',{data:data}) $('#xy-ul').html(html) }else{ //获取默认的监测方案 getDefaultScheme(selectedTab); } } } else { queryFailed(res); } }); } function getDefaultScheme(type){ var url = "/patient/scheme/getDefaultScheme", params = { type: type //1血糖 2血压 }; sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) { if(res.status == 200) { if(type==1){ //周日放后 var data = res.data data.list = _.sortBy(res.data.list, function(o) { return o.dayofweek == 1? 8: o.dayofweek; }) data.isDefault = 'default'; var html = template('xt-tmp',{data:data}) $('#xt-ul').html(html) }else{ var data = res.data data.list = _.sortBy(res.data.list, function(o) { return o.dayofweek == 1? 8: o.dayofweek; }) data.isDefault = 'default'; var html = template('xy-tmp',{data:data}) $('#xy-ul').html(html) } } else { queryFailed(res); } }) } function bindEvents(){ //切换类型 $('#jc-Type').on('tap','li',function(){ var $this = $(this) if(!$this.hasClass('active')){ $this.addClass('active').siblings().removeClass('active'); if($this.attr('data-type') == 2){ selectedTab = 2; // $xyUl.show(); // $xtUl.hide(); queryXTData(); }else{ selectedTab = 1; // $xyUl.hide(); // $xtUl.show(); queryXTData(); } } }) //展开 $scroll.on('tap','.fa-up',function(){ var $this = $(this) if($this.hasClass('active')){ $this.removeClass('active') $this.siblings('.fa-down').hide() }else{ $this.addClass('active') $this.siblings('.fa-down').show() } }) //绑定默认的监测方案 $('body').on('tap','.select',function(){ var $this = $(this); var type = $this.attr('data-type') $this.removeClass('select-active'); setPatientDefaultScheme(type,$this); }) } function setPatientDefaultScheme(type,target){ var url = "/patient/scheme/setPatientDefaultScheme", params = { type: type //1血糖 2血压 }; sendPost(url, params, 'JSON', 'POST', queryFailed, function(res) { if(res.status == 200) { dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '选择成功' }).show(); target.hide(); $('.discription').hide(); } else { queryFailed(res); } }) } function queryFailed(res) { d.close(); if(res && res.msg) { dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: res.msg }).show(); } else { dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '加载失败' }).show(); } }