var request = GetRequest(); var pro_id = request['pro_id'], prescriptionCode = request['prescriptionCode']; var project_data; var $form = $("#question_form"); var d = dialog({contentType:'load', skin:'bk-popup'}); var dd = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'}); function toast(msg){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show() } var initPage = function(){ project_data = gTemplate[pro_id]; var nameObj = {1:'症状',2:'体征及生活方式问卷'} var classes=""; if(pro_id == 1){classes='1'} if(pro_id == 2){classes='2,4'} $('title').text(nameObj[pro_id]) var params3 = { prescriptioncode:prescriptionCode, followupProject:classes } d.show() sendPost('patient/prescription/followupcontent/getinfo', params3, 'json', 'get',function(){ d.close() toast('请求失败') }, function(res){ d.close() if(res.status == 200){ if(! $.isEmptyObject(res.data)){ for(var key in project_data){ project_data[key].value = res.data[key]; } nextdo(false) }else{ nextdo(true) } } }) function nextdo(isBtn){ var html = template("item", {data:project_data}) $form.append(html); initMobiscroll() bindEvents() if(isBtn){ $('#btn_group').show() $('#question_form').css('pointer-events','') }else{ $('#btn_group').hide() $('#question_form').css('pointer-events','none') } } }, initMobiscroll = function(){ //绑定数字键盘 $.each(document.querySelectorAll('input[type=number]'), function(index, el){ var name = el.name; if(name=="HEART_RATE" || name == "HEIGHT" || name=="DAILY_SMOKING" || name=="CONTROL_EXERCISE_DURATION_MINS" || name=="SOMKING_EXP" || name=="EXERCISE_DURATION_MINS" || name=="EXERCISE_DURATION_MINS_EXP"){ $(el).mobiscroll().numpad({ theme: 'ios', display: 'bottom', lang: 'zh', placeholder: '0', fill: 'rtl', allowLeadingZero: true, template: 'ddd', scale:0, buttons: ['set','cancel'], onSelect: function(valueText, inst){ var value = parseFloat($('.mbsc-np-dsp').text()); $(this).val(value); } }) }else if(name == "WEIGHT" || name=="DRINK_EXP" || name=="DAILY_DRINKING" || name=="DAILY_STAPLE" || name == "WEIGHT_EXP"){ $(el).mobiscroll().numpad({ theme: 'ios', display: 'bottom', lang: 'zh', placeholder: '0', fill: 'rtl', allowLeadingZero: true, template: 'ddd.d', scale:0, buttons: ['set','cancel'], onSelect: function(valueText, inst){ var value = parseFloat($('.mbsc-np-dsp').text()); $(this).val(value); } }) }else{ $(el).mobiscroll().numpad({ theme: 'ios', display: 'bottom', lang: 'zh', placeholder: '0', buttons: ['set','cancel'], onSelect: function(valueText, inst){ var value = parseFloat($('.mbsc-np-dsp').text()); $(this).val(value); } }) } }) }, bindEvents = function(){ // 判断checkbox和radio控件 $form.on("change","input[type=radio]",function(){ $("#disable_save").hide(); $("#active_save").show(); var $this = $(this) if($this.attr('name') == "DAILY_DRINKING_f" || $this.attr('name') == "DAILY_SMOKING_f"){ if($this.val()>0){//针对类型5 $this.closest('ul').find('input[name=DAILY_SMOKING]').show() $this.closest('ul').find('input[name=DAILY_DRINKING]').show() $this.closest('ul').find('input[name=DAILY_SMOKING]').val('') $this.closest('ul').find('input[name=DAILY_DRINKING]').val('') }else{ $this.closest('ul').find('input[name=DAILY_SMOKING]').hide() $this.closest('ul').find('input[name=DAILY_DRINKING]').hide() $this.closest('ul').find('input[name=DAILY_SMOKING]').val(0) $this.closest('ul').find('input[name=DAILY_DRINKING]').val(0) } } }) $form.on("change","input[type!=radio]",function(){ if(this.type =='checkbox'){ if(this.checked){ this.value = 1; nextDo(this) }else{ this.value = 0; nextDo(this) } } if(this.type !='checkbox'){ nextDo(this) } function nextDo($this){ if($this.value && $this.value!="0"){ $("#disable_save").hide(); $("#active_save").show(); }else{ var list = $("input[type!=radio]"), len = list.length, empty = true; for(i=0; i< len; i++){ var value = list[i].value; if(value && value!="0"){ empty = false; } } if(empty){ if(pro_id == 1){//有选低血糖特殊处理 if($('input[name=HYPOG_REACT_CODE]:checked').val() == undefined){ $("#disable_save").show(); $("#active_save").hide(); } }else{ $("#disable_save").show(); $("#active_save").hide(); } } } } }) $("#active_save").on("tap", function(){ dd.show() var url = "patient/prescription/followupcontent/saveinfo", params = [], data = {}; function addData(num,d){ var alldata = {}; alldata.followupProject = num; alldata.projectData = d; return alldata } $form.serializeArray().map(function(x){data[x.name]=x.value;}); data = _.omit(data,'DAILY_SMOKING_f','DAILY_DRINKING_f')//过滤辅助判断 if(pro_id == 2){ var obj2={},obj4={}; obj4 = _.omit(data,'HEART_RATE','HEIGHT','WEIGHT') obj2 = _.pick(data,'HEART_RATE','HEIGHT','WEIGHT') params.push(addData(2,obj2)) params.push(addData(4,obj4)) } if(pro_id == 1){ params.push(addData(1,data)) } sendPost(url,{followupProjectData:JSON.stringify(params),prescriptioncode:prescriptionCode,sendIM:"true"}, 'json', 'post',function(){ dd.close() toast('请求失败') }, function(res){ dd.close() if(res.status == 200){ toast('提交成功') setTimeout(function(){ window.history.back() },500) } }) }) } $(function(){ //初始化页面内容 initPage(); })