var firstData={}; var firstIs = false; var curDeptId = 0; var curParentDeptId = -1; var ieType = 10; var attachBuild = ""; $(function(){ ieType = browse(); Commonjs.getJscrollpane.destroy(); // deptDeal._loadAllDeptInfo(); $('#datetimepicker1,#datetimepicker2').datetimepicker({ yearOffset:0, lang:'ch', timepicker:false, format:'d/m/Y', formatDate:'Y/m/d', minDate:'-1970/01/02', // yesterday is minimum date maxDate:'+1970/01/02' // and tommorow is maximum date calendar }); $('#layer').click(function(){ var artBox=art.dialog({ lock: true, icon:'question', opacity:0.4, width: 250, title:'提示', content: '页面模板会覆盖编辑区域已有组件,是否继续?', ok: function () { }, cancel: true }); }); initImage(); loadDeptInfo(); $('.info-office-list > ul > li').hover(function(){ $(this).children('a').addClass('hover'); $(this).children('ul').show(); $(this).append(''); },function(){ $(this).children('a').removeClass('hover'); $(this).children('ul').hide(); $(this).children('span').remove(); }); $("#deptCancel").hide(); $('#edit-btns').on('click',function(){ $("#deptCancel").hide(); var $add=$('.info-edit-address'), $text=$('.info-edit-text'), $btn=$(this); if($(this).hasClass('edityes')){ $("#deptCancel").hide(); $btn.text('编辑').removeClass('edityes'); //intro = intro.replace(//g,'\n'); $text.html($text.find('textarea').val()); $add.html($add.find('textarea').val()); var Service = {}; var page = {}; var code = 1009; Service.DeptCode = curDeptId; Service.DeptAddr = $add.html(); Service.AttchingBuild = attachBuild; var tem = $text.html(); tem = tem.replace(/\n/g,'
'); $text.html(tem); Service.DeptBrief =""; Service.ParentDeptCode = curParentDeptId; var param = {}; var params = Commonjs.getParams(code,Service);//获取参数 param.Api = "UpdateDept"; param.Params = Commonjs.jsonToString(params); var d = Commonjs.ajax('./basic_callBasicApi.do',param,false); if(d.RespCode == '10000'){ art.dialog({ lock: true, width: '300px', height: '100px', time: 3, content: d.RespMessage }); $("#deptCancel").hide(); } }else{ $("#deptCancel").show(); $btn.text('保存').addClass('edityes'); var temp = $text.html().replace(//g,'\n'); //$add.html('科室位置

'); //$text.html('科室 简介

'); $add.html('科室位置

'); $text.html('科室简介

'); } }); $('#deptCancel').on('click',function(){ deptDeal._loadDeptEditInfo(curDeptId); var $add=$('.info-edit-address'), $text=$('.info-edit-text'), $btn=$('#edit-btns'); $btn.text('编辑').removeClass('edityes'); $(this).hide(); }); function fetureHeight(){ var h=$(window).height()-111; if($('.info-doctor').outerHeight(true)>$(window).height()){ $('.info-details-fl').height($('.info-doctor').outerHeight(true)-49); }else{ $('.info-doctor').height(h); $('.info-office-list').height(h-49).jScrollPane({"overflow":true}); $('.info-details-fl').height(h-49); } } fetureHeight(); function infoListScroll(){ $(".info-office-box").height($(window).height()-161).jScrollPane({"autoReinitialise": true,"overflow":true}); } infoListScroll(); function userListScroll(){ $(".info-details-box").height($(window).height()-161).jScrollPane({"autoReinitialise": true,"overflow":true}); } userListScroll() $(window).resize(function(){ Commonjs.getJscrollpane.destroy(); Throttle(fetureHeight(),50,30); Throttle(infoListScroll(),50,30); Throttle(userListScroll(),50,30); }); /* $('.doctor-textarea-focu').on('focus keydown keyup',function(){TextareaCount()}); function TextareaCount(){ var $this=$('.doctor-textarea-focu'), $tips=$('.art-doctor-tips'); var $val=$.trim($this.val()); if(150-$val.length<0){ $tips.html('您已经超出'+($val.length-150)+'个字了哦'); }else if (150-$val.length==0){ $tips.html('您已经输满'+150+'个字了哦'); }else if(150-$val.length==150){ $tips.html('0 个字符,您还可以编辑 150 个字符'); } else{ $tips.html(''+($val.length)+' 个字符,您还可以编辑 '+(150-$val.length)+' 个字符'); } } */ $('#adb-title').on('focus keydown',function(){ if($(this).val() == '请输入职称!'){ $(this).val(''); }}); }); function checkMobile(str) { var re = /^1\d{10}$/ if (re.test(str)) { return true; } else { return false; } } function editDoctor(obj){ var editContent = {}; deptDeal._loadDoctorInfoById(obj); var contents=$('.art-doctor-box').get(0); var artBox=art.dialog({ lock: true, artIcon:'edit', opacity:0.4, width: 900, padding: '20px 20px 0', title:'编辑', header:false, content: contents, ok: function () { editContent.use =$("#adb-name").val(); editContent.sex =$("#adb-sex").val(); editContent.tel =$("#adb-tel").val(); editContent.title =$("#adb-title").val(); if(!checkMobile(editContent.tel) && editContent.tel != ''){ art.dialog({ lock: true, width: '300px', height: '100px', time: 3, content: '手机号格式有误' }); return false; } if(editContent.use == '' || editContent.use == undefined){ art.dialog({ lock: true, width: '300px', height: '100px', time: 3, content: '姓名不能为空' }); return false; } deptDeal._saveDoctor($("#adb-intro").val(),$("#spec").val(),obj,editContent); //console.log("editDoctor" +curDeptId) deptDeal._loadDoctorInfo(curDeptId,1); }, cancel: true }); } var saveDotorInfo = function(intro,spec,doctorCode,obj){ var Service = {}; var page = {}; var code = 1021; Service.HosId = Commonjs.hospitalId; Service.Intro = ""; Service.Spec = ""; Service.DoctorCode = doctorCode; Service.PhotoUrl = ""; Service.DocotrSex = (obj.sex==''|| obj.sex == undefined) ? '0': obj.sex; Service.Tel = obj.tel; Service.Title = obj.title; Service.DoctorName = obj.use; var tempTitle = obj.title; if((tempTitle != null && tempTitle != '') && tempTitle.length > 0 && (obj.tel!='' && obj.tel != undefined)){ Service.IsNeed = 0; }else{ Service.IsNeed = 1; } /* Service.Title = obj.sex; Service.DocotrSex = obj.sex; Service.DocotrSex = obj.sex; */ var param = {}; var params = Commonjs.getParams(code,Service);//获取参数 param.Api = "UpdateDoctor"; param.Params = Commonjs.jsonToString(params); var d = Commonjs.ajax('./basic_callBasicApi.do',param,false); //alert(d.TreeNodes); if(d == null || d == undefined){ return; } if( d.RespCode == '10000'){ art.dialog({ lock: true, width: '300px', height: '100px', time: 3, content: d.RespMessage }); } } var loadDeptInfo = function(){ var Service = {}; var page = {}; var code = 1001; Service.HosId = Commonjs.hospitalId; var param = {}; var params = Commonjs.getParams(code,Service);//获取参数 param.Api = "QueryDeptInfoByHosIdForTree"; param.Params = Commonjs.jsonToString(params); var d = Commonjs.ajax('./basic_callBasicApi.do',param,false); //alert(d.TreeNodes); if(d.RespCode == '10000'){ if(ieType == 8){ deptDeal._getUIForIe(d.TreeNodes); }else{ deptDeal._getUl(d.TreeNodes); } } } var findDept = function(deptId){ $btn=$('#edit-btns'); $("#deptCancel").hide(); $btn.text('编辑').removeClass('edityes'); // alert(deptId); curDeptId = deptId; deptDeal._loadDeptEditInfo(deptId); deptDeal._loadDoctorInfo(deptId,1); curDeptId = deptId; } function newGuid() { var guid = ""; for (var i = 1; i <= 32; i++){ var n = Math.floor(Math.random()*16.0).toString(16); guid += n; if((i==8)||(i==12)||(i==16)||(i==20)) guid += "-"; } return guid; } function initImage(){ var id = newGuid(); var html = '
'; $("#updateSmallImg").empty(); $("#updateSmallImg").append(html); } function upload(id,image) { var filename = $("#"+id).val(); var index = filename.lastIndexOf('.'); var type = filename.substring(index+1,filename.length); if(type.toLowerCase() != 'jpg' && type.toLowerCase() != 'gif' &&type.toLowerCase() != 'png'&&type.toLowerCase() != 'jpeg'){ YihuUtil.art.warning('注意喔:图片格式必须为.jpeg|.gif|.jpg|.png','warning'); return ; } var arrID = [ id ]; $.yihuUpload.ajaxFileUpload( { url : '/Hos-Process/servlets/UploadFileServlet', // 用于文件上传的服务器端请求地址 secureuri : false,// 一般设置为false fileElementId : arrID,// 文件上传空间的id属性 dataType : 'json',// 返回值类型 一般设置为json success : function(data, status) { var uri = data.url; uri=uri.replace('fullsize','small'); var name = data.NewFileName; var fname = data.FileName; var size = data.Size; var old = $("#" + id + "_f"); if (image=='SmallImgV') { $("#SmallImgV").attr("src", uri); $("#ImgUrl").val(uri); $("#hidVal").val(uri); } }, error : function(data, status, e) { //YihuUtil.art.warning("图片上传失败:建议您选择不超过1M的图片且在良好的网络环境下继续上传"); } }); } var deptDeal = function(){ var getUiIe = function(data){ // var ui =$(""); var ui = ""; $(".info-office-list").html(ui); if(obj.id !='' && obj.id != undefined){ findDept(obj.id); } } var getUl = function(data){ var ui =$(""); var obj={}; $.each(data,function(k,v){ var litext =''; if(!firstIs){ obj.id = v.id; obj.val = v.text; firstData = obj; firstIs = true; } if(v.text.length > 10){ var li =$("
  • "+v.text+"
  • "); }else{ var li =$("
  • "+v.text+"
  • "); } if(typeof(v.children.id) != 'undefined' && v.children.text != undefined){ var _textArr = []; var _idArr = []; var _ui =$(""); if($.isArray(v.children.text ) ){ _textArr = v.children.text; _idArr = v.children.id; $.each(_textArr,function(v1){ var li_text =''; var _id =_idArr[v1]; var _li =$("
  • "+this+"
  • "); _ui.append(_li); }); }else{ if(v.text.length > 10){ var _li =$("
  • "+v.children.text+"
  • "); }else{ var _li =$("
  • "+v.children.text+"
  • "); } _ui.append(_li); } li.append(_ui); } ui.append(li); }) ; $(".info-office-list").append(ui); if(obj.id !='' && obj.id != undefined){ findDept(obj.id); } } var loadEditInfo = function(deptId){ var Service = {}; var page = {}; var code = 1001; Service.HosId = Commonjs.hospitalId; Service.DeptCode = deptId; page.PIndex=0; page.PSize = 100; Service.Page = page; var param = {}; var params = Commonjs.getParams(code,Service);//获取参数 param.Api = "QueryDept"; param.Params = Commonjs.jsonToString(params); var d1 = Commonjs.ajax('./basic_callBasicApi.do',param,false); if(d1 == null || d1 == undefined){ return; } var dd = d1.Data;//modify by suntan $(".info-edit-top").html(""); $("#addr").html(""); $("#intro").html(""); $(".info-edit-top").html(dd == undefined ? '' : dd.Name); $("#addr").html(dd == undefined ? '' : dd.DeptAddr); var intro = dd == undefined ? '' : dd.Intro; //intro = intro.replace(//g,'\n'); $("#intro").append(intro); curParentDeptId = dd.ParientId ; attachBuild = dd.AttachBuilding; } var loadDoctorInfoByDoctorCode = function(doctorCode){ var tempUrl = ""; $("#adb-name").val(""); $("#adb-user").val(""); $("#adb-tel").val(""); //$("#adbImg").attr("src",unescape(backData.Doctor.Url)); $("#adb-dept").val(""); $("#spec").val(""); $("#intro").val(""); var Service = {}; var page = {}; var code = 1002; Service.HosId = Commonjs.hospitalId; Service.DoctorCode = doctorCode; page.PIndex=0; page.PSize = 100; Service.Page = page; var param = {}; var params = Commonjs.getParams(code,Service);//获取参数 param.Api = "QueryDoctor"; param.Params = Commonjs.jsonToString(params); var backData = Commonjs.ajax('./basic_callBasicApi.do',param,false); if(backData == null || backData == undefined){ return; } if(backData.RespCode == '10000'){ $("#adb-name").val(backData.Data.DocName); $("#adb-title").val(backData.Data.DocTitle); if(backData.Data.DocTitle == '' || backData.Data.DocTitle == undefined){ $("#adb-title").val("请输入职称!"); } //console.log("loadDoctorInfoByDoctorCode "+backData.Data.Tel.length); $("#adb-sex").val(backData.Data.Sex); if(backData.Data.PhotoUrl == '' || backData.Data.PhotoUrl ==undefined){ tempUrl ="../../commons/images/male.jpg"; }else { tempUrl =unescape(backData.Data.PhotoUrl); } $("#SmallImgV").attr("src",tempUrl); $("#adb-depart").text(backData.Data.RelativeDeptName); if(backData.Data.Tel.length > 10){ $("#adb-tel").val(backData.Data.Tel); }else{ $("#adb-tel").val(''); } $("#spec").val(backData.Data.Spec); $("#adb-intro").val(backData.Data.Intro); $("#adb-dept").text(backData.Data.DeptName); //console.log(backData.Data.DeptName); $("#zhishu").text((backData.Data.Intro =='' || backData.Data.Intro == undefined) ? 0 : backData.Data.Intro.length); $(".old").text((backData.Data.Intro =='' || backData.Data.Intro == undefined) ? 0 : backData.Data.Intro.length); }else{ art.dialog({ lock: true, width: '300px', height: '100px', time: 3, content: backData.RespMessage }); } } var loadDoctorInfo = function(deptId,index){ //console.log("loadDoctorInfo "+deptId); var Service = {}; var code = 1002; Service.HosId = Commonjs.hospitalId; Service.DeptCode = deptId; $('#pagenumber').val(index); var pageIndex = index-1; var pageSize = 10; var page = {}; page.PIndex = pageIndex; page.PSize = pageSize; var param = {}; var params = Commonjs.getParams(code,Service,page);//获取参数 param.Api = "QueryDoctor"; param.Params = Commonjs.jsonToString(params); var backData = Commonjs.ajax('./basic_callBasicApi.do',param,false); $("#docTable").empty(); if(backData.RespCode == '10000'){ // $("#docTable").empty(); var ui =$("
      "); var tep = []; if(backData.Data == undefined){ $('#docTable').append("
      • 未找到相关数据!
      "); return; } if(!$.isArray(backData.Data)){ if( backData.Data.length==undefined&&!Commonjs.isEmpty(backData.Data.DocCode)){ tep.push(backData.Data); backData.Data = tep; } } $.each(backData.Data,function(k,v){ var li =$("
    • ") if(v.PhotoUrl == '' || v.PhotoUrl ==undefined){ var _divOne = $("
      "); li.append(_divOne); }else{ var _divOne = $("
      "); li.append(_divOne); } if(v.DocName == undefined || v.DocName ==''){ var _divTwo = $("
      "); li.append(_divTwo); }else{ var _divTwo = $("
      "+v.DocName+"
      "); li.append(_divTwo); } if(v.DocTitle == undefined || v.DocTitle ==''){ var _divThe = $("
      "); li.append(_divThe); }else{ var _divThe = $("
      "+v.DocTitle+"
      "); li.append(_divThe); } var cal = "javascript:editDoctor('"+v.DocCode+"'"+")"; var _divFour = $("
      "); li.append(_divFour); ui.append(li); }); $("#docTable").append(ui); /*
      沙湖
      主任
      */ }else { Page(0,pageSize,'pager'); return; } if((backData.Page.PCount!=undefined&&backData.Page.PCount!=0)||(backData.Page.PCount==0 && index==1)){ $("#totalcount").val(backData.Page.PCount); } Page($("#totalcount").val(),backData.Page.PSize,'pager'); } var loadAllDept = function(){ var Service = {}; var page = {}; var code = 1001; Service.HosId = Commonjs.hospitalId; Service.Page = page; page.PIndex = 0; page.PSize = 100; var param = {}; var params = Commonjs.getParams(code,Service);//获取参数 param.Api = "QueryDept"; param.Params = Commonjs.jsonToString(params); var backData = Commonjs.ajax('./basic_callBasicApi.do',param,false); if(backData.RespCode == '10000'){ $.each(backData.Data,function(k,v){ $("#adb-dept").append($("