| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 | var d = dialog({contentType:'load', skin:'bk-popup'});var d2 = dialog({contentType:'load', skin:'bk-popup'});var dd = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'});var request = GetRequest();var patientCode = request['patient'],    patientName = decodeURI(request['name']),    prescriptionCode = request['prescriptionCode']; //处方的codevar jw_code = request['jw_code']var baseInfo = {};mui.init();//初始化单页viewvar viewApi = mui('#app').view({    defaultPage: '#main'});var view = viewApi.view;(function($) {    //处理view的后退与webview后退    var oldBack = $.back;    $.back = function() {        if (viewApi.canBack()) { //如果view可以后退,则执行view的后退            viewApi.back();        } else { //执行webview后退            oldBack();        }    };    //监听页面切换事件方案1,通过view元素监听所有页面切换事件,目前提供pageBeforeShow|pageShow|pageBeforeBack|pageBack四种事件(before事件为动画开始前触发)    //第一个参数为事件名称,第二个参数为事件回调,其中e.detail.page为当前页面的html对象    view.addEventListener('pageBeforeShow', function(e) {        console.log(e.detail.page.id + ' beforeShow');        if(e.detail.page.id == "list"){            //显示处方列表页面//          reloadListImage();            var list = listPage();            list.initPage();        }else if(e.detail.page.id == "main"){            console.log("back to main");            prescriptionCode = window.localStorage.getItem("prescriptionCode");            window.localStorage.removeItem("prescriptionCode");            getPrescriptionDetail(prescriptionCode);        }    });    view.addEventListener('pageShow', function(e) {//      console.log(e.detail.page.id + ' show');    });    view.addEventListener('pageBeforeBack', function(e) {//      console.log(e.detail.page.id + ' beforeBack');    });    view.addEventListener('pageBack', function(e) {//      console.log(e.detail.page.id + ' back');    });})(mui);$(function(){    //判断是否可以续方咨询,并且获得咨询对象的信息    isPrescriptionConsult();    if(jw_code){        //获得处方信息        getPrescriptionDetail(jw_code);    }else if(prescriptionCode){        //获得处方信息        getPrescriptionDetail(prescriptionCode);    }    bindEvents();});//判断是否可以续方咨询,并且获得咨询对象的信息function isPrescriptionConsult(){    d2.show();    var url = '/patient/consult/isPrescriptionConsult',        params = {patient: patientCode};    sendPost(url, params, 'json', 'get', queryFailed, function(res){        if(res.status == 200){        	d2.close()            baseInfo = res.data;            $("#patientName").text(patientName);            $("#docName").text(baseInfo.doctorName);            $("#checkDocName").text(baseInfo.doctorName);            $("#dept").text(baseInfo.hospitalName);            //增加续方说明选择文本            var html = template('explain_tmp', {list: res.data.prescriptionExplain});            $("#explain").empty().append(html);        }else{            queryFailed(res);        }    });}//获得处方信息function getPrescriptionDetail(code){    //TODO     d.showModal();    var url = '/patient/prescriptionInfo/getPrescription',        params = {code: code};    sendPost(url, params, 'json', 'get', queryFailed, function(res){        if(res.status == 200){            d.close();            var str = "";            for(i=0; i<res.data.prescriptionDt.length; i++){                str += res.data.prescriptionDt[i].healthProblemName+" ";            }            for(j=0; j<res.data.prescriptionInfo.length; j++){                if(j < 2){                    var item = res.data.prescriptionInfo[j];                    str += item.drugName + ' ' + item.num+item.drugNumUnitName+' ';                }            }            $("#preInfo").text(str);        }else{            queryFailed(res);        }    });}function bindEvents(){    $("#consultType").mobiscroll({        theme: 'ios',        lang: 'zh',        customWheels: true,        wheels: [            [{                keys: [1,2,3],                values: ['高血压-续方咨询', '糖尿病-续方咨询','高&糖-续方咨询']            }]        ],        onSelect: function(valueText, inst){            var dd = eval("[" + valueText + "]"),                k = dd[0].keys,                v = dd[0].values;            $("#consultType").val(v);            $("#consultType").attr("data-type", k);        }    });        //  $("#preInfo").on('click', function(){//      //跳转去处方选择页面时,缓存textarea内的信息//      var text = $("textarea").val().trim();//      if(text.length > 0){//          window.localStorage.setItem("precontent", text);//      }//      window.location.href = "prescription-selection.html";//  });        $("textarea").on("input", function(){        var text = $(this).val().trim(),            len = text.length;        $("#count").text(len);    });        //选择续方说明文本,直接将内容添加到textarea中    $("#explain").on('click', '.text-tag', function(){        var $this = $(this),            text = $this.text(),            tatext = $("textarea").val();        if($this.hasClass("active")){            $this.removeClass("active");            var a = tatext.split(text);            tatext = a.join("");            $("textarea").val(tatext);            $("#count").text(tatext.length);        }else{            $this.addClass("active");            tatext += text;            $("textarea").val(tatext);            $("#count").text(tatext.length);        }    });        var count = 0;    $("#commit").on('click', function(){        count ++;        if(count > 1){            return false;        }        //判断是否选择了咨询类型        var consultType = $("#consultType").val();        if(!consultType){            dialog({                contentType: 'tipsbox',                content: '请选择咨询类型',                skin:'bk-popup',                closeTime: 2000            }).showModal();            count = 0;            return false;        }                //判断是否存在处方信息        if(!jw_code && !prescriptionCode){            dialog({                contentType: 'tipsbox',                content: '请选择需要续方的处方记录',                skin: 'bk-popup',                closeTime: 2000            }).showModal();            count = 0;            return false;        }                d.showModal();        var url = "/patient/consult/addPrescriptionConsult",            params = {                jwCode: prescriptionCode || jw_code, //处方的code                doctor: baseInfo.doctor,                adminTeamId: baseInfo.adminTeamId,                reason: $("textarea").val().trim(),                type: $("#consultType").attr("data-type")            };        sendPost(url, params, 'json', 'post', queryFailed, function(res){            count = 0;            d.close()            if(res.status == 200){            	dialog({			        content: '已提交咨询,是否填写随访调查,作为医生审核续方的参考数据',			        okValue:'是',			        cancelValue: '否',					cancel: function () {						window.location.href = "prescription-consulting.html?consult="+res.data.consult+"&toUser="+patientCode;					},			        ok: function (){				            					        	window.location.href = "suifangdiaocha.html?consult="+res.data.consult+"&prescriptionCode="+res.data.relationCode;			        }				}).showModal()            }else{                queryFailed(res)            }        })    })    //  window.onpageshow = function(){//      var isReload = window.localStorage.getItem('reload');//      if(isReload){//          window.localStorage.removeItem('reload');//          var ua = navigator.userAgent;//          if(ua.toLowerCase().indexOf('iphone') > -1){//              window.location.reload();//          }//      }//  }}function queryFailed(res, message){    d.close();    if(message){        dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show();    }else{        if (res && res.msg) {            dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();        } else {            dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();        }    }    }
 |