123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- // 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<res.data.list.length; i++){
- var item = res.data.list[i];
- doc_keys.push(item.code);
- doc_vals.push(item.name);
- if(item.code == docInfo.code){
- defaultDoc.keys=item.code;
- defaultDoc.values = item.name;
- }
- }
- }else{
- doc_keys.push(docInfo.code);
- doc_vals.push(docInfo.name);
- }
- // getFollowWay();
- initialize_select();
- plus.nativeUI.closeWaiting();
- },'GET');
- },
- //获得随访方式下拉数据
- //getFollowWay = function(){
- // var url = "common/getDictByDictName",
- // params = {name:'FOLLOWUP_WAY_DICT'};
- // sendPost(url,params, null, function(res){
- // if(res.list.length > 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('<i class="title-line"></i>第'+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<closeList.length; i++){
- closeList[i].close('none');
- }
- mui.later(function(){
- mui.back()
- },300)
- }else{
- var opener = wv.opener();
- if(opener.id != id){
- closeList.push(opener);
- }
- backToPage(opener,id);
- }
- }
- //随访方式写死 第一次初始化
- function doctorLevel(){
-
- // if(docInfo.level ==2){
- // $(".plan_type").html('家庭(全科)')
- // $(".plan_type").attr('data-id',22)
- // }else if(docInfo.level ==3){
- // $(".plan_type").html('健管师随访')
- // $(".plan_type").attr('data-id',10)
- // }else if(docInfo.level ==1){
- // $(".plan_type").html('专科医生随访')
- // $(".plan_type").attr('data-id',13)
- // }
- }
- // 页面业务处理流程开始
- 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);
- })
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- })
- template.helper("setSex", function(p) {
- if(p == 2){return '女'}
- if(p == 1){return '男'}
- })
|