From f204e46e07aaefa92793fc965601c880633d3e84 Mon Sep 17 00:00:00 2001
From: Ranyunqiao <2499115710@qq.com>
Date: Thu, 9 Apr 2026 11:06:06 +0800
Subject: [PATCH] =?UTF-8?q?344=20=E9=97=A8=E8=AF=8A=E9=A2=84=E7=BA=A6?=
=?UTF-8?q?=E6=8C=82=E5=8F=B7=EF=BC=9A=E6=9C=AA=E8=BF=87=E6=BB=A4=E8=BF=87?=
=?UTF-8?q?=E6=9C=9F=E5=8F=B7=E6=BA=90=EF=BC=8C=E5=85=81=E8=AE=B8=E9=A2=84?=
=?UTF-8?q?=E7=BA=A6=E5=B7=B2=E8=BF=87=E6=97=B6=E7=9A=84=E6=97=B6=E9=97=B4?=
=?UTF-8?q?=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../appointmentmanage/dto/TicketQueryDTO.java | 3 ++
.../administration/ScheduleSlotMapper.xml | 28 ++++++++++++------
.../outpatientAppointment/index.vue | 29 +++++++++++--------
3 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/dto/TicketQueryDTO.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/dto/TicketQueryDTO.java
index 429aa6df..458d7ba0 100644
--- a/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/dto/TicketQueryDTO.java
+++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/dto/TicketQueryDTO.java
@@ -40,4 +40,7 @@ public class TicketQueryDTO implements Serializable {
// 每页显示条数 (默认查20条)
private Integer limit = 20;
+
+ // 浏览器当前时间戳(用来过滤过期号源,保证前后端一致)
+ private Long currentTime;
}
diff --git a/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml b/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml
index f2418441..8f6ad801 100644
--- a/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml
+++ b/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml
@@ -358,14 +358,22 @@
p.doctor_id AS doctorId,
p.doctor_name AS doctorName,
p.schedule_date AS scheduleDate,
- COALESCE(
- SUM(
- GREATEST(
- COALESCE(p.total_quota, 0) - COALESCE(p.booked_num, 0) - COALESCE(p.locked_num, 0),
- 0
+
+ COUNT(
+ CASE
+ WHEN s.delete_flag = '0'
+ AND = 0
+
+ AND (
+ p.schedule_date > CURRENT_DATE
+ OR (
+ p.schedule_date = CURRENT_DATE
+ AND CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME) > TO_TIMESTAMP(#{query.currentTime}/1000)
+ )
)
- ),
- 0
+ THEN s.id
+ ELSE NULL
+ END
) AS available,
COUNT(DISTINCT p.id) AS poolCount,
CASE
@@ -380,10 +388,12 @@
FROM
adm_schedule_pool p
LEFT JOIN adm_doctor_schedule d ON p.schedule_id = d.id
- LEFT JOIN adm_organization org ON p.dept_id = org.id
- AND org.delete_flag = '0'
+ LEFT JOIN adm_organization org ON p.dept_id = org.id AND org.delete_flag = '0'
+ LEFT JOIN adm_schedule_slot s ON s.pool_id = p.id AND s.delete_flag = '0'
p.delete_flag = '0'
+
+ AND (d.is_stopped IS NULL OR d.is_stopped = FALSE)
AND p.schedule_date = CAST(#{query.date} AS DATE)
diff --git a/openhis-ui-vue3/src/views/appoinmentmanage/outpatientAppointment/index.vue b/openhis-ui-vue3/src/views/appoinmentmanage/outpatientAppointment/index.vue
index b7133271..e98e4ed8 100644
--- a/openhis-ui-vue3/src/views/appoinmentmanage/outpatientAppointment/index.vue
+++ b/openhis-ui-vue3/src/views/appoinmentmanage/outpatientAppointment/index.vue
@@ -697,15 +697,17 @@ export default {
name: this.patientName?.trim() || null,
card: this.patientCard?.trim() || null,
phone: this.patientPhone?.trim() || null,
- page,
- limit: this.pageSize
+ page: 1,
+ limit: 1000 // 获取全量数据,前端过滤后再分页,避免过滤后分页错乱
};
},
buildDoctorQueryParams() {
return {
date: this.selectedDate,
type: this.selectedType === 'all' ? null : this.selectedType,
- department: this.selectedDepartment === 'all' ? null : this.selectedDepartment
+ department: this.selectedDepartment === 'all' ? null : this.selectedDepartment,
+ // 传递浏览器当前时间戳,后端用这个时间过滤过期号源,保证和前端过滤一致
+ currentTime: new Date().getTime()
};
},
handleTicketResponse(ticketResponse) {
@@ -746,15 +748,15 @@ export default {
// 再进行状态过滤
const filteredRecords = this.applyStatusFilter(timeFilteredRecords);
- const total = Number(payload.total);
- this.tickets = [...filteredRecords];
+ // 现在我们获取了全量数据,在前端过滤完成后再分页
+ // 这样保证过滤后分页正确,不会出现第一页空第二页有数据
this.allTickets = [...filteredRecords];
- // 当按状态筛选时,优先使用前端过滤后的数量,避免后端状态未生效导致"显示全部"
- if (this.selectedStatus && this.selectedStatus !== 'all') {
- this.totalTickets = this.tickets.length;
- } else {
- this.totalTickets = Number.isFinite(total) ? total : this.tickets.length;
- }
+ this.totalTickets = this.allTickets.length;
+
+ // 从过滤后的全量数据中取出当前页
+ const start = (this.currentPage - 1) * this.pageSize;
+ const end = start + this.pageSize;
+ this.tickets = this.allTickets.slice(start, end);
},
applyStatusFilter(records = []) {
if (!Array.isArray(records) || records.length === 0) {
@@ -791,7 +793,8 @@ export default {
doctorList = data.data;
}
- this.doctors = doctorList
+ // 初始用后端返回的数据
+ let initialDoctors = doctorList
.map((doctor, index) => {
const id = doctor?.id ?? doctor?.doctorId ?? index;
const available = Number(doctor?.available ?? doctor?.availableNum ?? doctor?.available_num ?? 0);
@@ -804,6 +807,8 @@ export default {
})
.filter(doctor => !!doctor.name);
+ this.doctors = initialDoctors;
+
if (this.selectedDoctorId && !this.doctors.some(d => d.id === this.selectedDoctorId)) {
this.selectedDoctorId = null;
}