fix(consultation): 限制会诊申请作废状态条件

修改会诊申请作废逻辑,仅允许新开和已提交状态可作废
前端界面同步调整作废按钮的禁用状态
后端增加状态校验防止非法操作
This commit is contained in:
wangjian963
2026-03-31 17:30:16 +08:00
parent bbef0322a3
commit ae9a96822e
3 changed files with 15 additions and 6 deletions

View File

@@ -465,7 +465,13 @@ public class ConsultationAppServiceImpl implements IConsultationAppService {
updateServiceRequestStatus(entity.getOrderId(), RequestStatus.DRAFT.getValue());
} else {
// 作废:状态改为"已取消"
// 作废:状态校验 - 已确认(20)、已签名(30)、已完成(40) 状态禁止作废
ConsultationStatusEnum currentStatus = ConsultationStatusEnum.getByCode(entity.getConsultationStatus());
if (currentStatus != null && !currentStatus.canCancel()) {
throw new IllegalArgumentException("当前状态【" + currentStatus.getDescription() + "】不允许作废,只有新开或已提交状态的会诊申请才能作废");
}
// 将状态改为"已取消"
entity.setConsultationStatus(CANCELLED.getCode());
entity.setCancelReason(cancelReason);
entity.setCancelNatureDate(new Date());

View File

@@ -76,10 +76,12 @@ public enum ConsultationStatusEnum {
}
/**
* 判断是否可以取消
* 判断是否可以取消/作废
* 只有新开(0)和已提交(10)状态可以作废
* 已确认(20)、已签名(30)、已完成(40)状态禁止作废
*/
public boolean canCancel() {
return this == NEW || this == SUBMITTED || this == CONFIRMED;
return this == NEW || this == SUBMITTED;
}
}