76 门诊预约挂号

This commit is contained in:
huabuweixin
2026-01-22 15:09:52 +08:00
parent 4450e3cc50
commit 0d57e984a6
13 changed files with 548 additions and 3820 deletions

View File

@@ -13,14 +13,6 @@ import java.util.Map;
*/ */
public interface ITicketAppService { public interface ITicketAppService {
/**
* 查询号源列表
*
* @param params 查询参数
* @return 号源列表
*/
R<?> listTicket(Map<String, Object> params);
/** /**
* 预约号源 * 预约号源
* *

View File

@@ -4,20 +4,28 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R; import com.core.common.core.domain.R;
import com.openhis.administration.domain.Patient; import com.openhis.administration.domain.Patient;
import com.openhis.administration.service.IPatientService; import com.openhis.administration.service.IPatientService;
import com.openhis.appointmentmanage.domain.DoctorSchedule;
import com.openhis.appointmentmanage.mapper.DoctorScheduleMapper;
import com.openhis.appointmentmanage.service.IDoctorScheduleService;
import com.openhis.clinical.domain.Order;
import com.openhis.clinical.domain.Ticket; import com.openhis.clinical.domain.Ticket;
import com.openhis.clinical.mapper.OrderMapper;
import com.openhis.clinical.service.ITicketService; import com.openhis.clinical.service.ITicketService;
import com.openhis.web.appointmentmanage.appservice.IDoctorScheduleAppService;
import com.openhis.web.appointmentmanage.appservice.ITicketAppService; import com.openhis.web.appointmentmanage.appservice.ITicketAppService;
import com.openhis.web.appointmentmanage.dto.TicketDto; import com.openhis.web.appointmentmanage.dto.TicketDto;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* 号源管理应用服务实现类 * 号源管理应用服务实现类
* *
@@ -31,145 +39,14 @@ public class TicketAppServiceImpl implements ITicketAppService {
@Resource @Resource
private IPatientService patientService; private IPatientService patientService;
@Resource
private IDoctorScheduleAppService doctorScheduleAppService;
@Resource
private DoctorScheduleMapper doctorScheduleMapper;
@Resource
private OrderMapper orderMapper;
/** private static final Logger log = LoggerFactory.getLogger(TicketAppServiceImpl.class);
* 查询号源列表
*
* @param params 查询参数
* @return 号源列表
*/
@Override
public R<?> listTicket(Map<String, Object> params) {
// 调试日志:打印所有参数
System.out.println("=== listTicket方法收到的所有参数===");
for (Map.Entry<String, Object> entry : params.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
System.out.println("=================================");
// 构建查询条件
Ticket ticket = new Ticket();
// 设置查询参数
// 处理日期参数
if (params.containsKey("date")) {
String date = (String) params.get("date");
try {
// 将日期字符串转换为Date类型设置到appointmentDate字段
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date appointmentDate = sdf.parse(date);
ticket.setAppointmentDate(appointmentDate);
System.out.println("设置的appointmentDate" + appointmentDate);
} catch (Exception e) {
// 日期格式错误,忽略该参数
System.out.println("日期格式错误,忽略该参数:" + date + ",错误信息:" + e.getMessage());
}
}
// 处理状态参数
if (params.containsKey("status")) {
String status = (String) params.get("status");
System.out.println("接收到的status参数" + status);
if (!"all".equals(status) && !"全部".equals(status)) {
// 将中文状态转换为英文状态
if ("未预约".equals(status)) {
ticket.setStatus("unbooked");
} else if ("已预约".equals(status)) {
ticket.setStatus("booked");
} else if ("已取号".equals(status)) {
ticket.setStatus("checked");
} else if ("已取消".equals(status)) {
ticket.setStatus("cancelled");
} else if ("已锁定".equals(status)) {
ticket.setStatus("locked");
} else {
ticket.setStatus(status);
}
System.out.println("设置的status" + ticket.getStatus());
}
}
if (params.containsKey("name")) {
String name = (String) params.get("name");
ticket.setPatientName(name);
}
if (params.containsKey("card")) {
String card = (String) params.get("card");
ticket.setMedicalCard(card);
}
if (params.containsKey("phone")) {
String phone = (String) params.get("phone");
ticket.setPhone(phone);
}
if (params.containsKey("type")) {
String type = (String) params.get("type");
System.out.println("前端传递的type参数值" + type);
if (!"all".equals(type)) {
// 类型映射转换:前端传递英文类型,数据库存储中文类型
if ("general".equals(type)) {
ticket.setTicketType("普通");
} else if ("expert".equals(type)) {
ticket.setTicketType("专家");
} else if ("普通".equals(type)) {
ticket.setTicketType("普通");
} else if ("专家".equals(type)) {
ticket.setTicketType("专家");
} else {
ticket.setTicketType(type);
}
System.out.println("转换后的ticketType值" + ticket.getTicketType());
}
}
// 手动实现分页查询避免MyBatis-Plus自动COUNT查询的问题
int pageNum = params.get("page") != null ? Integer.valueOf(params.get("page").toString()) : 1;
int pageSize = params.get("limit") != null ? Integer.valueOf(params.get("limit").toString()) : 10;
// 调试:输出构建的查询条件
System.out.println("构建的查询条件ticketType=" + ticket.getTicketType() + ", status=" + ticket.getStatus() + ", appointmentDate=" + ticket.getAppointmentDate());
// 1. 获取所有符合条件的记录
List<Ticket> allTickets = ticketService.selectTicketList(ticket);
// 调试:输出查询到的所有记录
System.out.println("查询到的所有记录:" + allTickets);
if (!allTickets.isEmpty()) {
for (Ticket t : allTickets) {
System.out.println("记录详情id=" + t.getId() + ", ticketType=" + t.getTicketType() + ", status=" + t.getStatus() + ", appointmentDate=" + t.getAppointmentDate() + ", deleteFlag=" + t.getDeleteFlag());
}
}
// 2. 计算总记录数
long total = allTickets.size();
System.out.println("手动计算的总记录数:" + total);
// 3. 手动分页
int start = (pageNum - 1) * pageSize;
int end = Math.min(start + pageSize, allTickets.size());
List<Ticket> pageTickets;
if (start >= end) {
pageTickets = new ArrayList<>();
} else {
pageTickets = allTickets.subList(start, end);
}
// 4. 转换为DTO
List<TicketDto> dtoList = pageTickets.stream().map(this::convertToDto).toList();
// 5. 构建响应数据,符合前端预期格式
Map<String, Object> result = new HashMap<>();
result.put("list", dtoList);
result.put("records", dtoList); // 兼容前端框架如Element UI可能使用的records字段
result.put("total", total);
result.put("page", pageNum);
result.put("current", pageNum); // 兼容前端框架可能使用的current字段
result.put("limit", pageSize);
result.put("pageSize", pageSize); // 兼容前端框架可能使用的pageSize字段
result.put("size", pageSize); // 兼容前端框架可能使用的size字段
result.put("pageNum", pageNum); // 兼容前端框架可能使用的pageNum字段
result.put("pages", (int) Math.ceil((double) total / pageSize)); // 计算总页数
// 调试:输出响应数据
System.out.println("返回的响应数据:" + result);
return R.ok(result);
}
/** /**
* 预约号源 * 预约号源
@@ -179,35 +56,73 @@ public class TicketAppServiceImpl implements ITicketAppService {
*/ */
@Override @Override
public R<?> bookTicket(Map<String, Object> params) { public R<?> bookTicket(Map<String, Object> params) {
// 1. 获取 ticketId 和 slotId
Long ticketId = null; Long ticketId = null;
Long slotId = null;
if (params.get("ticketId") != null) { if (params.get("ticketId") != null) {
ticketId = Long.valueOf(params.get("ticketId").toString()); ticketId = Long.valueOf(params.get("ticketId").toString());
} }
if (ticketId == null) { if (params.get("slotId") != null) {
return R.fail("参数错误"); slotId = Long.valueOf(params.get("slotId").toString());
} }
// 2. 参数校验
if (ticketId == null || slotId == null) {
return R.fail("参数错误ticketId 或 slotId 不能为空");
}
try { try {
// 3. 执行原有的预约逻辑
int result = ticketService.bookTicket(params); int result = ticketService.bookTicket(params);
return R.ok(result > 0 ? "预约成功" : "预约失败"); if (result > 0) {
// 4. 预约成功后,更新排班表状态
DoctorSchedule schedule = new DoctorSchedule();
schedule.setId(Math.toIntExact(slotId)); // 对应 XML 中的 WHERE id = #{id}
schedule.setIsStopped(true); // 设置为已预约
schedule.setStopReason("booked"); // 设置停用原因
// 执行更新
int updateCount = doctorScheduleMapper.updateDoctorSchedule(schedule);
if (updateCount > 0) {
return R.ok("预约成功并已更新排班状态");
} else {
// 如果更新失败,可能需要根据业务逻辑决定是否回滚预约
return R.ok("预约成功,但排班状态更新失败");
}
} else {
return R.fail("预约失败");
}
} catch (Exception e) { } catch (Exception e) {
return R.fail(e.getMessage()); // e.printStackTrace();
log.error(e.getMessage());
return R.fail("系统异常:" + e.getMessage());
} }
} }
/** /**
* 取消预约 * 取消预约
* *
* @param ticketId 号源ID * @param slotId 医生排班ID
* @return 结果 * @return 结果
*/ */
@Override @Override
public R<?> cancelTicket(Long ticketId) { public R<?> cancelTicket(Long slotId) {
if (ticketId == null) { if (slotId == null) {
return R.fail("参数错误"); return R.fail("参数错误");
} }
try { try {
int result = ticketService.cancelTicket(ticketId); ticketService.cancelTicket(slotId);
return R.ok(result > 0 ? "取消成功" : "取消失败"); DoctorSchedule schedule = new DoctorSchedule();
schedule.setId(Math.toIntExact(slotId)); // 对应 WHERE id = #{id}
schedule.setIsStopped(false); // 设置为 false (数据库对应 0)
schedule.setStopReason(""); // 将原因清空 (设为空字符串)
// 3. 调用自定义更新方法
int updateCount = doctorScheduleMapper.updateDoctorSchedule(schedule);
if (updateCount > 0) {
return R.ok("取消成功");
} else {
return R.ok("取消成功");
}
} catch (Exception e) { } catch (Exception e) {
return R.fail(e.getMessage()); return R.fail(e.getMessage());
} }
@@ -253,31 +168,87 @@ public class TicketAppServiceImpl implements ITicketAppService {
@Override @Override
public R<?> listAllTickets() { public R<?> listAllTickets() {
// 创建固定的测试数据,用于验证前端是否能展示数据 // 1. 从 AppService 获取排班数据
List<TicketDto> testTickets = new ArrayList<>(); R<?> response = doctorScheduleAppService.getDoctorScheduleList();
// 获取返回的 List 数据 (假设 R.ok 里的数据是 List<DoctorSchedule>)
// 创建5条测试数据 List<DoctorSchedule> scheduleList = (List<DoctorSchedule>) response.getData();
for (int i = 1; i <= 5; i++) {
TicketDto dto = new TicketDto(); // 2. 转换数据为 TicketDto
dto.setSlot_id((long) i); List<TicketDto> tickets = new ArrayList<>();
dto.setBusNo("TEST0000" + i);
dto.setDepartment("内科"); if (scheduleList != null) {
dto.setDoctor("张三"); for (DoctorSchedule schedule : scheduleList) {
dto.setTicketType("expert"); TicketDto dto = new TicketDto();
dto.setDateTime("08:00-08:50");
dto.setStatus("未预约"); // 基础信息映射
dto.setFee("150"); dto.setSlot_id(Long.valueOf(schedule.getId())); // Integer 转 Long
dto.setAppointmentDate(new Date()); dto.setBusNo(String.valueOf(schedule.getId())); // 生成一个业务编号
testTickets.add(dto); dto.setDepartment(String.valueOf(schedule.getDeptId())); // 如果有科室名建议关联查询这里暂填ID
dto.setDoctor(schedule.getDoctor());
// 号源类型处理:根据挂号项目判断是普通号还是专家号
String registerItem = schedule.getRegisterItem();
if (registerItem != null && registerItem.contains("专家")) {
dto.setTicketType("expert");
} else {
dto.setTicketType("general");
}
// 时间处理:格式化为日期+时间范围,如 "2025-12-01 08:00-12:00"
String currentDate = LocalDate.now().toString(); // 或者从schedule中获取具体日期
String timeRange = schedule.getStartTime() + "-" + schedule.getEndTime();
dto.setDateTime(currentDate + " " + timeRange);
LocalTime nowTime = LocalTime.now();
LocalTime endTime = schedule.getEndTime();
String stopReason1 = schedule.getStopReason();
if ("cancelled".equals(stopReason1)||(endTime != null && nowTime.isAfter(endTime))) {
dto.setStatus("已停诊");
}else if (Boolean.TRUE.equals(schedule.getIsStopped())) {
// 获取原因并处理可能的空值
String stopReason = schedule.getStopReason();
// 使用 .equals() 比较内容,并将常量放在前面防止空指针
if ("booked".equals(stopReason)) {
dto.setStatus("已预约");
// --- 新增:获取患者信息 ---
List<Order> Order = orderMapper.selectOrderBySlotId(Long.valueOf(schedule.getId()));
Order latestOrder=Order.get(0);
if (latestOrder != null) {
dto.setPatientName(latestOrder.getPatientName());
dto.setPatientId(String.valueOf(latestOrder.getPatientId()));
dto.setPhone(latestOrder.getPhone());
}
// -----------------------
} else if ("checked".equals(stopReason)) {
dto.setStatus("已取号");
} else {
// 兜底逻辑:如果 is_stopped 为 true 但没有匹配到原因
dto.setStatus("不可预约");
}
} else {
// is_stopped 为 false 或 null 时
dto.setStatus("未预约");
}
// 费用处理 (挂号费 + 诊疗费)
int totalFee = schedule.getRegisterFee() + schedule.getDiagnosisFee();
dto.setFee(String.valueOf(totalFee));
// 日期处理LocalDateTime 转 Date
if (schedule.getCreateTime() != null) {
ZonedDateTime zdt = schedule.getCreateTime().atZone(ZoneId.systemDefault());
dto.setAppointmentDate(Date.from(zdt.toInstant()));
}
tickets.add(dto);
}
} }
// 构建响应数据 // 3. 封装分页响应结
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("list", testTickets); result.put("list", tickets);
result.put("total", testTickets.size()); result.put("total", tickets.size());
result.put("page", 1); result.put("page", 1);
result.put("limit", 20); result.put("limit", 20);
return R.ok(result); return R.ok(result);
} }
@@ -322,9 +293,6 @@ public class TicketAppServiceImpl implements ITicketAppService {
case "cancelled": case "cancelled":
dto.setStatus("已取消"); dto.setStatus("已取消");
break; break;
case "locked":
dto.setStatus("已锁定");
break;
default: default:
dto.setStatus(status); dto.setStatus(status);
} }

View File

@@ -21,28 +21,6 @@ public class TicketController {
@Resource @Resource
private ITicketAppService ticketAppService; private ITicketAppService ticketAppService;
/**
* 查询号源列表
*
* @param params 查询参数
* @return 号源列表
*/
@PostMapping("/list")
public R<?> listTicket(@RequestBody Map<String, Object> params) {
return ticketAppService.listTicket(params);
}
/**
* 查询号源列表支持GET请求兼容旧版本
*
* @param params 查询参数
* @return 号源列表
*/
@GetMapping("/list")
public R<?> listTicketByGet(@RequestParam Map<String, Object> params) {
return ticketAppService.listTicket(params);
}
/** /**
* 查询所有号源(用于测试) * 查询所有号源(用于测试)

View File

@@ -46,6 +46,29 @@
<if test="updateTime != null">, #{updateTime}</if> <if test="updateTime != null">, #{updateTime}</if>
) )
</insert> </insert>
<!--自定义更新方法-->
<update id="updateDoctorSchedule" parameterType="com.openhis.appointmentmanage.domain.DoctorSchedule">
UPDATE adm_doctor_schedule
<set>
<if test="weekday != null">weekday = #{weekday},</if>
<if test="timePeriod != null">time_period = #{timePeriod},</if>
<if test="doctor != null">doctor = #{doctor},</if>
<if test="clinic != null">clinic = #{clinic},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="limitNumber != null">limit_number = #{limitNumber},</if>
<if test="callSignRecord != null">call_sign_record = #{callSignRecord},</if>
<if test="registerItem != null">register_item = #{registerItem},</if>
<if test="registerFee != null">register_fee = #{registerFee},</if>
<if test="diagnosisItem != null">diagnosis_item = #{diagnosisItem},</if>
<if test="diagnosisFee != null">diagnosis_fee = #{diagnosisFee},</if>
<if test="isOnline != null">is_online = #{isOnline},</if>
<if test="isStopped != null">is_stopped = #{isStopped},</if>
<if test="stopReason != null">stop_reason = #{stopReason},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="updateTime != null">update_time = #{updateTime}</if>
</set>
WHERE id = #{id}
</update>
</mapper> </mapper>

View File

@@ -10,4 +10,8 @@ public interface DoctorScheduleMapper extends BaseMapper<DoctorSchedule> {
* 自定义插入方法排除id字段数据库GENERATED ALWAYS * 自定义插入方法排除id字段数据库GENERATED ALWAYS
*/ */
int insertWithoutId(DoctorSchedule doctorSchedule); int insertWithoutId(DoctorSchedule doctorSchedule);
/**
* 自定义更新方法
*/
int updateDoctorSchedule(DoctorSchedule doctorSchedule);
} }

View File

@@ -27,7 +27,7 @@ public interface OrderMapper extends BaseMapper<Order> {
int countOrders(Map<String, Object> params); int countOrders(Map<String, Object> params);
Order selectOrderBySlotId(Long slotId); List<Order> selectOrderBySlotId(Long slotId);
int updateOrderStatusById(Long id, Integer status); int updateOrderStatusById(Long id, Integer status);

View File

@@ -25,8 +25,7 @@ public interface IOrderService extends IService<Order> {
int countOrders(Map<String, Object> params); int countOrders(Map<String, Object> params);
Order selectOrderBySlotId(Long slotId); List<Order> selectOrderBySlotId(Long slotId);
int updateOrderStatusById(Long id, Integer status); int updateOrderStatusById(Long id, Integer status);
int updateOrderCancelInfoById(Long id, java.util.Date cancelTime, String cancelReason); int updateOrderCancelInfoById(Long id, java.util.Date cancelTime, String cancelReason);

View File

@@ -3,7 +3,6 @@ package com.openhis.clinical.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.core.common.utils.AssignSeqUtil; import com.core.common.utils.AssignSeqUtil;
import com.core.common.utils.SecurityUtils;
import com.openhis.clinical.domain.Order; import com.openhis.clinical.domain.Order;
import com.openhis.clinical.domain.Ticket; import com.openhis.clinical.domain.Ticket;
import com.openhis.clinical.mapper.OrderMapper; import com.openhis.clinical.mapper.OrderMapper;
@@ -71,7 +70,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
} }
@Override @Override
public Order selectOrderBySlotId(Long slotId) { public List<Order> selectOrderBySlotId(Long slotId) {
return orderMapper.selectOrderBySlotId(slotId); return orderMapper.selectOrderBySlotId(slotId);
} }

View File

@@ -197,8 +197,8 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
throw new RuntimeException("号源不可取消预约"); throw new RuntimeException("号源不可取消预约");
} }
Order order = orderService.selectOrderBySlotId(ticketId); List<Order> orders = orderService.selectOrderBySlotId(ticketId);
if (order != null) { for(Order order:orders){
orderService.cancelAppointmentOrder(order.getId(), "患者取消预约"); orderService.cancelAppointmentOrder(order.getId(), "患者取消预约");
} }
@@ -249,8 +249,8 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
} }
// 检查是否存在相关订单,如果存在则取消 // 检查是否存在相关订单,如果存在则取消
Order order = orderService.selectOrderBySlotId(ticketId); List<Order> orders = orderService.selectOrderBySlotId(ticketId);
if (order != null) { for(Order order:orders){
orderService.cancelAppointmentOrder(order.getId(), "医生停诊"); orderService.cancelAppointmentOrder(order.getId(), "医生停诊");
} }

View File

@@ -119,6 +119,8 @@
<select id="selectOrderById" resultMap="OrderResult"> <select id="selectOrderById" resultMap="OrderResult">
select * from order_main where id = #{id} select * from order_main where id = #{id}
and status = 1
order by create_time desc
</select> </select>
<select id="selectOrderBySlotId" resultMap="OrderResult"> <select id="selectOrderBySlotId" resultMap="OrderResult">

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
<div id="topSearchArea" class="top-search-area"> <div id="topSearchArea" class="top-search-area">
<!-- 搜索标签行 --> <!-- 搜索标签行 -->
<div class="search-labels"> <div class="search-labels">
<div class="search-label">源日期</div> <div class="search-label">源日期</div>
<div class="search-label">状态</div> <div class="search-label">状态</div>
<div class="search-label">患者姓名</div> <div class="search-label">患者姓名</div>
<div class="search-label">就诊卡号</div> <div class="search-label">就诊卡号</div>
@@ -34,8 +34,7 @@
<select id="status-select" class="search-select" v-model="selectedStatus"> <select id="status-select" class="search-select" v-model="selectedStatus">
<option value="all">全部</option> <option value="all">全部</option>
<option value="unbooked">未预约</option> <option value="unbooked">未预约</option>
<option value="locked">锁定</option> <option value="booked">已预约</option>
<option value="booked">待缴费</option>
<option value="checked">已取号</option> <option value="checked">已取号</option>
<option value="cancelled">已停诊</option> <option value="cancelled">已停诊</option>
</select> </select>
@@ -105,38 +104,34 @@
<!-- 使用网格布局的号源卡片列表 --> <!-- 使用网格布局的号源卡片列表 -->
<div class="ticket-grid" v-if="filteredTickets.length > 0"> <div class="ticket-grid" v-if="filteredTickets.length > 0">
<div v-for="(item, index) in filteredTickets" :key="item.slot_id" class="ticket-card" @dblclick="handleDoubleClick(item)" @contextmenu.prevent="handleRightClick($event, item)"> <div v-for="(item, index) in filteredTickets" :key="item.slot_id" class="ticket-card" @dblclick="handleDoubleClick(item)" @contextmenu.prevent="handleRightClick($event, item)">
<div class="ticket-header"> <!-- 序号放在最右侧 -->
<div class="ticket-number">{{ index + 1 }}</div> <div class="ticket-index">{{ index + 1 }}</div>
<div class="ticket-type-badge" :class="item.ticketType === 'general' ? 'type-general' : 'type-expert'"> <!-- 1.时间 -->
{{ item.ticketType === 'general' ? '普通' : '专家' }} <div class="ticket-id-time">{{ item.dateTime }}</div>
</div> <!-- 2. 状态标签 -->
</div>
<div class="ticket-time">{{ item.dateTime }}</div>
<div class="ticket-doctor">{{ item.doctor }}</div>
<div class="ticket-status" :class="`status-${item.status}`"> <div class="ticket-status" :class="`status-${item.status}`">
<span class="status-dot"></span> <span class="status-dot"></span>
{{ item.status }} {{ item.status }}
</div> </div>
<div class="ticket-fee">挂号费: {{ item.fee }}</div> <!-- 3. 医生姓名截断显示悬停展示完整信息 -->
<!-- 显示患者信息如果已预约或已取号 --> <div class="ticket-doctor" :title="item.doctor">{{ item.doctor }}</div>
<!-- 4. 挂号费 -->
<div class="ticket-fee">挂号费{{ item.fee }}</div>
<!-- 5. 号源类型 -->
<div class="ticket-type">{{ item.ticketType === 'general' ? '普通' : '专家' }}</div>
<!-- 6. 已预约患者信息 -->
<div v-if="(item.status === '已预约' || item.status === '已取号') && item.patientName" class="ticket-patient"> <div v-if="(item.status === '已预约' || item.status === '已取号') && item.patientName" class="ticket-patient">
<div class="patient-name">{{ item.patientName }}</div> {{ item.patientName }}({{ item.patientId }})
<div class="patient-card">{{ item.patientId }}</div> </div>
<div class="patient-gender">性别{{ item.patientGender || '-' }}</div> <!-- 7. 患者电话号码 -->
<div v-if="(item.status === '已预约' || item.status === '已取号') && item.phone" class="ticket-phone">
电话号码 {{ item.phone }}
</div> </div>
<div class="ticket-actions"> <div class="ticket-actions">
<button class="action-button book-button" @click="openPatientSelectModal(item.slot_id)" :disabled="item.status !== '未预约'" :class="{ 'disabled': item.status !== '未预约' }"> <button class="action-button book-button" @click="openPatientSelectModal(item.slot_id)" :disabled="item.status !== '未预约'" :class="{ 'disabled': item.status !== '未预约' }">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
预约 预约
</button> </button>
<button class="action-button cancel-button" @click="confirmCancelConsultation(item)" :disabled="item.status === '已取消'" :class="{ 'disabled': item.status === '已取消' }">
<i class="el-icon-close"></i>
停诊
</button>
<button class="action-button check-in-button" @click="confirmCheckIn(item)" :disabled="item.status !== '已预约'" :class="{ 'disabled': item.status !== '已预约' }">
<i class="el-icon-circle-check"></i>
取号
</button>
</div> </div>
</div> </div>
<div v-if="hasMore" class="loading-more"> <div v-if="hasMore" class="loading-more">
@@ -166,7 +161,7 @@
<input id="phone" class="search-input" placeholder="手机号" v-model="patientSearchParams.phone" @input="onPatientSearchInput"> <input id="phone" class="search-input" placeholder="手机号" v-model="patientSearchParams.phone" @input="onPatientSearchInput">
<button id="patient-search-btn" class="search-btn" @click="searchPatients">查询</button> <button id="patient-search-btn" class="search-btn" @click="searchPatients">查询</button>
<div class="patient-table-container"> <div class="patient-table-container">
<table id="patient-table" class="patient-table"> <table id="patient-table" class="patient-table" v-if="patients.length > 0">
<thead> <thead>
<tr> <tr>
<th>序号</th> <th>序号</th>
@@ -192,6 +187,11 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<!-- 无搜索结果提示 -->
<div v-else-if="hasSearchCriteria && !isLoading" class="no-results">
未找到符合条件的患者请检查搜索条件
</div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@@ -231,13 +231,14 @@ import { listTicket, bookTicket, cancelTicket, checkInTicket, cancelConsultation
import { getPatientList } from '@/api/cardRenewal/api'; import { getPatientList } from '@/api/cardRenewal/api';
import { listDept } from '@/api/appoinmentmanage/dept'; import { listDept } from '@/api/appoinmentmanage/dept';
import { ref } from 'vue' import { ref } from 'vue'
import { ElDatePicker } from 'element-plus' import { ElDatePicker, ElPagination, ElMessageBox, ElMessage } from 'element-plus'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
export default { export default {
name: 'OutpatientAppointment', name: 'OutpatientAppointment',
components: { components: {
ElDatePicker ElDatePicker,
ElPagination
}, },
// 添加全局点击事件监听器,用于关闭右键菜单 // 添加全局点击事件监听器,用于关闭右键菜单
@@ -324,35 +325,34 @@ export default {
filteredTickets() { filteredTickets() {
let filtered = [...this.tickets]; let filtered = [...this.tickets];
// 按日期筛选(如果选择了日期) - 暂时注释掉以排查问题 //按日期筛选(如果选择了日期)
// if (this.selectedDate) { if (this.selectedDate) {
// filtered = filtered.filter(ticket => { filtered = filtered.filter(ticket => {
// // 使用后端返回的dateTime字段进行筛选 // 使用后端返回的dateTime字段进行筛选
// if (ticket.dateTime) { if (ticket.dateTime) {
// return ticket.dateTime.startsWith(this.selectedDate); return ticket.dateTime.startsWith(this.selectedDate);
// } }
// return true; return true;
// }); });
// } }
// 按状态筛选 - 暂时注释掉以排查问题 //按状态筛选
// if (this.selectedStatus !== 'all') { if (this.selectedStatus !== 'all') {
// // 状态映射表(后端返回中文状态,前端使用英文状态) // 状态映射表(后端返回中文状态,前端使用英文状态)
// const statusMap = { const statusMap = {
// 'unbooked': '未预约', 'unbooked': '未预约',
// 'locked': '已锁定', 'booked': '已预约',
// 'booked': '已预约', 'checked': '已取号',
// 'checked': '已取号', 'cancelled': '已停诊'
// 'cancelled': '已取消' };
// }; const chineseStatus = statusMap[this.selectedStatus];
// const chineseStatus = statusMap[this.selectedStatus]; filtered = filtered.filter(ticket => ticket.status === chineseStatus);
// filtered = filtered.filter(ticket => ticket.status === chineseStatus); }
// }
// 按科室筛选 - 暂时注释掉以排查问题 // 按科室筛选
// if (this.selectedDepartment !== 'all') { if (this.selectedDepartment !== 'all') {
// filtered = filtered.filter(ticket => ticket.department === this.selectedDepartment); filtered = filtered.filter(ticket => ticket.department === this.selectedDepartment);
// } }
// 按号源类型筛选 // 按号源类型筛选
filtered = filtered.filter(ticket => { filtered = filtered.filter(ticket => {
@@ -365,62 +365,67 @@ export default {
}); });
// 按医生筛选 - 暂时注释掉以排查问题 // 按医生筛选 - 暂时注释掉以排查问题
// if (this.selectedDoctorId) { if (this.selectedDoctorId) {
// const selectedDoctor = this.doctors.find(d => d.id === this.selectedDoctorId); const selectedDoctor = this.doctors.find(d => d.id === this.selectedDoctorId);
// if (selectedDoctor) { if (selectedDoctor) {
// filtered = filtered.filter(ticket => ticket.doctor === selectedDoctor.name); filtered = filtered.filter(ticket => ticket.doctor === selectedDoctor.name);
// } }
// } }
// 按患者信息筛选(姓名、就诊卡号、手机号) - 暂时注释掉以排查问题
// if (this.patientName || this.patientCard || this.patientPhone) {
// filtered = filtered.filter(ticket => {
// const matchesName = !this.patientName || ticket.patientName?.includes(this.patientName);
// const matchesCard = !this.patientCard || ticket.patientId?.includes(this.patientCard);
// const matchesPhone = !this.patientPhone || ticket.phone?.includes(this.patientPhone);
//
// return matchesName && matchesCard && matchesPhone;
// });
// }
return filtered; return filtered;
}, },
hasSearchCriteria() {
return Object.values(this.patientSearchParams).some(value => value && value.trim() !== '');
},
}, },
methods: { methods: {
selectDoctor(doctorId) { selectDoctor(doctorId) {
this.selectedDoctorId = doctorId this.selectedDoctorId = doctorId
console.log('Selected doctor:', doctorId)
// 医生选择后,筛选号源 // 医生选择后,筛选号源
this.onSearch(); this.onSearch();
}, },
onTypeChange() { onTypeChange() {
console.log('Type changed:', this.selectedType)
// 移除onSearch()调用,让计算属性自动处理类型筛选 // 移除onSearch()调用,让计算属性自动处理类型筛选
}, },
onDepartmentChange() { onDepartmentChange() {
console.log('Department changed:', this.selectedDepartment)
this.onSearch() this.onSearch()
}, },
onDoctorSearch() { onDoctorSearch() {
console.log('Searching doctor:', this.searchQuery)
// 使用计算属性filteredDoctors实现实时搜索无需调用API // 使用计算属性filteredDoctors实现实时搜索无需调用API
}, },
openPatientSelectModal(ticketId) { openPatientSelectModal(ticketId) {
console.log('openPatientSelectModal called with ticketId:', ticketId);
this.currentTicket = this.tickets.find(ticket => ticket.slot_id === ticketId); this.currentTicket = this.tickets.find(ticket => ticket.slot_id === ticketId);
console.log('Found ticket for modal:', this.currentTicket); // 重置搜索参数
// 打开患者选择弹窗时,查询患者列表 this.patientSearchParams = {
this.searchPatients(); patientName: '',
medicalCard: '',
idCard: '',
phone: ''
};
// 清空患者列表
this.patients = [];
this.showPatientModal = true; this.showPatientModal = true;
console.log('Show patient modal:', this.showPatientModal); // 默认加载所有患者
this.searchPatients();
}, },
// 患者搜索 // 患者搜索
searchPatients() { searchPatients() {
console.log('searchPatients called with params:', this.patientSearchParams); // 检查是否有搜索条件
const hasSearchCriteria = Object.values(this.patientSearchParams).some(value => value && value.trim() !== '');
// 设置加载状态
this.isLoading = true;
// 准备搜索参数,确保支持模糊匹配
const searchParams = {
patientName: this.patientSearchParams.patientName?.trim() || '',
medicalCard: this.patientSearchParams.medicalCard?.trim() || '',
idCard: this.patientSearchParams.idCard?.trim() || '',
phone: this.patientSearchParams.phone?.trim() || ''
};
// 调用真实API获取患者列表 // 调用真实API获取患者列表
getPatientList(this.patientSearchParams).then(response => { getPatientList(this.patientSearchParams).then(response => {
console.log('Patient API response:', response);
// 尝试不同的数据结构解析 // 尝试不同的数据结构解析
let records = []; let records = [];
if (response.data && response.data.records) { if (response.data && response.data.records) {
@@ -431,31 +436,40 @@ export default {
records = response; records = response;
} }
this.patients = records; this.patients = records;
console.log('Loaded patients:', this.patients); // 在前端进行额外的模糊匹配过滤以防后端API不支持完整的模糊匹配
if (hasSearchCriteria) {
this.patients = this.patients.filter(patient => {
const nameMatch = !searchParams.patientName ||
(patient.name && patient.name.toLowerCase().includes(searchParams.patientName.toLowerCase()));
const cardMatch = !searchParams.medicalCard ||
(patient.medicalCard && patient.medicalCard.toLowerCase().includes(searchParams.medicalCard.toLowerCase()));
const idMatch = !searchParams.idCard ||
(patient.idCard && patient.idCard.toLowerCase().includes(searchParams.idCard.toLowerCase()));
const phoneMatch = !searchParams.phone ||
(patient.phone && patient.phone.toLowerCase().includes(searchParams.phone.toLowerCase()));
return nameMatch && cardMatch && idMatch && phoneMatch;
});
}
// 验证每个患者是否有idCard字段如果没有尝试使用其他唯一标识 // 验证每个患者是否有idCard字段如果没有尝试使用其他唯一标识
this.patients.forEach((patient, index) => { this.patients.forEach((patient, index) => {
console.log(`Patient ${index}:`, patient);
console.log(`Patient ${index} has idCard:`, patient.idCard ? 'Yes' : 'No');
console.log(`Patient ${index} has id:`, patient.id ? 'Yes' : 'No');
console.log(`Patient ${index} has medicalCard:`, patient.medicalCard ? 'Yes' : 'No');
// 如果没有idCard尝试设置一个临时唯一标识 // 如果没有idCard尝试设置一个临时唯一标识
if (!patient.idCard) { if (!patient.idCard) {
patient.idCard = patient.id || patient.medicalCard || `temp_${index}`; patient.idCard = patient.id || patient.medicalCard || `temp_${index}`;
console.log(`Set temporary idCard for patient ${index}:`, patient.idCard);
} }
}); });
if (this.patients.length === 0) { if (this.patients.length === 0) {
console.log('No patients found in response'); ElMessage.error('没有找到患者数据,请检查搜索条件或联系管理员');
alert('没有找到患者数据,请检查搜索条件或联系管理员'); }
} // 清除加载状态
this.isLoading = false;
}).catch(error => { }).catch(error => {
console.error('获取患者列表失败:', error);
this.patients = []; this.patients = [];
alert('获取患者列表失败:' + (error.message || '未知错误')); ElMessage.error('获取患者列表失败:' + (error.message || '未知错误'));
// 清除加载状态
this.isLoading = false;
}); });
}, },
@@ -483,18 +497,12 @@ export default {
// 双击未预约卡片触发患者选择流程 // 双击未预约卡片触发患者选择流程
handleDoubleClick(ticket) { handleDoubleClick(ticket) {
console.log('handleDoubleClick called with ticket:', ticket);
if (ticket.status === '未预约') { if (ticket.status === '未预约') {
this.currentTicket = ticket; this.currentTicket = ticket;
console.log('Set currentTicket:', this.currentTicket);
this.selectedPatientId = null; this.selectedPatientId = null;
this.selectedPatient = null; this.selectedPatient = null;
console.log('Reset selected patient info:', { selectedPatientId: this.selectedPatientId, selectedPatient: this.selectedPatient });
// 先打开弹窗,再加载患者数据,避免等待 // 先打开弹窗,再加载患者数据,避免等待
this.showPatientModal = true; this.showPatientModal = true;
console.log('Show patient modal after double click:', this.showPatientModal);
// 调用患者搜索接口,加载患者列表 // 调用患者搜索接口,加载患者列表
this.searchPatients(); this.searchPatients();
} }
@@ -518,88 +526,66 @@ export default {
// 确认取消预约 // 确认取消预约
confirmCancelAppointment() { confirmCancelAppointment() {
if (this.selectedTicketForCancel) { if (this.selectedTicketForCancel) {
// 二次确认,显示患者姓名 // 使用 ElMessageBox.confirm 进行二次确认,显示患者姓名
if (confirm(`确认取消患者${this.selectedTicketForCancel.patientName || ''}的预约?`)) { ElMessageBox.confirm(
// 调用API取消预约 `确认取消患者${this.selectedTicketForCancel.patientName || ''}的预约?`,
'系统提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
// 用户点击确定调用API取消预约
this.cancelAppointment(this.selectedTicketForCancel); this.cancelAppointment(this.selectedTicketForCancel);
} }).catch(() => {
this.closeContextMenu(); // 用户取消操作
this.closeContextMenu();
});
} }
}, },
// 确认停诊
confirmCancelConsultation(ticket) {
// 二次确认
if (confirm(`确认取消${ticket.doctor}${ticket.dateTime}的看诊吗?`)) {
// 调用API处理停诊
this.cancelConsultation(ticket);
}
},
// 处理停诊
cancelConsultation(ticket) {
// 使用真实API调用处理停诊
cancelConsultation(ticket.slot_id).then(response => {
// API调用成功后重新获取最新的号源数据
this.onSearch();
alert('停诊已处理,该号源已被取消');
}).catch(error => {
console.error('停诊处理失败:', error);
alert('停诊处理失败,请稍后重试。');
});
},
// 确认取号
confirmCheckIn(ticket) {
// 二次确认
if (confirm(`确认${ticket.patientName || ''}取号吗?`)) {
// 调用API处理取号
this.checkIn(ticket);
}
},
// 处理取号
checkIn(ticket) {
// 使用真实API调用处理取号
checkInTicket(ticket.slot_id).then(response => {
// API调用成功后重新获取最新的号源数据
this.onSearch();
alert('取号成功!');
}).catch(error => {
console.error('取号失败:', error);
alert('取号失败,请稍后重试。');
});
},
// 取消预约API调用 // 取消预约API调用
cancelAppointment(ticket) { cancelAppointment(ticket) {
if (!ticket || !ticket.slot_id) { if (!ticket || !ticket.slot_id) {
console.error('取消预约失败:缺少号源信息'); ElMessage.error('取消预约失败:缺少号源信息');
alert('取消预约失败:缺少号源信息');
this.closeContextMenu(); this.closeContextMenu();
return; return;
} }
// 使用真实API调用取消预约 // 使用真实API调用取消预约传递slot_id
cancelTicket(ticket.slot_id).then(response => { cancelTicket(ticket.slot_id).then(response => {
// API调用成功后更新当前卡片状态 // 根据后端返回判断是否成功
const ticketIndex = this.tickets.findIndex(t => t.slot_id === ticket.slot_id); if (response.code === 200 || response.msg === '取消成功' || response.message === '取消成功') {
if (ticketIndex !== -1) { console.log('取消预约成功,更新前端状态');
// 清除该号源关联的所有患者信息
this.tickets[ticketIndex].status = '未预约'; // API调用成功后更新当前卡片状态
this.tickets[ticketIndex].patientName = null; const ticketIndex = this.tickets.findIndex(t => t.slot_id === ticket.slot_id);
this.tickets[ticketIndex].patientId = null; if (ticketIndex !== -1) {
this.tickets[ticketIndex].patientGender = null; // 清除该号源关联的所有患者信息
this.tickets[ticketIndex].medicalCard = null; this.tickets[ticketIndex].status = '未预约';
this.tickets[ticketIndex].phone = null; this.tickets[ticketIndex].patientName = null;
this.tickets[ticketIndex].patientId = null;
this.tickets[ticketIndex].patientGender = null;
this.tickets[ticketIndex].medicalCard = null;
this.tickets[ticketIndex].phone = null;
// 更新医生号源列表中的余号数量
this.updateDoctorsList();
}
// 关闭上下文菜单
this.closeContextMenu();
ElMessage.success('预约已取消,号源已释放');
} else {
// 取消失败
const errorMsg = response.msg || response.message || '取消预约失败';
ElMessage.error(`取消预约失败:${errorMsg}`);
this.closeContextMenu();
} }
// 关闭上下文菜单
this.closeContextMenu();
alert('预约已取消,号源已释放');
}).catch(error => { }).catch(error => {
console.error('取消预约失败:', error); const errorMsg = error.message || '取消预约失败,请稍后重试';
alert('取消预约失败,请稍后重试。'); ElMessage.error(`取消预约失败:${errorMsg}`);
this.closeContextMenu(); this.closeContextMenu();
}); });
}, },
@@ -608,63 +594,58 @@ export default {
this.selectedPatientId = null this.selectedPatientId = null
}, },
selectPatient(patientId) { selectPatient(patientId) {
console.log('selectPatient called with patientId:', patientId);
console.log('Current patients data:', this.patients);
console.log('Patients array length:', this.patients.length);
// 确保患者数据已加载 // 确保患者数据已加载
if (this.patients.length === 0) { if (this.patients.length === 0) {
console.error('No patients data available'); ElMessage.error('患者数据未加载,请先搜索患者');
alert('患者数据未加载,请先搜索患者');
return; return;
} }
this.selectedPatientId = patientId; this.selectedPatientId = patientId;
console.log('Set selectedPatientId:', this.selectedPatientId);
// 保存选择的患者对象 - 使用idCard作为唯一标识但增加容错性 // 保存选择的患者对象 - 使用idCard作为唯一标识但增加容错性
this.selectedPatient = this.patients.find(patient => { this.selectedPatient = this.patients.find(patient => {
// 尝试多种匹配方式 // 尝试多种匹配方式
const matchByIdCard = patient.idCard === patientId; const matchByIdCard = patient.idCard === patientId;
const matchById = patient.id === patientId; const matchById = patient.id === patientId;
const matchByMedicalCard = patient.medicalCard === patientId; const matchByMedicalCard = patient.medicalCard === patientId;
const match = matchByIdCard || matchById || matchByMedicalCard; const match = matchByIdCard || matchById || matchByMedicalCard;
console.log(`Checking patient ${patient.name || 'unknown'}:`);
console.log(` idCard: ${patient.idCard}, matchByIdCard: ${matchByIdCard}`);
console.log(` id: ${patient.id}, matchById: ${matchById}`);
console.log(` medicalCard: ${patient.medicalCard}, matchByMedicalCard: ${matchByMedicalCard}`);
console.log(` Overall match: ${match}`);
return match; return match;
}); });
console.log('Selected patient:', this.selectedPatient);
console.log('Selected patientId:', this.selectedPatientId);
if (this.selectedPatient) { if (this.selectedPatient) {
// 添加视觉反馈,验证患者是否被选中 // 使用 ElMessageBox.confirm 进行二次确认
alert('已选择患者: ' + this.selectedPatient.name); ElMessageBox.confirm(
`确认选择患者 ${this.selectedPatient.name} 进行预约?`,
// 可以考虑自动滚动到确认按钮,提高用户体验 '患者确认',
const confirmBtn = document.querySelector('.confirm-btn'); {
if (confirmBtn) { confirmButtonText: '确定',
confirmBtn.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); cancelButtonText: '取消',
} type: 'info'
}
).then(() => {
// 用户点击确定,自动滚动到确认按钮
ElMessage.success('已选择患者: ' + this.selectedPatient.name);
const confirmBtn = document.querySelector('.confirm-btn');
if (confirmBtn) {
confirmBtn.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
}).catch(() => {
// 用户取消选择,清空已选患者
this.selectedPatientId = null;
this.selectedPatient = null;
ElMessage.info('已取消患者选择');
});
} else { } else {
console.error('Patient not found with id:', patientId); ElMessage.error('未找到该患者,请重新选择');
alert('未找到该患者,请重新选择');
this.selectedPatientId = null; this.selectedPatientId = null;
} }
}, },
confirmPatientSelection() { confirmPatientSelection() {
if (!this.selectedPatientId || !this.selectedPatient) { if (!this.selectedPatientId || !this.selectedPatient) {
alert('请选择患者'); ElMessage.error('请选择患者');
return; return;
} }
if (!this.currentTicket) { if (!this.currentTicket) {
alert('预约信息错误,请重新选择号源'); ElMessage.error('预约信息错误,请重新选择号源');
this.closePatientSelectModal(); this.closePatientSelectModal();
return; return;
} }
@@ -672,6 +653,7 @@ export default {
try { try {
const userStore = useUserStore(); const userStore = useUserStore();
const appointmentData = { const appointmentData = {
slotId: this.currentTicket.slot_id, // 添加号源ID
ticketId: Number(this.currentTicket.slot_id), ticketId: Number(this.currentTicket.slot_id),
patientId: this.selectedPatientId, // 使用身份证号作为患者ID不需要转换为数字 patientId: this.selectedPatientId, // 使用身份证号作为患者ID不需要转换为数字
patientName: this.selectedPatient.name, patientName: this.selectedPatient.name,
@@ -685,39 +667,41 @@ export default {
// 验证必填字段 // 验证必填字段
if (!appointmentData.ticketId || isNaN(appointmentData.ticketId)) { if (!appointmentData.ticketId || isNaN(appointmentData.ticketId)) {
alert('号源ID无效'); ElMessage.error('号源ID无效');
return; return;
} }
if (!appointmentData.patientId) { if (!appointmentData.patientId) {
alert('患者ID无效'); ElMessage.error('患者ID无效');
return; return;
} }
// 调用真实API进行预约
console.log('Sending appointment data to backend:', appointmentData); bookTicket(appointmentData).then(response => {
bookTicket(appointmentData).then(response => {
const ticketIndex = this.tickets.findIndex(t => t.slot_id === this.currentTicket.slot_id); const ticketIndex = this.tickets.findIndex(t => t.slot_id === this.currentTicket.slot_id);
if (ticketIndex !== -1) { if (ticketIndex !== -1) {
this.tickets[ticketIndex].status = '已预约'; this.tickets[ticketIndex].status = '已预约';
this.tickets[ticketIndex].patientName = this.selectedPatient.name; this.tickets[ticketIndex].patientName = this.selectedPatient.name;
this.tickets[ticketIndex].patientId = this.selectedPatient.medicalCard; this.tickets[ticketIndex].patientId = this.selectedPatient.medicalCard;
this.tickets[ticketIndex].patientGender = this.selectedPatient.gender; this.tickets[ticketIndex].patientGender = this.selectedPatient.gender;
// 更新医生号源列表中的余号数量
this.updateDoctorsList();
} }
this.closePatientSelectModal(); this.closePatientSelectModal();
alert('预约成功,号源已锁定。患者到院签到时需缴费取号。');
// 重新加载号源数据,确保显示最新状态
this.onSearch();
ElMessage.success('预约成功,号源已锁定。患者到院签到时需缴费取号。');
}).catch(error => { }).catch(error => {
console.error('预约失败:', error); ElMessage.error('预约失败,请稍后重试。');
alert('预约失败,请稍后重试。');
}); });
} catch (error) { } catch (error) {
console.error('预约数据处理错误:', error); ElMessage.error('预约信息格式错误,请重新操作。');
alert('预约信息格式错误,请重新操作。');
} }
}, },
onDateChange() { onDateChange() {
// 日期变化时刷新号源列表
console.log('Date changed:', this.selectedDate)
// 重置页码并重新加载数据 // 重置页码并重新加载数据
this.currentPage = 1; this.currentPage = 1;
this.onSearch() this.onSearch()
@@ -731,16 +715,7 @@ export default {
this.isMobile = window.innerWidth <= 768; this.isMobile = window.innerWidth <= 768;
}, },
onSearch() { onSearch() {
this.isLoading = true this.isLoading = true
console.log('Searching with:', {
date: this.selectedDate,
status: this.selectedStatus,
type: this.selectedType,
name: this.patientName,
card: this.patientCard,
phone: this.patientPhone
});
// 调用真实API获取号源数据 // 调用真实API获取号源数据
const queryParams = { const queryParams = {
date: this.selectedDate, date: this.selectedDate,
@@ -749,7 +724,7 @@ export default {
name: this.patientName, name: this.patientName,
card: this.patientCard, card: this.patientCard,
phone: this.patientPhone, phone: this.patientPhone,
page: 1, page: this.currentPage,
limit: this.pageSize limit: this.pageSize
}; };
@@ -757,10 +732,7 @@ export default {
Promise.all([ Promise.all([
listAllTickets(), // 使用测试接口获取固定的5条专家号数据 listAllTickets(), // 使用测试接口获取固定的5条专家号数据
listDept() listDept()
]).then(([ticketResponse, deptResponse]) => { ]).then(([ticketResponse, deptResponse]) => {
// 打印完整的响应数据以便调试
console.log('完整的号源响应数据:', ticketResponse);
// 处理号源数据 // 处理号源数据
if (ticketResponse) { if (ticketResponse) {
// 检查是否有data.list字段后端返回的数据结构是{code, data:{list, total}} // 检查是否有data.list字段后端返回的数据结构是{code, data:{list, total}}
@@ -775,6 +747,10 @@ export default {
// 保存所有原始数据 // 保存所有原始数据
this.allTickets = [...this.tickets]; this.allTickets = [...this.tickets];
// 根据患者信息进行前端筛选
this.filterTicketsByPatientInfo();
// 更新医生列表 // 更新医生列表
this.updateDoctorsList(); this.updateDoctorsList();
this.hasMore = this.tickets.length < this.totalTickets; this.hasMore = this.tickets.length < this.totalTickets;
@@ -786,8 +762,7 @@ export default {
} }
// 处理科室数据 // 处理科室数据
this.updateDepartmentsListFromApi(deptResponse); this.updateDepartmentsListFromApi(deptResponse);
this.isLoading = false; this.isLoading = false;
}).catch(error => { }).catch(error => {
console.error('获取数据失败:', error); console.error('获取数据失败:', error);
@@ -798,9 +773,7 @@ export default {
this.departments = [{ value: 'all', label: '全部科室' }]; this.departments = [{ value: 'all', label: '全部科室' }];
this.isLoading = false; this.isLoading = false;
}); });
}, },
// 从号源数据中更新科室列表(备用方法) // 从号源数据中更新科室列表(备用方法)
updateDepartmentsList() { updateDepartmentsList() {
const departmentSet = new Set(); const departmentSet = new Set();
@@ -855,6 +828,25 @@ export default {
} }
}, },
// 根据患者信息过滤号源
filterTicketsByPatientInfo() {
// 如果没有输入患者信息,就不进行过滤
if (!this.patientName && !this.patientCard && !this.patientPhone) {
return;
}
// 根据患者信息进行过滤使用AND逻辑全部匹配
this.tickets = this.tickets.filter(ticket => {
const matchesName = !this.patientName || ticket.patientName?.includes(this.patientName);
const matchesCard = !this.patientCard || ticket.patientId?.includes(this.patientCard);
const matchesPhone = !this.patientPhone || ticket.phone?.includes(this.patientPhone);
return matchesName && matchesCard && matchesPhone;
});
console.log('按患者信息过滤后的号源数量:', this.tickets.length);
},
// 获取号源状态文本 // 获取号源状态文本
getStatusText(status) { getStatusText(status) {
switch (status) { switch (status) {
@@ -901,10 +893,7 @@ export default {
}); });
// 转换为数组 // 转换为数组
this.doctors = Array.from(doctorMap.values()); this.doctors = Array.from(doctorMap.values());
// 打印医生列表以便调试
console.log('生成的医生列表:', this.doctors);
}, },
// 加载更多数据 // 加载更多数据
loadMore() { loadMore() {
@@ -926,10 +915,7 @@ export default {
limit: this.pageSize limit: this.pageSize
}; };
listTicket(queryParams).then(response => { listTicket(queryParams).then(response => {
// 打印完整的响应数据以便调试
console.log('加载更多的号源响应数据:', response);
// 处理号源数据 // 处理号源数据
if (response) { if (response) {
let newRecords = []; let newRecords = [];
@@ -1461,6 +1447,15 @@ export default {
align-items: center; align-items: center;
} }
.ticket-index {
position: absolute;
top: 12px;
left: 12px;
color: #1890ff;
font-size: 14px;
font-weight: bold;
}
.ticket-time { .ticket-time {
font-size: 14px; font-size: 14px;
color: #333; color: #333;
@@ -1514,6 +1509,13 @@ export default {
white-space: nowrap; white-space: nowrap;
} }
.ticket-id-time {
font-size: 14px;
color: #333;
margin-bottom: 8px;
text-align: center;
}
.ticket-fee { .ticket-fee {
font-size: 14px; font-size: 14px;
color: #333; color: #333;
@@ -1547,50 +1549,6 @@ export default {
color: #91d5ff; color: #91d5ff;
cursor: not-allowed; cursor: not-allowed;
} }
.cancel-button {
background-color: #F56C6C;
color: white;
border: none;
border-radius: 4px;
padding: 4px 12px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
margin-top: 8px;
align-self: center;
}
.cancel-button:hover {
background-color: #F78989;
}
.cancel-button:disabled {
background-color: #C0C4CC;
cursor: not-allowed;
}
.check-in-button {
background-color: #67C23A;
color: white;
border: none;
border-radius: 4px;
padding: 4px 12px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
margin-top: 8px;
align-self: center;
}
.check-in-button:hover {
background-color: #85ce61;
}
.check-in-button:disabled {
background-color: #C0C4CC;
cursor: not-allowed;
}
/* 患者信息样式 */ /* 患者信息样式 */
.ticket-patient { .ticket-patient {
@@ -1603,6 +1561,18 @@ export default {
color: #333; color: #333;
} }
/* 患者电话号码样式 */
.ticket-phone {
margin-top: 4px;
padding: 4px;
background-color: rgba(34, 177, 76, 0.05);
border-radius: 4px;
font-size: 12px;
text-align: center;
color: #22b14c;
font-weight: 500;
}
/* 响应式设计 */ /* 响应式设计 */
@media (max-width: 768px) { @media (max-width: 768px) {
.ticket-grid { .ticket-grid {
@@ -1618,6 +1588,14 @@ export default {
.ticket-doctor { .ticket-doctor {
font-size: 13px; font-size: 13px;
} }
.ticket-id-time {
font-size: 13px;
}
.ticket-index {
font-size: 13px;
}
} }
/* 弹窗样式 */ /* 弹窗样式 */
@@ -1803,6 +1781,54 @@ export default {
box-shadow: none; box-shadow: none;
} }
/* 搜索提示样式 */
.search-hint {
text-align: center;
color: #999;
font-size: 14px;
padding: 20px;
background-color: #fafafa;
border-radius: 4px;
margin: 10px 0;
}
/* 加载指示器样式 */
.loading-indicator {
text-align: center;
color: #666;
font-size: 14px;
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}
.loading-spinner {
width: 16px;
height: 16px;
border: 2px solid #f3f3f3;
border-top: 2px solid #1890ff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.no-results {
text-align: center;
color: #666;
font-size: 14px;
padding: 20px;
background-color: #fff2f0;
border: 1px solid #ffccc7;
border-radius: 4px;
margin: 10px 0;
}
/* 右键菜单样式 */ /* 右键菜单样式 */
.context-menu { .context-menu {
position: fixed; position: fixed;
@@ -1842,4 +1868,60 @@ export default {
opacity: 0.7; opacity: 0.7;
cursor: not-allowed; cursor: not-allowed;
} }
/* 分页组件样式 */
.pagination-container {
display: flex;
justify-content: center;
margin-top: 20px;
padding: 20px 0;
background-color: #fafafa;
border-radius: 4px;
}
.pagination-container .el-pagination {
font-size: 14px;
}
.pagination-container .el-pagination .el-pager li {
min-width: 36px;
height: 36px;
line-height: 36px;
border-radius: 4px;
margin: 0 2px;
}
.pagination-container .el-pagination .el-pager li:hover {
background-color: #e6f7ff;
color: #1890ff;
}
.pagination-container .el-pagination .el-pager li.active {
background-color: #1890ff;
color: white;
}
.pagination-container .el-pagination .btn-prev,
.pagination-container .el-pagination .btn-next {
width: 36px;
height: 36px;
border-radius: 4px;
margin: 0 2px;
}
.pagination-container .el-pagination .el-pagination__sizes {
margin-right: 10px;
}
.pagination-container .el-pagination .el-pagination__sizes .el-input {
width: 100px;
}
.pagination-container .el-pagination .el-pagination__jump {
margin-left: 10px;
}
.pagination-container .el-pagination .el-pagination__jump .el-input {
width: 60px;
}
</style> </style>

File diff suppressed because it is too large Load Diff