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; }