Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
wangjian963
2026-05-18 11:09:24 +08:00
6 changed files with 180 additions and 59 deletions

32
BUG_522_ANALYSIS.md Normal file
View File

@@ -0,0 +1,32 @@
# Bug #522 分析报告
## Bug 描述
[住院护士站-三测单] 体征录入点击保存后缺乏执行反馈且窗口异常自动关闭
## 涉及文件
- 前端: `openhis-ui-vue3/src/views/inpatientNurse/tprChart/components/addTprDialog.vue`
- API: `openhis-ui-vue3/src/views/inpatientNurse/tprChart/components/api.js`
- 父组件: `openhis-ui-vue3/src/views/inpatientNurse/tprChart/index.vue`
## 根因分析
### 问题1弹窗异常自动关闭 — 根因
`addTprDialog.vue` 模板中,保存按钮使用了 `:disabled="buttonDisabled"`第50行和第108行**`buttonDisabled` 变量在整个 script setup 中从未声明**。
在 Vue 3 `<script setup>` + Composition API 中,模板引用的变量必须在 script 中声明。未声明的变量会触发 `ReferenceError`,导致组件渲染失败或运行时异常。这个错误会破坏组件的响应式系统,使得 `dialogVisible` 的响应式绑定失效,从而导致弹窗在保存操作后异常关闭。
### 问题2缺乏保存成功反馈 — 连带结果
虽然 `confirmCharge()` 函数在第1087行已有 `proxy.$modal.msgSuccess('保存成功')` 的调用,但由于 `buttonDisabled` 未声明引发的异常导致代码执行路径被破坏success 回调中的提示逻辑可能未能正常执行。
## 修复方案
1. **在 `addTprDialog.vue` 的 script setup 中新增 `buttonDisabled` ref 声明**,初始值为 `false`
2. **在保存操作中添加 loading 状态**点击保存后将按钮禁用API 返回后恢复,防止重复提交的同时也保证了响应式状态的一致性
## 验收标准
- [ ] 点击保存后弹窗保持开启状态
- [ ] 保存成功后弹出"保存成功"提示
- [ ] 左侧体征历史记录列表自动刷新
- [ ] 录入区域表单被清空,方便继续录入下一条

View File

@@ -507,6 +507,7 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<?> deleteSurgery(Long id) {
// 校验手术是否存在
Surgery existSurgery = surgeryService.getById(id);
@@ -519,6 +520,28 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
return R.fail("已完成的手术不能删除");
}
// 级联删除关联数据
String surgeryNo = existSurgery.getSurgeryNo();
// 1. 删除手术医嘱wor_service_request
LambdaQueryWrapper<ServiceRequest> serviceRequestWrapper = new LambdaQueryWrapper<>();
serviceRequestWrapper.eq(ServiceRequest::getActivityId, id);
serviceRequestService.remove(serviceRequestWrapper);
log.info("删除手术关联的医嘱 - surgeryId: {}, surgeryNo: {}", id, surgeryNo);
// 2. 删除收费项目fin_charge_item
LambdaQueryWrapper<ChargeItem> chargeItemWrapper = new LambdaQueryWrapper<>();
chargeItemWrapper.eq(ChargeItem::getProductId, id)
.eq(ChargeItem::getProductTable, "cli_surgery");
chargeItemService.remove(chargeItemWrapper);
log.info("删除手术关联的收费项目 - surgeryId: {}, surgeryNo: {}", id, surgeryNo);
// 3. 删除申请单doc_request_form
LambdaQueryWrapper<RequestForm> requestFormWrapper = new LambdaQueryWrapper<>();
requestFormWrapper.eq(RequestForm::getPrescriptionNo, surgeryNo);
requestFormService.remove(requestFormWrapper);
log.info("删除手术关联的申请单 - surgeryId: {}, surgeryNo: {}", id, surgeryNo);
surgeryService.deleteSurgery(id);
// 清除相关缓存

View File

@@ -873,6 +873,32 @@ function ensureOrgTreeLoaded() {
});
}
/** 待签发且未收费chargeStatus=5 为已收费) */
function isPendingUnsignedAndUnpaid(item) {
return item.statusEnum == 1 && item.chargeStatus != 5
}
/**
* 门诊划价仅允许操作本人开立bizRequestFlag==1 或空)。
* 手术计费:列表接口需按库中 generate_source_enum 查询(当前多为 1故子组件仍传 generateSourceEnum=1
* 通过 patientInfo.generateSourceEnum===6手术计费在 chargePatientInfo 中已写入)识别场景,删除时不卡 bizRequestFlag。
*/
function isSurgeryChargeBillingContext() {
const fromPatient = props.patientInfo?.generateSourceEnum
return fromPatient != null && Number(fromPatient) === 6
}
function isBizRequestAllowedForDelete(item) {
if (isSurgeryChargeBillingContext()) {
return true
}
const src = props.generateSourceEnum != null ? Number(props.generateSourceEnum) : NaN
if (src === 6) {
return true
}
return Number(item.bizRequestFlag) === 1 || !item.bizRequestFlag
}
function handleDelete() {
// 🔧 修复:使用 groupIndexList 而不是 check 属性
// 因为 watch 监听器会在数据更新时重置 check 为 false
@@ -881,80 +907,93 @@ function handleDelete() {
return;
}
let deleteList = groupIndexList.value.map((index) => {
const item = prescriptionList.value[index];
// 只删除待签发且未收费的项目
if (item.statusEnum != 1 || item.chargeStatus == 5) {
return null;
}
// 🔧 Bug #442: 非本人创建的医嘱不允许删除(与签发/签退逻辑保持一致)
if (Number(item.bizRequestFlag) !== 1 && item.bizRequestFlag) {
return null;
}
// 🔧 Bug #442: 已保存的行必须有有效的 requestId否则跳过避免后端删除不存在的记录
if (item.requestId == null || item.requestId === undefined || item.requestId === '') {
return null;
}
return {
requestId: item.requestId,
dbOpType: '3',
adviceType: item.adviceType,
};
}).filter(item => item !== null); // 过滤掉已签发、已收费、非本人创建或无 requestId 的项目
if (deleteList.length == 0) {
proxy.$modal.msgWarning('只能删除待签发且未收费的项目');
return;
const canDeleteRow = (item) =>
isPendingUnsignedAndUnpaid(item) && isBizRequestAllowedForDelete(item)
const anySelectedDeletable = groupIndexList.value.some((index) =>
canDeleteRow(prescriptionList.value[index])
)
if (!anySelectedDeletable) {
proxy.$modal.msgWarning(
'只能删除「待签发」且「未收费」的项目;门诊划价还需为本人开立。已签发、已收费或非本人开立项不可删。'
)
return
}
let deleteList = groupIndexList.value
.map((index) => {
const item = prescriptionList.value[index]
if (!canDeleteRow(item)) {
return null
}
if (item.requestId == null || item.requestId === undefined || item.requestId === '') {
return null
}
return {
requestId: item.requestId,
dbOpType: '3',
adviceType: item.adviceType,
}
})
.filter((item) => item !== null)
// 删除逻辑:按索引从大到小排序,避免删除后索引变化
const sortedIndexes = groupIndexList.value.sort((a, b) => b - a);
let hasSavedItem = false;
const sortedIndexes = [...groupIndexList.value].sort((a, b) => b - a)
let hasSavedItem = false
for (const index of sortedIndexes) {
const item = prescriptionList.value[index];
if (item.statusEnum != 1) {
continue; // 跳过已签发的项目
const item = prescriptionList.value[index]
if (!canDeleteRow(item)) {
continue
}
if (!item.requestId) {
// 新增的行(未保存到数据库),直接删除
prescriptionList.value.splice(index, 1);
prescriptionList.value.splice(index, 1)
} else {
hasSavedItem = true;
hasSavedItem = true
}
}
if (hasSavedItem) {
// 🔧 Bug #454: 删除前弹出确认提示,告知用户将级联删除关联检验申请单
const hasLabItem = deleteList.some(item => item.adviceType === 3);
const confirmMsg = hasLabItem
? '删除此医嘱将同时删除关联的检验申请单,是否确认删除?'
: '确认删除选中的医嘱项目吗?';
proxy.$modal.confirm(confirmMsg).then(() => {
savePrescription({ adviceSaveList: deleteList }).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess('操作成功');
getListInfo(false);
expandOrder.value = [];
groupIndexList.value = [];
groupList.value = [];
isAdding.value = false;
adviceQueryParams.value.adviceType = undefined;
}
});
}).catch(() => {
// 用户取消删除
});
} else {
// 只有新增行,已经在前端删除完成
proxy.$modal.msgSuccess('操作成功');
const cleanupAfterDelete = () => {
expandOrder.value = [];
groupIndexList.value = [];
groupList.value = [];
isAdding.value = false;
adviceQueryParams.value.adviceType = undefined;
};
if (hasSavedItem) {
if (deleteList.length === 0) {
proxy.$modal.msgWarning('没有可提交删除的已保存医嘱,请刷新后重试');
getListInfo(false);
cleanupAfterDelete();
return;
}
// Bug #454: 删除前确认;检验医嘱提示级联删除申请单
const hasLabItem = deleteList.some((item) => item.adviceType === 3);
const confirmMsg = hasLabItem
? '删除此医嘱将同时删除关联的检验申请单,是否确认删除?'
: '确认删除选中的医嘱项目吗?';
proxy.$modal
.confirm(confirmMsg)
.then(() => {
savePrescription({ adviceSaveList: deleteList }).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess('操作成功');
getListInfo(false);
cleanupAfterDelete();
}
});
})
.catch(() => {
// 用户取消删除
});
} else {
proxy.$modal.msgSuccess('操作成功');
cleanupAfterDelete();
}
}

View File

@@ -856,6 +856,7 @@ function handleDelete(row) {
}).then(() => {
getList()
proxy.$modal.msgSuccess('删除成功')
emit('saved') // 通知父组件刷新医嘱列表
}).catch(error => {
console.error('删除手术失败:', error)
proxy.$modal.msgError('删除失败')
@@ -867,6 +868,7 @@ function handleDelete(row) {
}).then(() => {
getList()
proxy.$modal.msgSuccess('手术已取消')
emit('saved') // 通知父组件刷新医嘱列表
}).catch(error => {
console.error('取消手术失败:', error)
proxy.$modal.msgError('取消失败')

View File

@@ -380,6 +380,28 @@ watch(
},
{ immediate: true }
);
// 编辑模式下applicationListAll 加载完成后重新回显已选项目
watch(
() => applicationListAll.value,
() => {
if (!props.editData?.requestFormId) return;
if (!props.editData.requestFormDetailList?.length) return;
if (!applicationListAll.value.length) return;
const selectedIds = [];
props.editData.requestFormDetailList.forEach((detail) => {
const matched = applicationListAll.value.find(
(item) => item.adviceName === detail.adviceName
);
if (matched) {
selectedIds.push(matched.adviceDefinitionId);
}
});
transferValue.value = selectedIds;
}
);
const submit = () => {
if (transferValue.value.length == 0) {
return proxy.$message.error('请选择申请单');

View File

@@ -777,6 +777,9 @@ const InputOptions = ref([
// 日期范围 - 体征信息搜索时间
const receptionTime = ref(null);
// 按钮禁用状态(保存按钮依赖)
const buttonDisabled = ref(false);
// 表单数据 - 体征录入
const formData = ref({
recordingDate: '',