(function() {
Vue.component('dept-source', {
template: '
',
props: ["info"],
data: function() {
return {
hospitalData: [],
deptData: [],
subDeptData: [],
planDate: [],
currentHospitalId:"",
nowDate:new Date().format("YYYY-MM-dd"),
pageIndex:1,
pageSize:10
}
},
mounted: function() {
var vm = this;
setTimeout(function(){
vm.currentHospitalId = JSON.parse(vm.info).hospitalId;
vm.getHospitalList();
vm.getDeptList();
vm.getVisitDate();
vm.bindEvents();
},50);
},
methods: {
itemClick:function(){
var vm = this;
var hosDeptId = "";
var curType = $(event.target).closest("li").attr("data-type");
var activeItemId = $(event.target).attr("data-val");
$(event.target).closest("li").find("span").removeClass("active");
$(event.target).addClass("active");
if(curType=="hostipal") {//医院
vm.currentHospitalId = activeItemId;
hosDeptId = ""
vm.getDeptList();
}else if(curType=="visitdept"){//就诊科室
vm.currentHospitalId = $(".select-condition-list li[data-type=hostipal]").find("span.active").attr("data-val");
hosDeptId = activeItemId;
}else if(curType=="subdept"){//子科室
}else if(curType=="visitdate"){//就诊日期
}
EventBus.$emit('update-doctor-list',{hospitalId:vm.currentHospitalId,hosDeptId:hosDeptId});
},
bindEvents:function(){
//查看更多
$(".more-list").click(function() {
var parent = $(this).parents(".select-condition-list-item");
parent.toggleClass('select-condition-list-item-active');
if(parent.hasClass("select-condition-list-item-active")) {
$(this).text("收起")
} else {
$(this).text("更多")
}
})
},
//获取医院列表
getHospitalList: function() {
var vm = this;
var params = {
pageIndex: 1,
pageSize: 99,
provinceCode: 360000,
cityCode: 361100
}
appointmentAPI.querySimpleHospitalList(params).then(function(res) {
if(res.successFlg && res.obj.Code == "10000") {
vm.hospitalData = res.obj.Result;
}
})
},
//获取科室列表
getDeptList: function() {
var vm = this;
var params = {
pageIndex: 1,
pageSize: 99,
hospitalId: vm.currentHospitalId
}
appointmentAPI.querySimpleHosDeptList(params).then(function(res) {
if(res.successFlg && res.obj.Code == "10000") {
vm.deptData = res.obj.Result;
// vm.deptData = _.filter(vm.deptData,function(item){
// return
// })
}
})
},
//默认只有7天的号源
getVisitDate: function() {
var vm = this;
var now = new Date(),d = new Date();
for(i = 1; i < 8; i++) {
var nDate = now.getDate();
d.setDate(nDate + i);
var obj = {
date: d.format("MM月dd日"),
date1: d.format("YYYY-MM-dd"),
day: this.getWeekDay(d.getDay())
}
this.planDate.push(obj);
}
},
getWeekDay: function(val) {
switch(val) {
case 0:
return "周日";
break;
case 1:
return "周一";
break;
case 2:
return "周二";
break;
case 3:
return "周三";
break;
case 4:
return "周四";
break;
case 5:
return "周五";
break;
case 6:
return "周六";
break;
}
}
}
});
})()
//\
// 医生类型
\
// \
// 全部\
// 主任医师\
// 其他\
//
\
// 更多
\
//\
//\
// 子科室
\
// \
// 全部\
//
\
// 更多
\
//\