var httpData=GetRequest(); var userInfo = JSON.parse(window.localStorage.getItem(httpRequest.agentName)); var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent')); var previewLayerIndex, followupLayerIndex, KFZDlayerIndex; function closeGuidancePreview(){ layer.close(previewLayerIndex) } function closeFollowUpLayer(planDetaiId, relationCode){ if($.isArray(relationCode)) { $.each(relationCode, function(index, item){ top.serviceItemVue.saveRehabilitationOperateRecord(planDetaiId, 6, item) }) } else { top.serviceItemVue.saveRehabilitationOperateRecord(planDetaiId, 6, relationCode) } layer.close(followupLayerIndex) } function closeKFZDlayer(planDetaiId){ top.serviceItemVue.saveRehabilitationOperateRecord(planDetaiId, 5) layer.close(KFZDlayerIndex) } function showSuccessMessage(msg) { layer.msg(msg, { icon: 1 }) } function showErrorMessage(msg) { layer.msg(msg, { icon: 5 }) } top.serviceItemVue = new Vue({ el:"#app", data:{ planId: httpData['planId'], planids: httpData['planids'], patient: httpData['patient'], patientName: decodeURI(httpData['patientName']), serviceData:[ { relationRecordImg:{}, messageList:{} } ], isCollapse :false, collapseIndex:0, qrCode:'', qrModal:false, curDetailId: '', layerIndex: undefined }, mounted:function(){ this.getServiceItemList(); }, methods:{ // 提醒患者 num 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒 sendSpecialistWeixinMessage: function(planDetaiId, type){ var vm = this var text = '' if(type==4){ // 上门服务 text = '请问您是否确认提醒'+vm.patientName+'居民预约上门护理服务?' } else if(type==7){ // 康复复诊 text = '请问您是否确认提醒'+vm.patientName+'居民进行复诊?' } var current=layer.confirm(text, { btn: ['确定', '取消'], title: "提示" }, function (index) { var _type = type == 4? 4:type==7?3:'' var loading = layer.load(0, {shade: false}) var params = { patient: vm.patient, doctor: docInfo.uid, type: _type, relationCode: planDetaiId, planId: vm.planId } rehaAPI.sendSpecialistWeixinMessage(params).then(function(res){ layer.close(loading) if(res.status == 200){ showSuccessMessage('提交成功!') if(_type==3 || _type==4){ // 提醒患者后,即认为是已完成 vm.saveRehabilitationOperateRecord(planDetaiId, type) } } else { showErrorMessage(res.msg) } }) layer.close(current); //再执行关闭 }) }, viewDetial:function(type,code){ var vm=this; if(type==3||type==4){ var str=""; if(type==3){ str="健康指导记录"; } if(type==4){ str="随访记录" } top.layer.msg('客户端暂不支持查询'+str); }else{ top.layer.open({ type: 2, // offset: ['100px'], //右下角弹出 area: ['80%', '600px'], shade: 0.5, title: '指导教育', fixed: true, //不固定 maxmin: true, closeBtn: 1, shift: 5, shadeClose: false, //点击遮罩关闭层 content: '../../article/html/article-info.html?articleId=' + code, end: function() { // 未点击确定按钮,点击关闭按钮 vm.getServiceItemList();     } }); } }, chakan:function(){ this.isCollapse=!this.isCollapse; }, changeCollapseIndex:function(idx, o){ this.collapseIndex=idx; this.curDetailId = o.planDetaiId }, clickItem:function(service){ var vm=this layer.open({ type: 2, area: ['97%', '640px'], shade: 0.5, title: '服务项目内容', fixed: true, //不固定 maxmin: true, closeBtn:1, shift: 5, shadeClose: false, //点击遮罩关闭层 content: '../../rehabilitation/html/guide_the_message.html?planid='+service.planDetaiId+'&pId='+httpData['planId']+'&patient='+vm.patient+'&patientName='+vm.patientName, end:function(){ vm.getServiceItemList();     } }); }, qwapp:function(){ layer.msg('请前往app处理',{icon:5}); }, viewGuidance: function(o){ var vm = this previewLayerIndex = layer.open({ type: 2, area: ['380px', '600px'], shade: 0.5, title: '预览', fixed: true, //不固定 maxmin: true, closeBtn:1, shift: 5, shadeClose: false, //点击遮罩关闭层 content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode='+o.article }); }, //获取服务列表 getServiceItemList:function(){ var vm=this; var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent') || '{}'); var loadding = layer.load(0, {shade: false}); //0代表加载的风格,支持0-2 rehaAPI.serviceItemList({planDetailIds:vm.planids}).then(function(res){ layer.close(loadding); if(res.status==200){ var isZK=loginDoctor.doctorType==1?true:false; vm.serviceData=_.map(res.data||{},function(o, index){ o.isZK=isZK; if(o.isMyTask==1){//执行者 o.isCK=true;//无法显示按钮 if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者 o.isCK=false; o.isCreate=true; } }else{ if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者 o.isCreate=true; } } if(o.itemType == 4 || o.itemType == 5 || o.itemType == 7){ vm.getRelationRecord(index, o.itemType, o.planDetaiId).then(function(result){ if(result.status == 200){ o.relationList = result.data&&result.data.length>0?result.data:undefined vm.$forceUpdate() } }) } return o }) if(vm.serviceData.length>0){ vm.curDetailId = vm.serviceData[0].planDetaiId } if(!vm.planId&&vm.serviceData.length>0){ vm.planId = vm.curDetailId.planId } }else{ layer.msg(res.msg,{icon:5}); } }) }, getRelationRecord: function(index, type, planDetaiId){ // 1.电话短信 2.康复咨询 3.远程监控检测 4.上门服务 5.康复指导 6 康复随访 7.复诊) var vm = this var url='' if(type==5){ url='doctor/specialist/rehabilitation/selectByRelationCode' }else if(type==7){ url='third/guahao/selectByRelationCode' }else if(type==4){ url="/doctor/specialist/rehabilitation/selectRelationCode" } var vm = this var params = { relationCode: planDetaiId } return httpRequest.get(url, {data: params}) }, //康复指导 kfzd:function(planDetaiId){ var vm=this KFZDlayerIndex = layer.open({ type: 2, // offset: ['100px'], //右下角弹出 area: ['660px', '650px'], shade: 0.5, title: '康复指导', fixed: true, //不固定 maxmin: true, closeBtn: 1, shift: 5, shadeClose: false, //点击遮罩关闭层 content:'../../rehabilitation/html/rehabilitation_guidance.html?patient='+vm.patient+'&planDetaiId='+planDetaiId+'&planId='+vm.planId, end: function() { // 未点击确定按钮,点击关闭按钮 vm.getServiceItemList();     } }); }, // 康复随访计划 sfjh: function(planDetaiId){ var vm=this followupLayerIndex = layer.open({ type: 2, // offset: ['100px'], //右下角弹出 area: ['80%', '650px'], shade: 0.5, title: '随访计划', fixed: true, //不固定 maxmin: true, closeBtn: 1, shift: 5, shadeClose: false, //点击遮罩关闭层 content:'../../followup/html/followup_newplan.html?patient='+vm.patient+'&planDetaiId='+planDetaiId+'&planId='+vm.planId, end: function() { // 未点击确定按钮,点击关闭按钮 vm.getServiceItemList();     } }); }, saveRehabilitationOperateRecord:function(planDetailId, type, relationCode){ var vm=this; var params={ rehabilitationDetailId: planDetailId, node:null, patientCode: vm.patient, doctorCode: docInfo.uid, relationRecordType: type, relationRecordCode: '', relationRecordImg: null, status: 0 } rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){ if(res.status==200){ if(type==6){ vm.updateRelationCodeByDetailId(planDetailId, relationCode) } else{ vm.updateNoteAndImageRehabilitationOperate(planDetailId) } }else { showErrorMessage(res.msg) } }) }, updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) { var vm = this; var _image = []; for(var i in vm.upImgs) { _image.push(vm.upImgs[i].img); } var params = { planDetailId: planDetailId, node: '', image: '' } if(relationCode){ params['relationCode'] = relationCode } var loadding = top.layer.load(0, { shade: false }); //0代表加载的风格,支持0-2 rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) { top.layer.close(loadding); if(res.status == 200) { vm.getServiceItemList(); top.rehabilitationVue.refresh() }else { showErrorMessage(res.msg) } }) }, updateRelationCodeByDetailId: function(planDetailId, relationCode){ var vm = this var params = { planDetailId: planDetailId, relationCode: relationCode, } rehaAPI.updateRelationCodeByDetailId(params).then(function(res) { if(res.status == 200) { vm.getServiceItemList(); top.rehabilitationVue.refresh() } else { showErrorMessage(res.msg) } }) }, // 暂未开放 zwkf:function(){ layer.msg('此功能暂未开放',{icon:1}); }, goToFinish:function(planDetaiId){ var vm=this; layer.open({ type: 2, // offset: ['100px'], //右下角弹出 area: ['80%', '650px'], shade: 0.5, title: '完成项目确认', fixed: true, //不固定 maxmin: true, closeBtn:1, shift: 5, shadeClose: false, //点击遮罩关闭层 content: '../../rehabilitation/html/guide_the_message.html?planid='+planDetaiId+'&pId='+vm.planId+'&patient='+vm.patient+'&patientName='+vm.patientName, end: function() { // 未点击确定按钮,点击关闭按钮 vm.getServiceItemList();     } }); }, fwm:function(planid,patient){ this.loadSocket(planid,patient); }, zdly:function(data){ var vm = this var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent')); var otherCode,otherName; var planDetailId=''; // if(data.specialistDoctorCode==data.executeDoctorCode){ // layer.msg('无法与自己聊天',{icon:5}); // return ; // } if(docInfo.doctorType==1){ if(docInfo.uid == data.specialistDoctorCode) { //当前医生为创建计划的专科医生,与全科医生聊天 otherCode = data.familyDoctorCode; otherName = data.familyDoctorName; }else { //当前医生为专科,当前医生不是创建计划的专科医生,没反应 return false } }else{ //全科医生与专科医生聊天 otherCode = data.specialistDoctorCode; name = data.specialistDoctorName; } // if(data.isMyTask==1){ // otherCode=data.specialistDoctorCode; // otherName=data.specialistDoctorName; // }else{ // otherCode=data.executeDoctorCode; // otherName=data.executeDoctorCode; // } planDetailId=data.planDetaiId; layer.open({ type: 2, // offset: ['100px'], //右下角弹出 area: ['660px', '600px'], shade: 0.5, title: '指导留言', fixed: true, //不固定 maxmin: true, closeBtn:1, shift: 5, shadeClose: false, //点击遮罩关闭层 content: '../../consulting/html/consulting.html?otherCode='+otherCode+'&otherName='+encodeURI(otherName)+'&planDetailId='+planDetailId, end:function(){ // 未点击确定按钮,点击关闭按钮       vm.getServiceItemList();     } }); }, loadSocket:function(planid,patient){ var vm=this; var imurl=httpRequest.socketUrl; jQuery.getScript(imurl+"/socket.io/socket.io.js").done(function() { var socket = io.connect(imurl); var sessionId = 'system'; socket.emit('login', {userId: userInfo.uid, password: userInfo.uid,sessionId:sessionId,clientType:"doctor"}); socket.on('message', function (data) { console.log(data); if(data.type==1){ vm.goToFinish(planid); setTimeout(function(){ vm.qrModal=false; },1000/60) } }); socket.on('error', function (data) { console.log(data); }); socket.on('ack', function (data) { console.log(data); vm.getQRCode(planid); }); function getLocalTime(nS) { return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' '); } }) .fail(function() { layer.msg('服务码创建失败',{icon:5}); }); }, getQRCode:function(planid){ var vm=this; var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent')); var params={ planDetailId:planid, doctorCode: loginDoctor.uid } rehaAPI.createServiceQrCode(params).then(function(res){ console.log(res); if(res.status==200){ vm.qrCode=res.data; setTimeout(function(){ vm.qrModal=true; },1000/60) }else{ layer.msg('服务码获取失败',{icon:5}); } }) }, getContent: function(value,type) { var res=value; if(type==2 || type==9){ res = ""; }else if(type==3){ res = '【语音】'; }else if(type==19){ res = '【聊天记录】'; }else if(type==12){ res = '【视频】'; } return res; }, previewImg: function(url){ var src = httpRequest.getImgUrl(url); imgShow("#outerdiv", "#innerdiv", "#bigimg", src); } }, filters:{ formatDate:function(value, format) { if(!value) return ; var d = new Date(value); return d.format("yyyy-MM-dd hh:mm:ss"); }, getImgUrl: function(value) { var url = httpRequest.getImgUrl(value); return url; } } }) // $("body").on('click','img',function(){ // var _this = $(this);//将当前的img元素作为_this传入函数 // imgShow("#outerdiv", "#innerdiv", "#bigimg", _this); // }); function imgShow(outerdiv, innerdiv, bigimg, src){ // var src = _this.attr("src");//获取当前点击的pimg元素中的src属性 $(bigimg).attr("src", src);//设置#bigimg元素的src属性 /*获取当前点击图片的真实大小,并显示弹出层及大图*/ $("").attr("src", src).load(function(){ var windowW = $(window).width();//获取当前窗口宽度 var windowH = $(window).height();//获取当前窗口高度 var realWidth = this.width;//获取图片真实宽度 var realHeight = this.height;//获取图片真实高度 var imgWidth, imgHeight; var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放 if(realHeight>windowH*scale) {//判断图片高度 imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放 imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度 if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度 imgWidth = windowW*scale;//再对宽度进行缩放 } } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度 imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放 imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度 } else {//如果图片真实高度和宽度都符合要求,高宽不变 imgWidth = realWidth; imgHeight = realHeight; } $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放 var w = (windowW-imgWidth)/2;//计算图片与窗口左边距 var h = (windowH-imgHeight)/2;//计算图片与窗口上边距 $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性 $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg }); $(outerdiv).click(function(){//再次点击淡出消失弹出层 $(this).fadeOut("fast"); }); }