(function (c) { config.init(); var startDate = (new Date()).pattern('yyyy-MM-dd');//起始时间 var endDate = ( new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * 8) ).pattern('yyyy-MM-dd');//结束时间 var selectedDate = window.Fx.getUrlParam('date') || (new Date()).pattern('yyyy-MM-dd');//选择的时间 var a = { hospitalId: Fx.getUrlParam("hospitalId"), deptId: Fx.getUrlParam("deptId"), startDate: startDate, endDate: endDate }; //顶部月份 var month = (new Date()).pattern('M'); var e_month = ''; switch (month){ case '1':e_month = 'Jan';break; case '2':e_month = 'Feb';break; case '3':e_month = 'Web';break; case '4':e_month = 'Apr';break; case '5':e_month = 'May';break; case '6':e_month = 'Jun';break; case '7':e_month = 'Jly';break; case '8':e_month = 'Aug';break; case '9':e_month = 'Sept';break; case '10':e_month = 'Oct';break; case '11':e_month = 'Nov';break; case '12':e_month = 'Dec';break; default : e_month = 0; } c('#month').html(''); c('#month').append(''+month+'' + '' + '
'+e_month+'
'); //请求顶部日期 c.ajax({ type: "get", url: window.apiUrl+"getEnableTime.php?day=8&callback=jsonp", dataType: "jsonp", data: c.extend(window.hzAPI.getToken(), a), jsonp: "callback", async: false, crossDomain: true, complete: window.hzAPI.dialog(false,window.hzAPI.options.timeout,'数据请求中,请稍后'), success:function (data) { // console.log(data); c('.headdate .right').html(''); var ulStr = ''; //生成顶部日期 for(var i in data){ for(var j in data[i]){ if( data[i][j] && j == selectedDate ){ ulStr += '
  • ' + '
    '+new Date(j).pattern('E')+'
    ' + '
    '+j.split('-')[2]+'
    ' + '
  • '; }else if( data[i][j]){ ulStr += '
  • ' + '
    '+new Date(j).pattern('E')+'
    ' + '
    '+j.split('-')[2]+'
    ' + '
  • '; }else if( !data[i][j] && j == selectedDate){ ulStr += '
  • ' + '
    '+new Date(j).pattern('E')+'
    ' + '
    '+j.split('-')[2]+'
    ' + '
  • '; }else { ulStr += '
  • ' + '
    '+new Date(j).pattern('E')+'
    ' + '
    '+j.split('-')[2]+'
    ' + '
  • '; } } } c('.headdate .right').html(ulStr); //绑定顶部事件 c('.headdate .right li').click(function (e) { window.location.href = window.location.href.split('&date')[0]+'&date='+c(e.currentTarget).attr('name'); }); }, error: function (error) { window.hzAPI.dialog(false, window.hzAPI.options.timeout, "网络链接失败"); }, timeout: 9000 }); var b = { hospitalId: Fx.getUrlParam("hospitalId"), deptId: Fx.getUrlParam("deptId"), startDate: startDate, endDate: startDate, callback: 'callback' }; if(window.Fx.getUrlParam('date')){ b = { hospitalId: Fx.getUrlParam("hospitalId"), deptId: Fx.getUrlParam("deptId"), startDate: Fx.getUrlParam("date"), endDate: Fx.getUrlParam("date"), callback: 'callback' } } //请求医生 c.ajax({ type: "get", url: window.apiUrl+"getRegInfo.php", dataType: "jsonp", data: c.extend(window.hzAPI.getToken(), b), jsonp: "callback", async: false, crossDomain: true, complete: window.hzAPI.dialog(false,window.hzAPI.options.timeout,'数据请求中,请稍后'), success:function (data) { //todo 返回了false,不允许频繁请求接口 //初始化内容 c('#morning').html(''); c('#afternoon').html(''); if(data!=false && data && data.Schedules){ var doctorList = data.Schedules.Schedule; if(doctorList instanceof Array){ console.log(doctorList); }else{ doctorList = [doctorList]; } for(var i = 0; i < doctorList.length; i++){ var docinfo = doctorList[i]; var docStr = '',btnStr = ''; if(docinfo.AvailableLeftNum > 0){ btnStr = ''; }else{ btnStr = ''; } docStr = '
  • ' + '
    ' + '' + '
    ' + '
    ' + '
    ' + docinfo.DoctorName + '
    ' + '
    ' + docinfo.DoctorTitle + '
    ' + '
    ' + '
    ' + btnStr '
    ' + '
  • '; //下午 if(doctorList[i].SessionCode == 'X'){ c('#afternoon').append(docStr); } else if (doctorList[i].SessionCode == 'S') { c('#morning').append(docStr); } } } //添加提示文案 if(c('#afternoon li').length<1){ c('#afternoon').append('
  • 暂无排班记录
  • '); } //添加提示文案 if(c('#morning li').length<1){ c('#morning').append('
  • 暂无排版记录
  • '); } c('button').click(function (e) { window.location.href = window.location.origin + window.location.pathname.replace('appointmentDoctorList','doctorWho') + '?hospitalId=' + window.Fx.getUrlParam('hospitalId') + '&deptId=' + window.Fx.getUrlParam('deptId') + '&doctorId=' + e.currentTarget.id +'&date=' + selectedDate; }); }, error: function (error) { window.hzAPI.dialog(false, window.hzAPI.options.timeout, "网络链接失败"); }, timeout: 9000 }); // hzAPI.getData(window.apiUrl+"?c=api&a=getRegInfo", a, ".right"); })(Zepto);