fix(consultation): 限制会诊申请作废状态条件
修改会诊申请作废逻辑,仅允许新开和已提交状态可作废 前端界面同步调整作废按钮的禁用状态 后端增加状态校验防止非法操作
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
size="small"
|
||||
:icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
:disabled="scope.row.consultationStatus >= STATUS.ENDED"
|
||||
:disabled="scope.row.consultationStatus >= STATUS.CONFIRMED"
|
||||
title="作废"
|
||||
/>
|
||||
</template>
|
||||
@@ -666,8 +666,9 @@ const handleSave = async () => {
|
||||
}
|
||||
|
||||
const handleDelete = async (row) => {
|
||||
if (row.consultationStatus >= STATUS.ENDED) {
|
||||
ElMessage.warning('已结束的会诊申请不可作废')
|
||||
// 已确认(20)、已签名(30)、已完成(40) 状态禁止作废
|
||||
if (row.consultationStatus >= STATUS.CONFIRMED) {
|
||||
ElMessage.warning('已确认/已签名状态的会诊申请不可作废')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user