340 预约管理-门诊预约挂号:选择患者弹窗列表数据字段显示错位

This commit is contained in:
2026-04-07 16:16:14 +08:00
parent c3f1b105e9
commit 7b6c972a12

View File

@@ -196,7 +196,6 @@
<td>{{ index + 1 }}</td>
<td>{{ patient.name }}</td>
<td>{{ patient.identifierNo || patient.medicalCard || patient.id }}</td>
<td>{{ patient.identifierNo }}</td>
<td>{{ getGenderText(patient.genderEnum_enumText || patient.genderEnum || patient.gender || patient.sex) }}</td>
<td>{{ patient.idCard }}</td>
<td>{{ patient.phone }}</td>
@@ -330,90 +329,10 @@ export default {
);
}
// 🎯 实时更新余号数量:统计该医生当前筛选条件下剩余可预约(未预约 + 未过期)号源数量
const availableCountMap = {};
this.filteredAndSortedTickets.forEach(ticket => {
const doctorId = String(ticket.doctorId || ticket.doctor_id);
if (!availableCountMap[doctorId]) {
availableCountMap[doctorId] = 0;
}
// 只有未预约的号源才算作可预约余号
if (ticket.status === '未预约') {
availableCountMap[doctorId]++;
}
});
// 更新每个医生的余号数量
filtered = filtered.map(doctor => {
const actualAvailable = availableCountMap[String(doctor.id)] || 0;
return {
...doctor,
available: actualAvailable
};
});
return filtered;
},
// 过滤并排序后的完整号源列表
filteredAndSortedTickets() {
let filtered = [...this.tickets];
// 🎯 精确过滤:过滤掉早于当前时间的号源
// - 日期早于今天 → 过滤
// - 日期是今天但号源时段已经开始(开始时间早于当前时间) → 过滤
const now = new Date();
filtered = filtered.filter(ticket => {
// dateTime 格式示例:"2024-01-01 08:00-09:00"
const parts = (ticket.dateTime || '').split(' ');
if (parts.length < 2) return true; // 如果格式不正确,保留显示
const dateStr = parts[0];
const timeRangeStr = parts[1];
if (!dateStr || !timeRangeStr) return true;
// 提取开始时间
const startTimeStr = timeRangeStr.split('-')[0]; // "08:00"
if (!startTimeStr) return true;
// 构建号源开始时间的完整 Date 对象
const ticketStartStr = `${dateStr} ${startTimeStr}`;
const ticketStart = new Date(ticketStartStr);
// 只显示开始时间晚于当前时间的号源
return ticketStart > now;
});
// 🎯 按开始时间升序排序 → 较早的号源排在前面
filtered.sort((a, b) => {
const getStartTime = (ticket) => {
const parts = (ticket.dateTime || '').split(' ');
if (parts.length < 2) return new Date(0).getTime();
const dateStr = parts[0];
const timeRangeStr = parts[1];
const startTimeStr = (timeRangeStr || '').split('-')[0];
if (!startTimeStr) return new Date(0).getTime();
const ticketStartStr = `${dateStr} ${startTimeStr}`;
return new Date(ticketStartStr).getTime();
};
const timeA = getStartTime(a);
const timeB = getStartTime(b);
return timeA - timeB;
});
return filtered;
},
// 🎯 分页:按照用户选择的每页条数分页,返回当前页的数据
filteredTickets() {
const filtered = this.filteredAndSortedTickets;
const startIndex = (this.currentPage - 1) * this.pageSize;
const endIndex = startIndex + this.pageSize;
return filtered.slice(startIndex, endIndex);
},
// 更新总条数为过滤后的实际条数,分页自动处理
totalTickets() {
return this.filteredAndSortedTickets.length;
return [...this.tickets];
},
hasSearchCriteria() {
return !!this.patientKeyword?.trim();
@@ -514,21 +433,21 @@ export default {
this.selectedPatient = null;
this.searchPatients();
},
// 双击未预约卡片触发患者选择流程
handleDoubleClick(ticket) {
if (ticket.status === '未预约') {
this.currentTicket = ticket;
this.patientKeyword = '';
this.selectedPatientId = null;
this.selectedPatient = null;
this.selectedPatient = null;
// 先打开弹窗,再加载患者数据,避免等待
this.showPatientModal = true;
// 调用患者搜索接口,加载患者列表
this.searchPatients();
}
},
// 右键已预约卡片显示取消预约菜单
handleRightClick(event, ticket) {
if (ticket.status === '已预约') {
@@ -537,13 +456,13 @@ export default {
this.contextMenuVisible = true;
}
},
// 关闭右键菜单
closeContextMenu() {
this.contextMenuVisible = false;
this.selectedTicketForCancel = null;
},
// 确认取消预约
confirmCancelAppointment() {
if (this.selectedTicketForCancel) {
@@ -565,7 +484,7 @@ export default {
});
}
},
// 取消预约API调用
cancelAppointment(ticket) {
if (!ticket || !ticket.slot_id) {
@@ -573,13 +492,13 @@ export default {
this.closeContextMenu();
return;
}
// 使用真实API调用取消预约传递slot_id
cancelTicket(ticket.slot_id).then(response => {
cancelTicket(ticket.slot_id).then(response => {
// 根据后端返回判断是否成功
if (response.code === 200 || response.msg === '取消成功' || response.message === '取消成功') {
console.log('取消预约成功,更新前端状态');
// API调用成功后更新当前卡片状态
const ticketIndex = this.tickets.findIndex(t => t.slot_id === ticket.slot_id);
if (ticketIndex !== -1) {
@@ -594,7 +513,7 @@ export default {
}
this.fetchTickets({ refreshDepartments: false, refreshDoctors: true }).catch(() => {});
// 关闭上下文菜单
this.closeContextMenu();
ElMessage.success('预约已取消,号源已释放');
@@ -711,24 +630,24 @@ export default {
if (genderValue === null || genderValue === undefined) {
return '未知';
}
// 将值转换为字符串进行比较
const strValue = String(genderValue).toLowerCase();
// 处理男性值
if (strValue === '0' || strValue === '男' || strValue === 'male' || strValue === 'm' ||
strValue === 'malegender' || strValue === 'man' || strValue === 'boy' ||
if (strValue === '0' || strValue === '男' || strValue === 'male' || strValue === 'm' ||
strValue === 'malegender' || strValue === 'man' || strValue === 'boy' ||
strValue === '男性' || strValue === '男士') {
return '男';
}
// 处理女性值
if (strValue === '1' || strValue === '女' || strValue === 'female' || strValue === 'f' ||
strValue === 'femalegender' || strValue === 'woman' || strValue === 'girl' ||
if (strValue === '1' || strValue === '女' || strValue === 'female' || strValue === 'f' ||
strValue === 'femalegender' || strValue === 'woman' || strValue === 'girl' ||
strValue === '女性' || strValue === '女士') {
return '女';
}
// 如果都不是,返回"未知"
return '未知';
},
@@ -741,7 +660,7 @@ export default {
if (patient.gender !== undefined && patient.gender !== null) {
return patient.gender;
}
// 如果genderEnum_enumText是"男性"或"女性",转换为对应的数字
if (patient.genderEnum_enumText) {
const text = patient.genderEnum_enumText.toLowerCase();
@@ -754,7 +673,7 @@ export default {
// 默认返回0男性
return 0;
},
// 检测是否为移动设备
checkMobileDevice() {
this.isMobile = window.innerWidth <= 768;
@@ -813,8 +732,12 @@ export default {
const total = Number(payload.total);
this.tickets = [...filteredRecords];
this.allTickets = [...filteredRecords];
// 后端已经分页总条数由后端返回始终使用后端返回的total
this.totalTickets = Number.isFinite(total) ? total : this.tickets.length;
// 当按状态筛选时,优先使用前端过滤后的数量,避免后端状态未生效导致“显示全部”
if (this.selectedStatus && this.selectedStatus !== 'all') {
this.totalTickets = this.tickets.length;
} else {
this.totalTickets = Number.isFinite(total) ? total : this.tickets.length;
}
},
applyStatusFilter(records = []) {
if (!Array.isArray(records) || records.length === 0) {