123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- // 基本信息(包括userAgent)
- var baseInfo = null,
- // 基础环境信息(包括当前webview、encry相关)
- baseEnv = null,
- docInfo = null,
- fv_id = null,
- followupClass = null, //记录随访类型 高血压或糖尿病
- noFillItem = 0,
- patientCode = null, //记录患者code
- otherPeople = '',
- fv_status = null, //记录随访状态
- prescriptionStatus,
- prescriptionCode ="";//续方
- var reference = ""; //记录前一个页面的id
-
- var $proList = $("#project_list");
- // 获取登录相关信息
- var getBaseInfo = function() {
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- prescriptionCode = baseEnv.webview.prescriptionCode;
- fv_id = baseEnv.webview.followup_id;
- fv_status = baseEnv.webview.status;
- reference = baseEnv.webview.reference;
- otherPeople = baseEnv.webview.otherPeople;
- //获取续方状态
- if(prescriptionCode){
- sendGet('doctor/prescriptionInfo/getContinuedPrescriptionAsDoctor',{code: prescriptionCode,type:1}, null, function(res){
- if(res.status == 200) {
- prescriptionStatus = res.data.prescription.status;
- isShowBtn()
- }else{
- mui.toast('获取续方状态失败')
- isShowBtn()
- }
- })
- }else{
- isShowBtn()
- }
- // 登录的相关信息
- var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
- return {
- userAgent: userAgent
- }
- },
- // 获取基础环境信息
- getBaseEnvPromise = function () {
- var env = {
- webview: plus.webview.currentWebview()
- };
- mui.back = function(){
- backAction();
- }
- // 因为有异步请求,需要等待数据返回之后进行处理,所以返回Promise
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- isShowBtn = function(){
- //非操作人员
- if(otherPeople || (prescriptionStatus>=0 && prescriptionStatus < 40)){
- $('#completeSec').hide();
- }else{
- setTimeout(function(){
- $('#completeSec').show();
- },1000)
- }
- },
- initPage = function(){
- noFillItem = 0;
- if(fv_status == 1){
- $("#complete").text("保存修改");
- }
-
- //获取随访计划详情
- plus.nativeUI.showWaiting();
- var url = "doctor/followup/getFollowup";
- sendPost(url,{id: fv_id}, null, function(res){
- if(res.status == 200) {
- patientCode = res.data.patientCode;
- $(".docInfo").text(res.data.doctorName+" "+res.data.orgName);
- $(".patientName").text(res.data.patientName);
- if(res.data.followupNo){
- $(".planNo").text(res.data.followupNo);
- $(".planNo").closest("li").removeClass("c-hide");
- }
- $(".fvType").text(res.data.followupTypeName);
- $(".fvClass").text(res.data.followupClassName);
- $(".fvDate").text(res.data.followupDate);
- if(res.data.mobile && res.data.followupType == 3){ //电话随访方式才可以打电话
- $(".div-phone").show();
- $(".div-phone").attr("data-phone", res.data.mobile);
- }
- followupClass = res.data.followupClass;
- getFollowupProject();
- }else{
- plus.nativeUI.closeWaiting();
- mui.toast('数据加载失败')
- }
- }, "GET");
- },
- getFollowupProject = function(){
- //获取随访项目列表
- var url = "doctor/followup/getFollowupProject";
- sendPost(url,{id: fv_id}, null, function(res){
- if(res.status == 200) {
- var html = template("pro_list_temp", res);
- $proList.empty().append(html);
- for(i=0; i<res.data.length; i++){
- var item = res.data[i];
- if(item.status == 0){
- noFillItem += 1;
- }
- }
- }
- plus.nativeUI.closeWaiting();
- }, "GET");
- },
- backAction = function(){
- var self = plus.webview.currentWebview(),
- opener = self.opener(),
- pre_opener = opener.opener();
- var indexWv = plus.webview.getWebviewById('index');
- var server = plus.webview.getWebviewById("fuwujilu");
- var suifangList = plus.webview.getWebviewById('suifang_list');
- var xufangzixun = plus.webview.getWebviewById('xufangzixun');
-
- var chooseSuifang = plus.webview.getWebviewById('choose_suifang');
- var followWay = plus.webview.getWebviewById('follow_way');
- var suifangDetail = plus.webview.getWebviewById('suifang_detail');
- var startPlan = plus.webview.getWebviewById('start_plan');
- if(suifangList){
- mui.fire(suifangList, "refresh2");
- if(chooseSuifang){chooseSuifang.close('none')}
- if(followWay){followWay.close('none')}
- if(suifangDetail){suifangDetail.close('none')}
- if(startPlan){startPlan.close('none')}
- mui.later(function(){
- self.close('none')
- }, 300);
- }else if(xufangzixun){//续方咨询
- var fw = plus.webview.getWebviewById('xf_follow_way');
- if(fw){fw.close('none')}
- mui.later(function(){
- self.close('none');
- }, 300);
- }else if(server){//服务记录
- mui.fire(server, "refresh2");
- if(chooseSuifang){chooseSuifang.close('none')}
- if(followWay){followWay.close('none')}
- if(startPlan){startPlan.close('none')}
- if(suifangDetail){suifangDetail.close('none')}
- mui.later(function(){
- self.close('none');
- }, 300);
- openWebview("../../huanzhe/html/fuwujilu.html", {type: 'sf', patientCode: patientCode});
- }else if(pre_opener && pre_opener.id == "choose_suifang"){
- var pre_pre_opener = pre_opener.opener();
- if(pre_pre_opener.id == "suifang_detail"){
- //index->suifang_detail->choose_suifang->follow_way->fvDetail
- mui.fire(indexWv,'refresh');
- openWebview("index.html");
- mui.later(function(){
- pre_pre_opener.close('none');
- pre_opener.close('none');
- opener.close('none');
- self.close('none');
- },300);
- }else{
- //IM/juminxinxi->choose_suifang->follow_way->fvDetail
- var fuwujilu = plus.webview.getWebviewById("fuwujilu");
- if(fuwujilu){
- mui.fire(fuwujilu, "newPage", {type: 'sf', patientCode: patientCode});
- }
- openWebview("../../huanzhe/html/fuwujilu.html", {type: 'sf', patientCode: patientCode});
- mui.later(function(){
- pre_opener.close('none');
- opener.close('none');
- self.close('none');
- }, 1000);
- }
- }else{
- if(indexWv){
- mui.fire(indexWv,'refresh');
- openWebview("index.html");
- }
- mui.later(function(){
- var pre_pre_opener = pre_opener.opener();
- if(opener.id == "start_plan" || opener.id == "follow_way" || opener.id == "suifang_detail"){
- opener.close('none');
- }
- if(pre_opener && (pre_opener.id == "sousuojumin_one" || pre_opener.id == "xuanzejumin_one")){
- pre_opener.close('none');
- }
- if(pre_opener && pre_opener.id == "suifang_detail"){
- pre_opener.close('none');
- }
- if(pre_pre_opener && pre_pre_opener.id == "xuanzejumin_one"){
- pre_pre_opener.close('none');
- }
- self.close('none');
- }, 300);
- }
- }
- bindEvents = function(){
- $proList.on("tap","li", function(){
- if(!otherPeople || $(this).find('.c-list-key span').text()=='已登记'){
- var project_id = $(this).attr("data-id"),
- title = $(this).attr("data-label"),
- url = (project_id == "6")? "drugs.html":"questionaires.html";
- openWebview(url,{
- followup_id: fv_id,
- project_id: project_id,
- title: title,
- followupClass:followupClass,
- patientCode: patientCode,
- otherPeople:otherPeople
- });
- }
- });
-
- $("#complete").on('click',function(){
- var $ul = $('#project_list').find('li');
- if( !($ul.eq(1).attr('data-fill')*1 && $ul.eq(4).attr('data-fill')*1) ){
- mui.toast('请完善体征和评价')
- return false
- }
- if(noFillItem > 0){
- dialog({
- content: "当前还有<strong style='color:red;'>"+noFillItem+"</strong>项未提交,您确定要上传吗?",
- okValue:'继续上传',
- ok: function (){
- plus.nativeUI.showWaiting();
- var url = "doctor/followup/finishFollowup",
- params = {id: fv_id};
- sendPost(url, params, null, function(res){
- if(res.status == 200){
- mui.toast("完成本次随访");
- backAction();
- }
- plus.nativeUI.closeWaiting();
- },'POST');
- },
- cancelValue: '返回补充',
- cancel: function () {
- return;
- }
- }).showModal();
-
- }else{
- plus.nativeUI.showWaiting();
- var url = "doctor/followup/finishFollowup",
- params = {id: fv_id};
- sendPost(url, params, null, function(res){
- if(res.status == 200){
- mui.toast("完成本次随访");
- backAction();
- }
- plus.nativeUI.closeWaiting();
- },'POST');
- }
- });
-
- $(".div-phone").on('click', function(){
- var mobile = $(this).attr("data-phone");
- dialog({
- content: mobile,
- okValue:'立即拨号',
- ok: function (){
- window.location.href = "tel:"+mobile;
- },
- cancelValue: '不了,谢谢',
- cancel: function () {
- return;
- }
- }).showModal();
- });
- };
- // 页面业务处理流程开始
- new Promise(function(resolve, reject) {
- // TODO 临时放开
- //resolve(true);
- mui.plusReady(function() {
- // plus已经准备好,可以往下执行
- resolve(true);
- });
- }).then(function() {
-
- // 获取基础环境信息
- return getBaseEnvPromise().then(function(env) {
- baseEnv = env;
- }).then(function() {
- // 获取登录医生信息
- baseInfo = getBaseInfo();
-
- //初始化页面内容
- initPage();
-
- // 绑定页面事件
- bindEvents();
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- });
- window.addEventListener('refresh',function(){
- initPage();
- })
|