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 = '