123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- 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();
- }
- }
|