123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- !function(){
- var httpData=GetRequest();
- var currentGMT=new Date();//当前时间GMT
- new Vue({
- el:"#app",
- data:{
- ynow: currentGMT.getFullYear(),//年份
- mnow: currentGMT.getMonth(),//月份(比实际少一个月---0开始至11)
- dnow: currentGMT.getDate(),//当前日
- currentDay:null,//带中文格式的当前年月
- currentDayForEn:null,//不带中文格式年月日2018/10/01如果写成/的话 转换成时间戳会变成北京时间8点
- calendarData:[],//日历数据
- timeAxisData:[],//时间轴数据
- __Data:[],//当前的年月(日历)
- __xData:[],//当前的年月(时间轴)
- status:null,//任务状态(0未完成,1已完成,2已预约)
- searchTask:null,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
- searchTaskName:null,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
- planId: httpData['planId'],
- patientCode: httpData['patientCode'],
- taskArr:[
- {code:1,name:'我的任务'},
- {code:2,name:'健康教育'},
- {code:3,name:'健康指导'},
- {code:4,name:'随访'},
- {code:5,name:'复诊'},
- ],
- statusArr:[
- {code:0,name:'未完成'},
- {code:1,name:'已完成'},
- {code:2,name:'已预约'},
- ],
- curTask:'',//快速查找是否点击了搜索按钮
- curTaskName:'',//快速查找是否点击了搜索按钮
- tabStatus:null,
- planInfo:{},
- docList:[]
- },
- mounted:function(){
- if(!this.planId){
- layer.msg('未传入计划id(planId)',{icon:2})
- }else{
- this.tabStatus=1;
- }
- this.planSchedule();
- this.serviceDoctorList();//获取服务医生列表
- this.bindEvents();
- },
- methods:{
- //获取计划表
- planSchedule:function(){
- var vm = this;
- var params = {
- planId: this.planId,
- patientCode: this.patientCode
- };
- rehaAPI.planSchedule(params).then(function(res){
- if(res.status == 200){
- vm.planInfo = res.data;
- vm.planInfo.tagClass = "tag-"+res.data.healthyConditionType;
- //patientImg:居民签名照/证件照,如果不为null的话说明居民已确认,显示康复完成明细
- if(vm.planInfo.status==2 && !vm.planInfo.patientImg){//任务全部完成时,显示完成提示框
- vm.showCompleteDailog();
- }else if(vm.planInfo.status==2 && vm.planInfo.patientImg){//居民已确认计划完成
- vm.tabStatus=3;
- $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId+"&completePlan=true")
- }
- }else{
- layer.msg(res.msg,{icon:5});
- }
- })
- },
- serviceDoctorList:function(){
- var vm = this;
- rehaAPI.serviceDoctorList({patientCode: this.patientCode}).then(function(res){
- if(res.status == 200){
- vm.docList = res.data;
- }else{
- layer.msg(res.msg,{icon:5});
- }
- })
- },
- weiXinConfirmClick:function(){
- var vm = this;
- rehaAPI.sendWxMsg({planId: this.planId}).then(function(res){
- if(res.status == 200){
- layer.msg("发送成功,等待居民确认");
- setTimeout(function(){
- vm.tabStatus=3;
- $("#framePage").attr("src","stop_special_service.html?planids="+vm.planId)
- },1000)
- }else{
- layer.msg(res.msg,{icon:5});
- }
- })
- },
- setImgSrc: function (src) {
- var str = httpRequest.getImgUrl(src)
- return str
- },
- showCompleteDailog:function(){
- layer.confirm('<div class="mt10 tac"><image src="../images/yiwancheng_icon.png" width="100" height="100"/><div class="mt20 c-f20 c-333 mb40">本次康复计划已完成</div><div class="div-patient-comfirm c-f14 c-fff bgc-12b7f5" style="margin:40px auto 20px;">邀请居民确认</div></div>', {
- btn: [],
- area: ["400px", "340px"],
- title: "完成提示"
- }, function (index) {
-
- // layer.close(index);
- });
- },
- refreshPage:function(){
- if(!this.planId){
- layer.msg('未传入计划id(planId)',{icon:2})
- return ;
- }
- this.goToLoadData(true);
- },
- bindEvents:function(){
- var vm = this;
- $("body").on("click",".div-patient-comfirm",function(){
- layer.closeAll();
- vm.weiXinConfirmClick();
- })
- },
- viewDetail:function(planids,status,type){
- var vm=this;
- if(!planids){
- layer.msg('无服务项',{icon:5})
- return ;
- }
- if(status==1 && type==1){
- top.layer.open({
- type: 2,
- area: ['800px', '650px'],
- shade: 0.5,
- title: '完成项目确认',
- fixed: true, //不固定
- maxmin: true,
- closeBtn:1,
- shift: 5,
- shadeClose: false, //点击遮罩关闭层
- content: '../../rehabilitation/html/guide_the_message.html?planid='+planids
- });
- return ;
- }
- // planids='402803f6657f195301657f4c4ce70000';
- layer.open({
- type: 2,
- area: ['800px', '650px'],
- shade: 0.5,
- title: '服务项目内容',
- fixed: true, //不固定
- maxmin: true,
- closeBtn:1,
- shift: 5,
- shadeClose: false, //点击遮罩关闭层
- content: '../../rehabilitation/html/service_item_content.html?planids='+planids,
- end:function(){
- vm.goToLoadData(true);
- }
-
- });
- },
- changeStatus:function(val){
- this.status=this.status==val?null:val;
- },
- changeTask:function(val){
- this.searchTask=this.searchTask==val.code?null:val.code;
- this.searchTaskName=this.searchTaskName==val.name?null:val.name;
- },
- monDetail:function(){
- this.currentDay = this.ynow + '年'+ (this.mnow + 1) +'月';
- this.currentDayForEn=this.ynow+'/'+(this.mnow>=9?(this.mnow+1):"0"+(this.mnow+1))+'/'+(this.dnow>=9?this.dnow:"0"+this.dnow)
- },
- is_leap:function(year) { //判断是否为闰年
- return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0));
- },
- preMonth:function(){ //上一个月
- if(this.mnow<=0){
- this.mnow=11;
- this.ynow=this.ynow-1;
- }else{
- this.mnow--;
- }
- this.monDetail();
- this.goToLoadData(true);
- },
- getPreMouth:function(){
- var pMnow,pYnow;
- if(this.mnow<=0){
- pMnow=11;
- pYnow=this.ynow-1;
- }else{
- pMnow=this.mnow-1;
- pYnow=this.ynow;
- }
- var m_days=new Array(31,(28+this.is_leap(pYnow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
- return {
- days:m_days[pMnow],
- date:pYnow+'-'+(++pMnow>=10?pMnow:"0"+pMnow)
- }
- },
- nextMonth:function(){ //下一个月
- if(this.mnow>=11){
- this.mnow=0;
- this.ynow=this.ynow+1;
- }else{
- this.mnow++;
- }
- this.monDetail();
- this.goToLoadData(true);
- },
- getNextMouth:function(){
- var nMnow,nYnow;
- if(this.mnow>=11){
- nMnow=0;
- nYnow=this.ynow+1;
- }else{
- nMnow=this.mnow+1;
- nYnow=this.ynow;
- }
- var m_days=new Array(31,(28+this.is_leap(nYnow)),31,30,31,01,31,31,30,31,30,31); //每个月的天数
- return {
- days:m_days[nMnow],
- date:nYnow+'-'+(++nMnow>=10?nMnow:"0"+nMnow)
- }
- },
- goToLoadData:function(flag){//flag是否更新数据
- this.tabStatus==1 && (!this.calendarData.length || flag) && this.calendar();
- this.tabStatus==2 && (!this.timeAxisData.length || flag) && this.timeAxis();
- },
- calendar:function(){
- var nlstr = new Date(this.ynow,this.mnow,1); //当月第一天
- var firstday = nlstr.getDay()-1;//第一天星期几,默认是周日 我们改成周一
- firstday=firstday==-1?6:firstday;//如果是-1,说明当月的第一天是周日
- var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
- var tr_str=Math.ceil((m_days[this.mnow] + firstday)/7); //当前月天数+第一天是星期几的数值 获得 表格行数
- var c_days=m_days[this.mnow];//当前月份的天数
- var p_arr=this.getPreMouth();
- var n_arr=this.getNextMouth();
- var i,k,idx,date_str;
- var dataArr=[];//天数/年月
- for(i=0;i<tr_str;i++) { //表格的行
- for(k=0;k<7;k++) { //表格每行的单元格
- idx=i*7+k; //单元格自然序列号
- date_str=idx-firstday+1; //计算日期
- var __ym;
- if(date_str<=0){//过滤无效日期(小于等于零的、大于月总天数的)
- date_str=date_str+p_arr['days'];//当前日期+上个月的天数就是上个月的日期
- __ym=p_arr['date'];
- }else if(date_str>c_days){
- date_str=date_str-c_days;//下个月的日期就是这个月的天数-当月的天数
- __ym=n_arr['date'];
- }else{
- __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
- }
- dataArr.push({
- day:date_str,
- date:__ym
- });
- }
- }
- this.__Data=dataArr;
- this.monDetail();
- this.calenderPlanDetail();
- },
- // 日历请求
- calenderPlanDetail:function(){
- var vm=this;
- var __days=vm.__Data;
- var lastDay=(__days.concat()).pop().day;
- lastDay=lastDay>9?lastDay:'0'+lastDay;
- var params={
- executeStartTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
- executeEndTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
- planId:vm.planId,//计划id
- searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
- status:vm.status,//任务状态(0未完成,1已完成,2已预约)
- }
- rehaAPI.calendarPlanDetail(params).then(function(res){
- vm.curTask=vm.searchTask;
- vm.curTaskName=vm.searchTaskName;
- vm.calendarData=[];
- var list = [];
- if(res.status==200){
- var data=res.data
- var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
- for(var i in __days){
- var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
- var item={
- noService:true,
- day:__days[i].day
- };
- for(var j in data){
- if(_key==j){
- item=data[j];
- item.day=__days[i].day;
- var finishFlag=false
- var sFlag=false;
- var fFlag=false;
- if(item.specialist){
- if(item.specialist.all==item.specialist.finish){
- sFlag=true;
- }
- }else{
- sFlag = true;
- }
- if(item.family){
- if(item.family.all==item.family.finish){
- fFlag = true;
- }
- }else{
- fFlag = true;
- }
- finishFlag = sFlag && fFlag;
- item.finishFlag=finishFlag;
- data.length && data.splice(j,1);
- break;
- }
- }
- var thatTime=+new Date(_key)-8*60*60*1000;
- var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
- item.future=future;
- list.push(item);
- // vm.calendarData.push(item);
- }
- vm.calendarData = _.chunk(list, 7)
- }
- })
- },
- // 时间轴请求
- timeAxis:function(){
- var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
- var c_days=m_days[this.mnow];//当前月份的天数
- var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
- var dataArr=[];//天数/年月
- for(;c_days>0;c_days--){
- dataArr.push({
- day:c_days,
- date:__ym
- });
- }
- this.__xData=dataArr;
- this.monDetail();
- this.calendarPlanDetailList();
- },
- // 时间轴请求
- calendarPlanDetailList:function(){
- var vm=this;
- var __days=vm.__xData;
- var lastDay=(__days.concat()).pop().day;
- lastDay=lastDay>9?lastDay:'0'+lastDay;
- var params={
- executeEndTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
- executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
- planId:vm.planId,//计划id
- searchTask:vm.searchTask,//快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
- status:vm.status,//任务状态(0未完成,1已完成,2已预约)
- }
- rehaAPI.calendarPlanDetailList(params).then(function(res){
- if(res.status==200){
- var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
- vm.timeAxisData=_.map(res.data||{},function(o){
- var _time=o.executeTime.split(' ');
- var thatTime=+new Date(_time[0]);
- var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
- (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
- var _html=o.status==2?'预':(future==-1?'逾':'');
- _html=future==1?'今':_html;
- if(_html=='预') future=3;
- o.html=_html
- o.date=_time[0];
- o.time=_time[1];
- o.future=future;
- return o;
- })||[];
- }
- console.log(vm.timeAxisData)
- })
- },
- changeSearch: function(status) {
- var i = status == 1 ? -400 : 0;
- var timer1 = setInterval(function() {
- i += (5 * status)
- $(".search-left").css("right", i + "px")
- if(status == 1 && i >= 0) {
- clearInterval(timer1)
- }
- if(status == -1 && i <= -400) {
- clearInterval(timer1)
- }
- }, 5)
- }
- },
- watch:{
- tabStatus:function(){
- this.goToLoadData();
- }
- }
- })
- }();
|