// TODO 临时构造plus对象,使得能够在浏览器中进行调试 //var plus = null; // 基本信息(包括userAgent) var baseInfo = null, // 基础环境信息(包括当前webview、encry相关) baseEnv = null, docInfo = null, patientInfo = null, choose_date = "", team_msg = "", docList = null; //记录改患者可选的随访医生列表 var currentNum=1;//当前选择下的记录 //下拉弹框的数据 var type_keys = [], type_vals = [], doc_keys = [], doc_vals = []; var defaultDoc = {}; // 获取登录相关信息 var getBaseInfo = function() { docInfo = JSON.parse(plus.storage.getItem("docInfo")); patientInfo = baseEnv.webview.patientInfo; choose_date = baseEnv.webview.chooseDate; if(choose_date){ var now = new Date() var minute = now.getMinutes()<10?'0'+now.getMinutes():now.getMinutes(); var hour = now.getHours()<10?'0'+now.getHours():now.getHours(); choose_date = choose_date+' '+hour+':'+minute; } // 登录的相关信息 var userAgent = JSON.parse(plus.storage.getItem("userAgent")); return { userAgent: userAgent } }, // 获取基础环境信息 getBaseEnvPromise = function () { var env = { webview: plus.webview.currentWebview() }; // 因为有异步请求,需要等待数据返回之后进行处理,所以返回Promise return Promise.resolve().then(function(res) { return env; }); }, //初始化页面内容 initPage = function(){ $(".plan_doctor").attr("data-id", docInfo.code); $(".plan_doctor").text(docInfo.name); $(".plan_date").val(choose_date || ""); //请求居民信息 sendGet('doctor/patient/info',{patient:patientInfo.code},function(){ mui.toast('请求失败') }, function(res){ if(res.status == 200){ var html = template('people_msg',{data:res.data}) $('#ul_main').html(html) }else{ mui.toast('获取居民信息失败') } }) doctorLevel();//随访方式 getDoctorList(); }, //获得随访医生的列表 getDoctorList = function(){ plus.nativeUI.showWaiting(); var url = "/doctor/patient_group/sign_doctors", params = {patient: patientInfo.code}; sendPost(url, params, null, function(res){ if(res.data.list.length > 0){ team_msg = res.data.list; for(var i = 0; i 0){ // for(var i=0; i< res.list.length; i++){ // var item = res.list[i]; // if(item.value == '电话'){ // if(patientInfo.mobile){ // type_keys.push(item.code); // type_vals.push(item.value); // } // }else{ // type_keys.push(item.code); // type_vals.push(item.value); // } // } // } // initialize_select(); // plus.nativeUI.closeWaiting(); // },'GET'); //}, setDefaultSelect = function() { // 获取健康管理师下拉框mibiscroll实例 // var doctorMobiscroll = $('[data-val=doctor]').mobiscroll('getInst'); var valueText = "{keys:'"+defaultDoc.keys+"',values:'"+defaultDoc.values+"'}"; doctorMobiscroll.setVal([valueText]); }, //初始化下拉框的数据 initialize_select = function(){ //随访日期选择 $('[data-val=date]').mobiscroll({ preset: 'datetime', theme: 'ios', lang: 'zh', dateFormat: 'yy-mm-dd', timeFormat: 'HH:ii', showLabel: true, minDate: new Date() }); //随访方式选择 // $('[data-val=way]').mobiscroll({ // theme: 'ios', // lang: 'zh', // customWheels: true, // wheels: [ // [{ // keys: type_keys, // values: type_vals // }] // ], // onSelect: function(valueText, inst) { // var dd = eval("[" + valueText + "]"); // $(this).val(dd[0].values); // $(this).attr('data-id',dd[0].keys); // } // }); //随访医生选择 // $('[data-val=doctor]').mobiscroll({ // theme: 'ios', // lang: 'zh', // customWheels: true, // wheels: [ // [{ // keys: doc_keys, // values: doc_vals // }] // ], // onSelect: function(valueText, inst) { // var dd = eval("[" + valueText + "]"); // var $this = $(this) // $this.text(dd[0].values); // $this.attr('data-id',dd[0].keys); // //随访方式写死team_msg // $.map(team_msg,function(o,i){ // if(dd[0].keys == o.code){ // if(o.typename == "全科医生"){ // $this.closest('ul.c-list').find(".plan_type").html('家庭(全科)') // $this.closest('ul.c-list').find(".plan_type").attr('data-id',22) // } // if(o.typename == "健康管理师"){ // $this.closest('ul.c-list').find(".plan_type").html('健管师随访') // $this.closest('ul.c-list').find(".plan_type").attr('data-id',10) // } // if(o.typename == "专科医生"){ // $this.closest('ul.c-list').find(".plan_type").html('专科医生随访') // $this.closest('ul.c-list').find(".plan_type").attr('data-id',13) // } // } // }) // } // }); // setDefaultSelect(); //设置默认医生选中 }, reflashBindEvent=function(){ $(".plan_type").unbind("click") $(".mui-table-view-cell1").unbind("click") $(".plan_type").bind('click',function(){ currentNum=$(this).parents(".scsf-item").data("num") || $(this).parents(".append_plan").data("num"); mui('#sheet1').popover('toggle'); }) $(".mui-table-view-cell1").bind('click',function(){ var _text=$(this).find('a').text(); console.log(_text) if(_text=='电话随访'){ if(patientInfo.mobile){ mui.toast('该居民未留下电话号码无法进行电话随访'); return ; } } if(_text=='网络随访'){ if(patientInfo.isWX){ mui.toast('该居民未关注公众号无法进行网络随访') return ; } } if(_text=='上门随访'){ if(patientInfo.address){ mui.toast('该居民未留下居住地址无法进行上门随访') return ; } } mui('#sheet1').popover('hide'); $("[data-num="+currentNum+"]").find(".plan_type").text(_text).data('id',($(this).data("value"))) }) }, //绑定事件 bindEvents = function(){ $('.main').on('click','.addplan',function (){ var num = $('.plan_list').children('ul').last().data('num'); ++num; var plan_html = $(".append_plan").prop("outerHTML"); $('.plan_list').append(plan_html); $('.plan_list').children('ul').last().attr('data-num',num); $('.plan_list').children('ul').last().find('.sfnum').html('第'+num+'次'); $('.plan_list').children('ul').last().find('.plan_date').attr('id','date'+num); $('.plan_list').children('ul').last().find('.plan_type').attr('id','way'+num); $('.plan_list').children('ul').last().find('.plan_doctor').attr('id','doctor'+num); initialize_select(num); reflashBindEvent(); }); reflashBindEvent(); //删除随访 $('.main').on('click','.title-btn',function (){ $(this).parents('.append_plan').remove(); }); //保存随访 $('.submit').on('click',function (){ var status = true; var plan_datas = []; $('.plan_list').children('ul').each(function (e){ var plan_date = $(this).find('.plan_date').val(); var plan_type = $(this).find('.plan_type').data('id'); var plan_doctor = $(this).find('.plan_doctor').data('id'); if(plan_date == '' || plan_date == '请选择'){ status = 1; } if(plan_type == 3 && patientInfo.mobile == ''){ //type == 3,为电话随访 status = 2; } if(plan_type == 6 && patientInfo.isWX == ''){ //type == 6,为网络随访 status = 3; } if(plan_type == 2 && patientInfo.address == ''){ //type == 2,为上门随访 status = 4; } plan_datas[e] = []; plan_datas[e] = {'date':plan_date+":00",'type':plan_type,'doctor':plan_doctor}; }) if(status === 1){ mui.toast('随访日期未填写') return false; } if(status === 2){ mui.toast('该居民未预留电话,不可以电话随访') return false; } if(status === 3){ mui.toast('该居民未关注微信公众号,不可以网络随访') return false; } if(status === 4){ mui.toast('该居民未填写地址,不可以上门随访') return false; } var params = { patient: patientInfo.code, data: JSON.stringify(plan_datas) }; plus.nativeUI.showWaiting(); sendPost("/doctor/followup/addFollowupPlan", params, null, function(res){ if(res.status == 200){ mui.toast("保存成功"); var cur = plus.webview.currentWebview(), opener = cur.opener(), pre_opener = opener.opener(), index = plus.webview.getWebviewById('index'), server = plus.webview.getWebviewById('fuwujilu'); suifangList = plus.webview.getWebviewById('suifang_list'); if(suifangList){ mui.fire(suifangList, "refresh2"); backToPage(cur,'suifang_list') }else if(opener.id == "choose_suifang"){ if(pre_opener && pre_opener.id == "suifang_detail"){ //index->suifang_detail->choose_detail->add_plan if(index){ mui.fire(index, "refresh"); index.show(); mui.later(function(){ opener.close('none'); cur.close('none'); }, 300); }else if(server){ mui.fire(server, "refresh2"); mui.later(function(){ pre_opener.close('none'); opener.close('none'); cur.close('none'); }, 300); } }else{ //IM/juminxinxi ->choose_suifang->add_plan var fuwujilu = plus.webview.getWebviewById("fuwujilu"); if(fuwujilu){ mui.fire(fuwujilu, "newPage", {type: 'sf', patientCode: patientInfo.code}); } openWebview("../../huanzhe/html/fuwujilu.html", {type: 'sf', patientCode: patientInfo.code}); mui.later(function(){ opener.close('none'); cur.close('none'); }, 1000); } }else{ mui.fire(index, 'refresh'); var xuanzejumin = plus.webview.getWebviewById("xuanzejumin_one"); var search_jumin = plus.webview.getWebviewById("sousuojumin_one"); if(xuanzejumin){xuanzejumin.close('none')}; if(search_jumin){search_jumin.close('none')}; mui.later(function(){ cur.close('none'); }, 300); } }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, 'POST'); }) } var closeList = []; function backToPage(wv,id){ if(wv.id == id){ for(i=0; i