From b02e2bce2a81ae14832da574f544bc7a9cd4e3a4 Mon Sep 17 00:00:00 2001 From: zq <136432190602163.com> Date: Wed, 12 Nov 2025 11:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E5=88=9D=E5=A7=8B=E5=8C=BB?= =?UTF-8?q?=E9=99=A2=E6=95=B0=E6=8D=AE=EF=BC=8C=E4=BF=AE=E6=94=B9=E8=B0=83?= =?UTF-8?q?=E8=AF=8A=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/HosInformation.vue | 141 ++++++++++++++++++++++++++++++------------- 1 file changed, 100 insertions(+), 41 deletions(-) diff --git a/src/views/HosInformation.vue b/src/views/HosInformation.vue index e9c2bba..7c50569 100644 --- a/src/views/HosInformation.vue +++ b/src/views/HosInformation.vue @@ -425,7 +425,7 @@ -
+
{{ getDayNumber(data.day) }} @@ -623,11 +623,12 @@ 上午班
- {{ getAfternoonSelectedNames('morningSelectedHospitals') }} + + {{ morningSelectedNames }}
- - +
{{ item.name }} @@ -637,7 +638,6 @@ :checked="item.morning_plan == '1' ? true : false">
-
@@ -647,11 +647,12 @@ 下午班
- {{ getAfternoonSelectedNames('afternoonSelectedHospitals') }} + + {{ afternoonSelectedNames }}
- - +
{{ item.name }} @@ -949,6 +950,7 @@ export default { singleHosTitle: '出诊日历',//单个医院弹框标题 temp_plans: null,//临时调诊 hosList: [],//医院信息 + hosListCopy:[],//医院信息备份 currentDay: new Date(), calendarList1: [], calendarList: {}, // 用于存储格式化后的排班数据 @@ -983,6 +985,7 @@ export default { // afternoonSelectedHospitals: [], // 下午班选中的医院ID数组 isAfternoonDropdownOpen: false, isMornDropdownOpen: false, + } }, created() { @@ -1029,9 +1032,10 @@ export default { computed: { // 生成医院颜色映射对象 + // 根据医院列表生成颜色映射表,循环使用调色板中的颜色 hospitalColorMap() { const colorMap = {}; - this.hosList.forEach((hospital, index) => { + this.hosListCopy.forEach((hospital, index) => { colorMap[hospital.hid] = this.colorPalette[index % this.colorPalette.length]; }); return colorMap; @@ -1071,6 +1075,12 @@ export default { }); return configs; }, + morningSelectedNames() { + return this.getSelectedNames(this.morningSelectedHospitals); + }, + afternoonSelectedNames() { + return this.getSelectedNames(this.afternoonSelectedHospitals); + }, selectedCount() { return this.selectedRows.length; @@ -1078,6 +1088,19 @@ export default { ...mapState(['hosMenuData']) // 从Vuex映射showSidebar状态到组件的计算属性中 }, methods: { + getSelectedNames(selectedList) { + console.log(selectedList,'getSelectedNames----selectedList===='); + if (selectedList.length === 0) { + return '不出诊'; + } + + const selectedNames = selectedList.map(hid => { + const hospital = this.hosList.find(item => item.hid === hid); + return hospital ? hospital.name : ''; + }).filter(name => name); +console.log(selectedNames,'getSelectedNames--selectedNames'); + return selectedNames.join('、') || '休息'; + }, toggleAfternoonDropdown() { console.log('----09999',this.afternoonSelectedHospitals); if (this.isAfternoonDropdownOpen) { @@ -1096,12 +1119,24 @@ export default { this.isAfternoonDropdownOpen = false; }, - getAfternoonSelectedNames(list) { - if (this[list].length === 0) { - return '请选择'; + getMorningSelectedNames() { + if (this.morningSelectedHospitals.length === 0) { + return '不出诊'; + } + + const selectedNames = this.morningSelectedHospitals.map(hid => { + const hospital = this.hosList.find(item => item.hid === hid); + return hospital ? hospital.name : ''; + }).filter(name => name); + + return selectedNames.join('、') || '休息'; + }, + getAfternoonSelectedNames() { + if (this.afternoonSelectedHospitals.length === 0) { + return '不出诊'; } - const selectedNames = this[list].map(hid => { + const selectedNames = this.afternoonSelectedHospitals.map(hid => { const hospital = this.hosList.find(item => item.hid === hid); return hospital ? hospital.name : ''; }).filter(name => name); @@ -1155,7 +1190,6 @@ export default { }, // 选中上午班医院 selectMorningHospital(hospitalId,workHos) { - console.log(workHos,hospitalId,'workHos00000'); if (!this.is_allow_coincide && this[workHos].length >= 1) { // 不允许重合时,只能选一个,先清空再添加 @@ -1163,6 +1197,8 @@ export default { } else { // 允许重合或还没有选中任何项 if (!this[workHos].includes(hospitalId)) { + console.log(workHos,this[workHos],'workHos00000'); + this[workHos].push(hospitalId); } } @@ -1178,51 +1214,69 @@ export default { // 日历点击 handleDateClick(dateString, event) { event.stopPropagation(); - // 检查是否有排班数据 - if (!this.hasScheduleData(dateString)) { - console.log('该日期无排班数据'); + // 可修改今天及之后的数据 + const clickedDate = new Date(dateString); + const today = new Date(); + today.setHours(0, 0, 0, 0); // 清除时间部分,只比较日期 + + if (clickedDate < today) { + this.$Message.warning('无法调整过去的日期'); return; } + + // // 检查是否有排班数据 + // if (!this.hasScheduleData(dateString)) { + // console.log('该日期无排班数据'); + // return; + // } // 获取当天对应的周几信息 const date1 = new Date(dateString); const day = date1.getDay() const dayText = day == 0 ? '周日' : this.weekPlan[day] this.currentEditingDate = this.formatMonth(dateString, true) + ` ${dayText}` this.isShowDialogDate = this.hasTempAdjustments(dateString) - console.log('点击日期:000', this.isShowDialogDate, '999998888888', date1, this.currentEditingDate, dayText, dateString); + // console.log('点击日期:000', this.isShowDialogDate, '999998888888', date1, this.currentEditingDate, dayText, dateString); if (this.isShowDialogDate) { this.singleHosTitle = dayText + '出诊规则' } // 获取该日期的排班信息 - const schedule = this.getDateSchedule(dateString); - if (!schedule) return; + // const schedule = this.getDateSchedule(dateString); + // if (!schedule) return; // 获取该日期涉及的所有医院 const hospitals = this.getHospitalsByDate(dateString); + // console.log(this.hosListCopy,this.hosList,'=====测试一下两组数据源'); // 重构一下医院数据,增加上下午出诊状态 - this.hosList = this.hosList.map(item => { + this.hosList = this.hosListCopy.map(item => { let hospitalInfo = { hid: item.hid, name: item.h_depart_name, - workTime: '已取消', + workTime: '休息', originalPlan: '0', currentPlan: '0', isCancelled: false // 明确标记为取消 }; - hospitals.forEach(hospital => { - if (hospital.hid === item.hid) { - hospitalInfo = { ...hospital } - if (hospital.currentPlan == '1') { - hospitalInfo.morning_plan = '1' - } else if (hospital.currentPlan == '2') { - hospitalInfo.afternoon_plan = '1' - } else if (hospital.currentPlan == '3') { - hospitalInfo.morning_plan = '1' - hospitalInfo.afternoon_plan = '1' + if(hospitals.length > 0){ + hospitals.forEach(hospital => { + if (hospital.hid === item.hid) { + hospitalInfo = { ...hospital } + if (hospital.currentPlan == '1') { + hospitalInfo.morning_plan = '1' + hospitalInfo.afternoon_plan = '0' + } else if (hospital.currentPlan == '2') { + hospitalInfo.afternoon_plan = '1' + hospitalInfo.morning_plan = '0' + } else if (hospital.currentPlan == '3') { + hospitalInfo.morning_plan = '1' + hospitalInfo.afternoon_plan = '1' + }else{ + hospitalInfo.morning_plan = '0' + hospitalInfo.afternoon_plan = '0' + } } - } - }) - console.log(hospitalInfo, ' ...hospitalInfo'); + }) + } + // console.log(hospitalInfo, ' ...hospitalInfo'); return { morning_plan: '0', afternoon_plan: '0', @@ -1230,7 +1284,7 @@ export default { ...hospitalInfo, } }) - console.log(hospitals, this.hosList, 'hospitals==='); + // console.log(hospitals, this.hosList, 'hospitals==='); // 根据医院数量决定弹出哪种对话框 if (this.hosList.length === 1) { @@ -1245,6 +1299,7 @@ export default { }, // 初始化选中医院 initSelectedHospitals(hospitals) { + this.morningSelectedHospitals = []; this.afternoonSelectedHospitals = []; @@ -1259,10 +1314,8 @@ export default { this.afternoonSelectedHospitals.push(hid); } }); + console.log(hospitals,this.morningSelectedHospitals, this.afternoonSelectedHospitals, 'initSelectedHospitals-初始化的喧哗走ing'); this.moreHosVisiable = true; - // this.morningText = this.morningSelectedHospitals.join(', ') - // this.afterText = this.afternoonSelectedHospitals.join(', ') - console.log(this.morningSelectedHospitals, this.afternoonSelectedHospitals, '初始化的喧哗走ing'); }, // 确认多医院临时调诊 @@ -1318,6 +1371,8 @@ export default { if (response.code === 0) { this.$message.success('临时调整保存成功'); + this.afternoonSelectedHospitals = []; + this.morningSelectedHospitals = []; // 重新加载排班数据 this.getDoctorHosPreview(); } else { @@ -1864,6 +1919,8 @@ export default { h_depart_name: list[item].h_depart_name } }); + // 存储一份副本,用于后续操作 + this.hosListCopy = JSON.parse(JSON.stringify(this.hosList)) // 保存原始数据 // this.rawScheduleData = list; @@ -1940,11 +1997,11 @@ export default { const dateStr = daySchedule._dateStr; const originalPlan = this.getOriginalPlan(dateStr, hospitalId); - console.log(` - addHospitalToSchedule: 医院=${hospitalId}, 当前计划=${shiftType}, 原计划=${originalPlan}`); + // console.log(` - addHospitalToSchedule: 医院=${hospitalId}, 当前计划=${shiftType}, 原计划=${originalPlan}`); // 处理临时取消的班次 if (shiftType === "0" && originalPlan !== "0") { - console.log(` - 检测到临时取消: 医院=${hospitalId}, 原班次=${originalPlan}`); + // console.log(` - 检测到临时取消: 医院=${hospitalId}, 原班次=${originalPlan}`); if (!daySchedule[originalPlan]) { daySchedule[originalPlan] = []; @@ -2156,6 +2213,8 @@ export default { // 取消多医院临时调诊 moreTempCancel() { this.moreHosVisiable = false; + this.afternoonSelectedHospitals = []; + this.morningSelectedHospitals = []; }, isCurrentMonth(date) { const current = new Date();