-
- 上午出诊
- 下午出诊
- 全天出诊
- 不出诊
-
+
+ {{ currentEditingDate }}{{ isToday(currentEditingDate) ? '(今日)' : '' }}
+
+
+ 上午出诊
+ 下午出诊
+ 全天出诊
+ 不出诊
@@ -925,6 +906,8 @@ export default {
conflictDates: [], // 存储有冲突的日期
conflictCount: 0, // 冲突天数统计
tempAdjustments: {}, // 存储临时调诊数据 {日期: {医院ID: {原班次, 新班次, 状态}}}
+ currentEditingHospital: null, // 当前正在编辑的医院
+ currentEditingDate: null, // 当前正在编辑的日期
}
},
created() {
@@ -978,54 +961,266 @@ export default {
});
return colorMap;
},
+ // 添加计算属性
+ formattedCalendarData() {
+ const data = {};
+ Object.keys(this.calendarList).forEach(dateStr => {
+ const schedule = this.calendarList[dateStr];
+ if (this.hasActualSchedule(schedule)) {
+ data[dateStr] = schedule;
+ }
+ });
+ return data;
+ },
+ hospitalTagConfigs() {
+ const configs = {};
+ Object.keys(this.calendarList).forEach(dateStr => {
+ configs[dateStr] = {};
+ const schedule = this.calendarList[dateStr];
+ if (!schedule) return;
+
+ Object.keys(schedule).forEach(shiftType => {
+ if (['_isTempAdjust', '_conflicts', '0'].includes(shiftType)) return;
+
+ if (schedule[shiftType]) {
+ schedule[shiftType].forEach(hospital => {
+ const key = `${dateStr}_${hospital.hid}_${shiftType}`;
+ configs[dateStr][key] = this.getColorTagClass(
+ dateStr,
+ hospital.hid,
+ shiftType
+ );
+ });
+ }
+ });
+ });
+ return configs;
+ },
+
selectedCount() {
return this.selectedRows.length;
},
...mapState(['hosMenuData']) // 从Vuex映射showSidebar状态到组件的计算属性中
},
methods: {
- // getDateCellStyle(dateString) {
- // const schedule = this.getDateSchedule(dateString);
- // if (!schedule) return {};
- // for (const key in schedule) {
- // if (key !== '0' && schedule[key] && schedule[key].length > 0) {
- // return {
- // backgroundColor: this.singleColor[key] || '#FFFFFF',
- // color:this.singleTextColor[key] || '#303133'
- // };
- // }
- // }
- // return {};
- // },
- // [{"depart_id":4,"morning_plan":"1","afternoon_plan":0}]
- // /api/admin/get_departs_worktimes
-
- // 获取颜色标签的类名
- getColorTagClass(dateStr, hospitalId, shiftType) {
- const originalPlan = this.getOriginalPlan(dateStr, hospitalId);
- const status = this.getTempAdjustmentStatus(dateStr, hospitalId, originalPlan);
+ // 日历点击
+ handleDateClick(dateString, event) {
+ // 阻止事件冒泡
+ event.stopPropagation();
+
+ // 检查是否有排班数据
+ if (!this.hasScheduleData(dateString)) {
+ console.log('该日期无排班数据');
+ return;
+ }
- // 获取当前显示的班次(可能是调整后的)
- const currentShift = this.getCurrentShiftType(dateStr, hospitalId);
+ console.log('点击日期:', dateString);
- // 如果当前不显示这个班次,不渲染色块
- if (currentShift !== shiftType) {
- return 'hidden-tag';
+ // 获取该日期的排班信息
+ const schedule = this.getDateSchedule(dateString);
+ if (!schedule) return;
+
+ // 获取该日期涉及的所有医院
+ const hospitals = this.getHospitalsByDate(dateString);
+ console.log(hospitals,'hospitals===');
+ // 根据医院数量决定弹出哪种对话框
+ if (hospitals.length === 1) {
+ // 单医院 - 弹出单医院调整对话框
+ this.currentEditingDate = dateString;
+ this.currentEditingHospital = hospitals[0];
+ this.singleHosVisiable = true;
+ // this.showSingleHospitalDialog(dateString, hospitals[0]);
+ } else {
+ // 多医院 - 弹出多医院调整对话框
+ // this.showMultiHospitalDialog(dateString, hospitals);
+ }
+ },
+ // 设置临时调诊数据----
+ async saveTempAdjustment(dateString, newPlan) {
+ console.log(newPlan,'newPlan====');
+ try {
+ const response = await this.$http('POST', '/api/admin/set_visit_change', {
+ doctor_id: this.doctor_id,
+ date: dateString,
+ plans: JSON.stringify(newPlan)
+ });
+
+ if (response.code === 0) {
+ this.$message.success('临时调整保存成功');
+ // 重新加载排班数据
+ this.getDoctorHosPreview();
+ } else {
+ this.$message.error(response.msg || '保存失败');
+ }
+ } catch (error) {
+ console.error('保存临时调整失败:', error);
+ this.$message.error('保存失败');
+ }
+ },
+ // 获取指定日期涉及的所有医院
+ getHospitalsByDate(dateString) {
+ const schedule = this.getDateSchedule(dateString);
+ if (!schedule) return [];
+
+ const hospitals = [];
+
+ // 遍历所有班次类型收集医院
+ Object.keys(schedule).forEach(shiftType => {
+ const list =schedule[shiftType]
+ console.log(schedule,list,'schedule----');
+ if (['_isTempAdjust', '_conflicts', '0'].includes(shiftType)) return;
+ if(Array.isArray(list) && list.length>0){
+ list.map(hospital => {
+ // 检查是否已存在
+ const exists = hospitals.some(h => h.hid === hospital.hid);
+ if (!exists) {
+ hospitals.push({
+ hid: hospital.hid,
+ name: hospital.hospital_name,
+ originalPlan: hospital.originalPlan,
+ currentPlan: hospital.currentPlan,
+ isCancelled: hospital.isCancelled,
+ workTime: hospital.workTime
+ });
+ }
+ });
+ }
+ });
+ console.log(hospitals,'hospitals===');
+
+ return hospitals;
+ },
+ // 形成出诊文案
+ getWorkTimeDisplayText(hospital, dateStr, hospitalId) {
+ const hospitalData = this.rawScheduleData[hospitalId];
+
+ if (!hospitalData) return hospital.workTime;
+ // console.log(hospitalData,hospital,'hospitalData====');
+
+ const { morning_worktime, afternoon_worktime, temp_change_worktime } = hospitalData;
+ console.log(morning_worktime,'morning_worktime===');
+ let allDay_worktime = '';
+ if ((hospital.currentPlan == 3 || hospital.originalPlan ==3) && (morning_worktime && afternoon_worktime)) {
+ allDay_worktime = morning_worktime.slice(0, 5) + '-' + afternoon_worktime.slice(-5);
+ }
+ // console.log(allDay_worktime,'allDay_worktime===');
+ // 检查是否有临时调整
+ const hasTempAdjustment = temp_change_worktime && temp_change_worktime[dateStr];
+
+ // 获取班次类型对应的中文
+ const planTextMap = {
+ '1': '上午班',
+ '2': '下午班',
+ '3': '全天班',
+ '0': '休息'
+ };
+ // 对应的班次时间映射表
+ const workTimeTextMap = {
+ '1': morning_worktime,
+ '2': afternoon_worktime,
+ '3': allDay_worktime,
+ '0': '休息'
+ };
+
+ let planText = planTextMap[hospital.currentPlan] || '休息';
+ let workTimeText = workTimeTextMap[hospital.currentPlan];
+
+ // 如果是临时取消了,那就显示原来的出诊时间
+ if (hospital.currentPlan != hospital.originalPlan && hospital.currentPlan == 0) {
+ workTimeText = workTimeTextMap[hospital.originalPlan] || '休息';
+ }
+
+ // 如果是取消状态
+ if (hospital.isCancelled) {
+ return `${workTimeText} (固定${planTextMap[hospital.originalPlan] || ''})`;
}
- // 根据状态返回对应的类名
+ // 如果有临时调整
+ if (hasTempAdjustment) {
+ return `${workTimeText} (临时${planText})`;
+ }
+
+ // 固定排班
+ return `${workTimeText} (固定${planText})`;
+ },
+ getColorTagClass(dateStr, hospitalId, shiftType) {
+
+ const schedule = this.getDateSchedule(dateStr);
+ if (!schedule || !schedule[shiftType]) return { class: 'color-tag', style: {} };
+
+ const hospital = schedule[shiftType].find(h => h.hid === hospitalId);
+ if (!hospital) return { class: 'color-tag', style: {} };
+
+ const hospitalColor = this.getHospitalColor(hospitalId);
+
+ // 如果是取消的班次
+ if (hospital.isCancelled) {
+ return {
+ class: 'opacity-tag',
+ style: { backgroundColor: hospitalColor }
+ };
+ }
+
+ // 其他状态的班次(保持原有逻辑)
+ const status = this.getTempAdjustmentStatus(dateStr, hospitalId, hospital.originalPlan);
+
switch (status) {
case 'cancelled':
- return 'opacity-tag'; // 调诊后无出诊班次
+ return { class: 'opacity-tag', style: { backgroundColor: hospitalColor } };
case 'added':
case 'changed':
- return 'color-tag-coi'; // 调整后的班次
+ return {
+ class: 'color-tag-coi',
+ style: { borderColor: hospitalColor, backgroundColor: 'transparent' }
+ };
case 'same':
- return 'color-tag'; // 与固定排班一致
case 'no_adjustment':
- return 'color-tag'; // 无调整,按固定排班显示
default:
- return 'color-tag';
+ return { class: 'color-tag', style: { backgroundColor: hospitalColor } };
+ }
+ },
+
+ // 获取颜色标签配置
+ // getColorTagConfig(dateStr, hospitalId, shiftType) {
+ // const key = `${dateStr}_${hospitalId}_${shiftType}`;
+ // return this.hospitalTagConfigs[dateStr]?.[key] || { class: 'color-tag', style: {} };
+ // },
+ getColorTagConfig(dateStr, hospitalId, shiftType) {
+ const schedule = this.getDateSchedule(dateStr);
+ if (!schedule || !schedule[shiftType]) return { class: 'color-tag', style: {} };
+
+ const hospital = schedule[shiftType].find(h => h.hid === hospitalId);
+ if (!hospital) return { class: 'color-tag', style: {} };
+
+ const hospitalColor = this.getHospitalColor(hospitalId);
+
+ // 如果是取消的班次
+ if (hospital.isCancelled) {
+ return {
+ class: 'opacity-tag',
+ style: { backgroundColor: hospitalColor }
+ };
+ }
+
+ // 其他状态的班次(保持原有逻辑)
+ const status = this.getTempAdjustmentStatus(dateStr, hospitalId, hospital.originalPlan);
+ if (dateStr == '2025-11-12') {
+ console.log(status, 'getColorTagConfig:status===');
+ }
+
+ switch (status) {
+ case 'cancelled':
+ return { class: 'opacity-tag', style: { backgroundColor: hospitalColor } };
+ case 'added':
+ case 'changed':
+ return {
+ class: 'color-tag-coi',
+ style: { borderColor: hospitalColor, backgroundColor: 'transparent' }
+ };
+ case 'same':
+ case 'no_adjustment':
+ default:
+ return { class: 'color-tag', style: { backgroundColor: hospitalColor } };
}
},
getCurrentShiftType(dateStr, hospitalId) {
@@ -1049,22 +1244,17 @@ export default {
// 获取医院项的类名
getHospitalItemClass(dateStr, hospitalId) {
const status = this.getTempAdjustmentStatus(dateStr, hospitalId, this.getOriginalPlan(dateStr, hospitalId));
+ const isCancelled = status === 'cancelled';
+
+ if (isCancelled) {
+ return 'temp-adjusted cancelled-item';
+ }
+
if (status && status !== 'same') {
return 'temp-adjusted';
}
- return '';
- },
- // 获取调整状态文本
- getAdjustmentStatusText(dateStr, hospitalId) {
- const status = this.getTempAdjustmentStatus(dateStr, hospitalId, this.getOriginalPlan(dateStr, hospitalId));
- const statusMap = {
- 'cancelled': '(已取消)',
- 'added': '(新增)',
- 'changed': '(调整)',
- 'same': '(原班次)'
- };
- return statusMap[status] || '';
+ return '';
},
// 获取调整状态
@@ -1079,51 +1269,34 @@ export default {
// 检查是否有多个临时调整(控制只显示一个adjust元素)
hasMultipleTempAdjustments() {
- // 这个方法用于控制界面显示逻辑,实际只显示一个adjust元素
- return false; // 总是返回false,因为我们已经控制只显示一个
+ return false; // 总是返回false,因为已经控制只显示一个
},
-
// 获取临时调诊状态
- // getTempAdjustmentStatus(dateStr, hospitalId, originalPlan) {
- // if (!this.tempAdjustments[dateStr] || !this.tempAdjustments[dateStr][hospitalId]) {
- // return null;
- // }
-
- // const adjustment = this.tempAdjustments[dateStr][hospitalId];
- // const newPlan = adjustment.newPlan;
-
- // // 判断状态
- // if (newPlan === "0" && originalPlan !== "0") {
- // return 'cancelled'; // 班次取消
- // } else if (originalPlan === "0" && newPlan !== "0") {
- // return 'added'; // 新增班次
- // } else if (originalPlan !== newPlan) {
- // return 'changed'; // 班次变更
- // } else {
- // return 'same'; // 与固定排班一致
- // }
- // },
getTempAdjustmentStatus(dateStr, hospitalId, originalPlan) {
if (!this.tempAdjustments[dateStr] || !this.tempAdjustments[dateStr][hospitalId]) {
- return 'no_adjustment'; // 无调整
+ return 'no_adjustment';
}
const adjustment = this.tempAdjustments[dateStr][hospitalId];
- const newPlan = adjustment.newPlan;
-
- // 判断状态
- if (newPlan === "0" && originalPlan !== "0") {
- return 'cancelled'; // 班次取消
- } else if (originalPlan === "0" && newPlan !== "0") {
- return 'added'; // 新增班次
- } else if (originalPlan !== newPlan) {
- return 'changed'; // 班次变更
+ const newPlan = adjustment.newPlan.toString();
+ const originalPlanStr = originalPlan.toString();
+ if (dateStr == '2025-11-12' && hospitalId == 7) {
+ console.log(`getTempAdjustmentStatus: ${dateStr}, 医院=${hospitalId}, 原计划=${originalPlanStr}, 新计划=${newPlan}`);
+ }
+ if (newPlan === "0" && originalPlanStr !== "0") {
+ // console.log(` - 状态: cancelled (班次取消)`);
+ return 'cancelled';
+ } else if (originalPlanStr === "0" && newPlan !== "0") {
+ // console.log(` - 状态: added (新增班次)`);
+ return 'added';
+ } else if (originalPlanStr !== newPlan) {
+ // console.log(` - 状态: changed (班次变更)`);
+ return 'changed';
} else {
- return 'same'; // 与固定排班一致
+ // console.log(` - 状态: same (与固定排班一致)`);
+ return 'same';
}
},
-
-
// 检查是否需要显示临时调整标识
shouldShowAdjust(dateString) {
const schedule = this.getDateSchedule(dateString);
@@ -1140,7 +1313,6 @@ export default {
});
},
- // 获取原始固定排班
getOriginalPlan(dateStr, hospitalId) {
const hospital = this.rawScheduleData[hospitalId];
if (!hospital) return "0";
@@ -1148,22 +1320,28 @@ export default {
const date = new Date(dateStr);
const dayOfWeek = date.getDay() === 0 ? 7 : date.getDay();
+ // console.log(`getOriginalPlan: ${dateStr}, 星期${dayOfWeek}, 医院${hospitalId}`);
+
// 固定排班
if (hospital.worktime_no_fixed === 0 && hospital.worktime_list && hospital.worktime_list[dayOfWeek]) {
- return hospital.worktime_list[dayOfWeek].plan.toString();
+ const plan = hospital.worktime_list[dayOfWeek].plan.toString();
+ // console.log(` - 固定排班: ${plan}`);
+ return plan;
}
// 非固定排班中的具体日期
if (hospital.worktime_no_fixed === 1 && hospital.worktime_list && hospital.worktime_list[dateStr]) {
- return hospital.worktime_list[dateStr].plan.toString();
+ const plan = hospital.worktime_list[dateStr].plan.toString();
+ // console.log(` - 非固定排班: ${plan}`);
+ return plan;
}
+ // console.log(` - 默认: 0`);
return "0";
},
-
// 检查是否存在冲突(不允许时段重合时)
hasTimeConflict(dateStr, shiftType) {
- if (this.is_allow_coincide) return false;
+ if (!this.is_allow_coincide) return false;
const schedule = this.getDateSchedule(dateStr);
if (!schedule || !schedule[shiftType]) return false;
@@ -1221,11 +1399,6 @@ export default {
isConflictDate(dateString) {
return this.conflictDates.includes(dateString);
},
- // 检查是否需要显示临时调整标识
- // shouldShowAdjust(dateString) {
- // const schedule = this.getDateSchedule(dateString);
- // return schedule && schedule._isTempAdjust;
- // },
// 添加月份变化监听方法
onCalendarMonthChange(date) {
// 只有当月份真正变化时才重新生成排班
@@ -1254,7 +1427,99 @@ export default {
});
// 保存原始数据
- this.rawScheduleData = list;
+ // this.rawScheduleData = list;
+ this.rawScheduleData = {
+ "7": {
+ "h_depart_name": "北京大学第三医院针灸科",
+ "worktime_no_fixed": 0,
+ "display_work_days": 0,
+ "morning_worktime": "09:00-12:00",
+ "afternoon_worktime": "14:00-16:00",
+ "worktime_list": {
+ "1": {
+ "id": "379",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "week_day": "1",
+ "plan": "0",
+ "work_paln_desc": "不可预约"
+ },
+ "2": {
+ "id": "380",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "week_day": "2",
+ "plan": "0",
+ "work_paln_desc": "不可预约"
+ },
+ "3": {
+ "id": "381",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "week_day": "3",
+ "plan": "1",
+ "work_paln_desc": "上午可约"
+ },
+ "4": {
+ "id": "382",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "week_day": "4",
+ "plan": "3",
+ "work_paln_desc": "全天可约"
+ },
+ "5": {
+ "id": "383",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "week_day": "5",
+ "plan": "0",
+ "work_paln_desc": "不可预约"
+ },
+ "6": {
+ "id": "384",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "week_day": "6",
+ "plan": "0",
+ "work_paln_desc": "不可预约"
+ },
+ "7": {
+ "id": "385",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "week_day": "7",
+ "plan": "0",
+ "work_paln_desc": "不可预约"
+ }
+ },
+ "temp_change_worktime": {
+ "2025-11-10": {
+ "id": "57",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "morning_plan": "1",
+ "afternoon_plan": "0",
+ "date": "2025-11-10",
+ "plan": 1,
+ "work_paln_desc": "上午可约",
+ "date_paln_desc": "11.10上午"
+ },
+ "2025-11-12": {
+ "id": "58",
+ "doctor_id": "3",
+ "depart_id": "7",
+ "morning_plan": "0",
+ "afternoon_plan": "0",
+ "date": "2025-11-12",
+
+ "plan": 0,
+ "work_paln_desc": "不可预约",
+ "date_paln_desc": "11.12休息"
+ }
+ }
+ }
+ }
// 初始化当前月份的排班数据
this.generateMonthSchedule(this.currentDay);
@@ -1286,29 +1551,29 @@ export default {
},
// 为日期范围生成排班
generateScheduleForDateRange(startDate, endDate) {
- const tempCalendarData = { ...this.calendarList };
- const currentDate = new Date(startDate);
-
- // 清空临时调整数据
- this.tempAdjustments = {};
-
- while (currentDate <= endDate) {
- const dateStr = this.formatDate(currentDate);
-
- // 重新生成排班数据,确保临时调整信息正确设置
- const daySchedule = this.getScheduleForDate(currentDate);
-
- if (daySchedule && Object.keys(daySchedule).length > 1) {
- tempCalendarData[dateStr] = daySchedule;
- } else {
- delete tempCalendarData[dateStr];
- }
+ const tempCalendarData = { ...this.calendarList };
+ const currentDate = new Date(startDate);
- currentDate.setDate(currentDate.getDate() + 1);
- }
+ // 清空临时调整数据
+ this.tempAdjustments = {};
+
+ while (currentDate <= endDate) {
+ const dateStr = this.formatDate(currentDate);
- this.calendarList = tempCalendarData;
-},
+ // 重新生成排班数据,确保临时调整信息正确设置
+ const daySchedule = this.getScheduleForDate(currentDate);
+
+ if (daySchedule && Object.keys(daySchedule).length > 1) {
+ tempCalendarData[dateStr] = daySchedule;
+ } else {
+ delete tempCalendarData[dateStr];
+ }
+
+ currentDate.setDate(currentDate.getDate() + 1);
+ }
+
+ this.calendarList = tempCalendarData;
+ },
isTempAdjustDate(dateString) {
if (!this.rawScheduleData) return false;
@@ -1323,50 +1588,122 @@ export default {
return false;
},
addHospitalToSchedule(daySchedule, hospitalId, hospital, plan, workDesc) {
- const shiftType = plan.toString();
-
- // 如果班次是0(不出诊),不添加到排班显示中
- if (shiftType === "0") {
- return;
- }
-
- if (!daySchedule[shiftType]) {
- daySchedule[shiftType] = [];
- }
+ const shiftType = plan.toString();
+ const dateStr = daySchedule._dateStr;
+ const originalPlan = this.getOriginalPlan(dateStr, hospitalId);
- // 检查是否已经添加过这个医院
- const existingIndex = daySchedule[shiftType].findIndex(item => item.hid === hospitalId);
-
- const hospitalInfo = {
- hid: hospitalId,
- hospital_name: hospital.h_depart_name,
- workTime: workDesc,
- originalPlan: this.getOriginalPlan(daySchedule._dateStr, hospitalId),
- currentPlan: plan.toString()
- };
-
- if (existingIndex >= 0) {
- // 替换现有项
- daySchedule[shiftType][existingIndex] = hospitalInfo;
- } else {
- // 新增
- daySchedule[shiftType].push(hospitalInfo);
- }
-},
-getHospitalColorTag(dateStr, hospitalId, shiftType) {
- const status = this.getTempAdjustmentStatus(dateStr, hospitalId, this.getOriginalPlan(dateStr, hospitalId));
- const classNames = this.getColorTagClass(dateStr, hospitalId, shiftType);
-
- // 如果班次被取消,显示"x"
- const displayContent = status === 'cancelled' ? 'x' : 'x';
-
- return {
- class: classNames,
- content: displayContent,
- style: { backgroundColor: this.getHospitalColor(hospitalId) }
- };
-},
+ console.log(` - addHospitalToSchedule: 医院=${hospitalId}, 当前计划=${shiftType}, 原计划=${originalPlan}`);
+
+ // 处理临时取消的班次
+ if (shiftType === "0" && originalPlan !== "0") {
+ console.log(` - 检测到临时取消: 医院=${hospitalId}, 原班次=${originalPlan}`);
+
+ if (!daySchedule[originalPlan]) {
+ daySchedule[originalPlan] = [];
+ }
+
+ const hospitalInfo = {
+ hid: hospitalId,
+ hospital_name: hospital.h_depart_name,
+ workTime: '已取消',
+ originalPlan: originalPlan,
+ currentPlan: shiftType,
+ isCancelled: true // 明确标记为取消
+ };
+
+ const existingIndex = daySchedule[originalPlan].findIndex(item => item.hid === hospitalId);
+ if (existingIndex >= 0) {
+ daySchedule[originalPlan][existingIndex] = hospitalInfo;
+ } else {
+ daySchedule[originalPlan].push(hospitalInfo);
+ }
+ return;
+ }
+
+ // 正常班次
+ if (shiftType !== "0") {
+ if (!daySchedule[shiftType]) {
+ daySchedule[shiftType] = [];
+ }
+
+ const hospitalInfo = {
+ hid: hospitalId,
+ hospital_name: hospital.h_depart_name,
+ workTime: workDesc,
+ originalPlan: originalPlan,
+ currentPlan: shiftType,
+ isCancelled: false
+ };
+
+ const existingIndex = daySchedule[shiftType].findIndex(item => item.hid === hospitalId);
+ if (existingIndex >= 0) {
+ daySchedule[shiftType][existingIndex] = hospitalInfo;
+ } else {
+ daySchedule[shiftType].push(hospitalInfo);
+ }
+ }
+ },
+
+ // addHospitalToSchedule(daySchedule, hospitalId, hospital, plan, workDesc) {
+ // const shiftType = plan.toString();
+ // const dateStr = daySchedule._dateStr;
+ // const originalPlan = this.getOriginalPlan(dateStr, hospitalId);
+
+ // console.log(` - addHospitalToSchedule: 医院=${hospitalId}, 当前计划=${shiftType}, 原计划=${originalPlan}`);
+
+ // // 处理临时取消的班次(原计划有班次,临时调整为不出诊)
+ // if (shiftType === "0" && originalPlan !== "0") {
+ // console.log(` - 检测到临时取消: 医院=${hospitalId}, 原班次=${originalPlan}`);
+ // // 在对应的原班次类型中添加取消标记
+ // if (!daySchedule[originalPlan]) {
+ // daySchedule[originalPlan] = [];
+ // }
+
+ // const hospitalInfo = {
+ // hid: hospitalId,
+ // hospital_name: hospital.h_depart_name,
+ // workTime: '已取消',
+ // originalPlan: originalPlan,
+ // currentPlan: shiftType,
+ // isCancelled: true // 标记为已取消
+ // };
+
+ // // 检查是否已经存在
+ // const existingIndex = daySchedule[originalPlan].findIndex(item => item.hid === hospitalId);
+ // if (existingIndex >= 0) {
+ // daySchedule[originalPlan][existingIndex] = hospitalInfo;
+ // } else {
+ // daySchedule[originalPlan].push(hospitalInfo);
+ // }
+ // console.log(` - 已添加到 ${originalPlan} 班次:`, hospitalInfo);
+ // return;
+ // }
+
+ // // 正常班次(非取消的)
+ // if (shiftType !== "0") {
+ // if (!daySchedule[shiftType]) {
+ // daySchedule[shiftType] = [];
+ // }
+
+ // const hospitalInfo = {
+ // hid: hospitalId,
+ // hospital_name: hospital.h_depart_name,
+ // workTime: workDesc,
+ // originalPlan: originalPlan,
+ // currentPlan: shiftType,
+ // isCancelled: false
+ // };
+
+ // const existingIndex = daySchedule[shiftType].findIndex(item => item.hid === hospitalId);
+ // if (existingIndex >= 0) {
+ // daySchedule[shiftType][existingIndex] = hospitalInfo;
+ // } else {
+ // daySchedule[shiftType].push(hospitalInfo);
+ // }
+ // console.log(` - 已添加到 ${shiftType} 班次:`, hospitalInfo);
+ // }
+ // },
// 获取排班优先级(数值越高优先级越高)
getSchedulePriority(hospitalId, plan, dateStr) {
const status = this.getTempAdjustmentStatus(dateStr, hospitalId, this.getOriginalPlan(dateStr, hospitalId));
@@ -1381,13 +1718,14 @@ getHospitalColorTag(dateStr, hospitalId, shiftType) {
return 0; // 固定排班
}
},
- // 获取指定日期的排班(集成临时调诊)
+ // 获取日期排班
getScheduleForDate(date) {
const dateStr = this.formatDate(date);
const dayOfWeek = date.getDay() === 0 ? 7 : date.getDay();
const daySchedule = {
_isTempAdjust: false,
- _conflicts: [] // 存储冲突信息
+ _conflicts: [],
+ _dateStr: dateStr // 添加日期标识
};
Object.keys(this.rawScheduleData).forEach(hospitalId => {
@@ -1413,6 +1751,8 @@ getHospitalColorTag(dateStr, hospitalId, shiftType) {
newPlan: finalPlan,
status: this.getTempAdjustmentStatus(dateStr, hospitalId, originalPlan)
};
+
+ console.log(`医院 ${hospitalId} 在 ${dateStr}: 原计划=${originalPlan}, 新计划=${finalPlan}, 状态=${this.tempAdjustments[dateStr][hospitalId].status}`);
} else {
// 固定排班
if (worktime_no_fixed === 0 && worktime_list && worktime_list[dayOfWeek]) {
@@ -1426,12 +1766,13 @@ getHospitalColorTag(dateStr, hospitalId, shiftType) {
}
}
- // 添加到排班
- if (finalPlan !== "0") {
- this.addHospitalToSchedule(daySchedule, hospitalId, hospital, finalPlan,
- temp_change_worktime && temp_change_worktime[dateStr] ?
- temp_change_worktime[dateStr].work_paln_desc :
- this.getWorkTimeDesc(finalPlan));
+ // 关键修改:即使 finalPlan 为 "0",也要处理临时调整的情况
+ if (isTempAdjust || finalPlan !== "0") {
+ const workDesc = temp_change_worktime && temp_change_worktime[dateStr] ?
+ temp_change_worktime[dateStr].work_paln_desc :
+ this.getWorkTimeDesc(finalPlan);
+
+ this.addHospitalToSchedule(daySchedule, hospitalId, hospital, finalPlan, workDesc);
if (isTempAdjust) {
daySchedule._isTempAdjust = true;
@@ -1444,11 +1785,10 @@ getHospitalColorTag(dateStr, hospitalId, shiftType) {
return Object.keys(daySchedule).length > 1 ? daySchedule : null;
},
-
// 检查排班冲突
checkScheduleConflicts(daySchedule, dateStr) {
console.log(dateStr);
- if (this.is_allow_coincide) return;
+ if (!this.is_allow_coincide) return;
for (const shiftType in daySchedule) {
if (shiftType === '_isTempAdjust' || shiftType === '_conflicts' || shiftType === '0') continue;
@@ -1499,8 +1839,31 @@ getHospitalColorTag(dateStr, hospitalId, shiftType) {
},
// 取消单医院临时调诊
singleTempCancel() {
- this.singleHosVisiable = false
-
+ this.singleHosVisiable = false;
+ let plan = this.currentEditingHospital.currentPlan;
+ let depart_id = this.currentEditingHospital.hid;
+ let plans = {
+ depart_id,
+ "morning_plan": plan,
+ "afternoon_plan": plan,
+ }
+ if(plan == '0'){
+ plans["morning_plan"] = '0';
+ plans["afternoon_plan"] = '0';
+ }else if(plan == '1'){
+ plans["morning_plan"] = '1';
+ plans["afternoon_plan"] = '0';
+ }else if(plan == '2'){
+ plans["morning_plan"] = '0';
+ plans["afternoon_plan"] = '1';
+ }else if(plan == '3'){
+ plans["morning_plan"] = '1';
+ plans["afternoon_plan"] = '1';
+ }
+ console.log(plans,'plans');
+ let plansList = []
+ plansList.push(plans)
+ this.saveTempAdjustment(this.currentEditingDate,plansList)
},
isCurrentMonth(date) {
const current = new Date();
@@ -1555,23 +1918,46 @@ getHospitalColorTag(dateStr, hospitalId, shiftType) {
},
// 获取指定日期的排班信息
+ // getDateSchedule(dateString) {
+ // // 如果这天还没有生成排班数据,就动态生成
+ // if (!this.calendarList[dateString]) {
+ // const date = new Date(dateString);
+ // const today = new Date();
+
+ // // 只生成今天及之后的排班
+ // if (date >= today) {
+ // const daySchedule = this.getScheduleForDate(date);
+ // if (daySchedule) {
+ // this.$set(this.calendarList, dateString, daySchedule);
+ // }
+ // }
+ // }
+ // // console.log(this.calendarList[dateString],dateString,'====this.calendarList[dateString]');
+ // return this.calendarList[dateString];
+ // },
+ // 检查排班数据是否有实际内容
+ hasActualSchedule(schedule) {
+ if (!schedule) return false;
+
+ const validKeys = Object.keys(schedule).filter(key =>
+ !['_isTempAdjust', '_conflicts', '_dateStr'].includes(key)
+ );
+
+ return validKeys.some(key => {
+ return schedule[key] && schedule[key].length > 0;
+ });
+ },
+
+ // 获取指定日期的排班信息(修改后的版本)
getDateSchedule(dateString) {
- // 如果这天还没有生成排班数据,就动态生成
- if (!this.calendarList[dateString]) {
- const date = new Date(dateString);
- const today = new Date();
-
- // 只生成今天及之后的排班
- if (date >= today) {
- const daySchedule = this.getScheduleForDate(date);
- if (daySchedule) {
- this.$set(this.calendarList, dateString, daySchedule);
- }
- }
- }
- // console.log(this.calendarList[dateString],'====this.calendarList[dateString]');
- return this.calendarList[dateString];
+ return this.formattedCalendarData[dateString] || null;
+ },
+ // 修改判断方法
+ hasScheduleData(dateString) {
+ return !!this.getDateSchedule(dateString);
},
+
+
formatCalendarData(responseData) {
const calendarData = {};
const today = new Date();
@@ -2481,7 +2867,14 @@ getHospitalColorTag(dateStr, hospitalId, shiftType) {
}
}
+