From e330372355d806e6b1add5572780687c994a9771 Mon Sep 17 00:00:00 2001 From: yangkexiang <1677036288@qq.com> Date: Mon, 18 May 2026 11:03:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug525:[=E6=89=8B=E6=9C=AF=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E9=97=A8=E8=AF=8A=E6=89=8B=E6=9C=AF=E5=AE=89?= =?UTF-8?q?=E6=8E=92-=E8=AE=A1=E8=B4=B9]=20=E5=B7=B2=E5=8B=BE=E9=80=89?= =?UTF-8?q?=E2=80=9C=E5=BE=85=E7=AD=BE=E5=8F=91=E2=80=9D=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=B8=94=E6=9C=AA=E6=94=B6=E8=B4=B9=EF=BC=8C=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E2=80=9C=E5=88=A0=E9=99=A4=E2=80=9D=E6=8F=90=E7=A4=BA=E2=80=9C?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E5=88=A0=E9=99=A4=E5=BE=85=E7=AD=BE=E5=8F=91?= =?UTF-8?q?=E4=B8=94=E6=9C=AA=E6=94=B6=E8=B4=B9=E7=9A=84=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bargain/component/prescriptionlist.vue | 157 +++++++++++------- 1 file changed, 98 insertions(+), 59 deletions(-) diff --git a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue index 865efff9b..90d2a9ce3 100755 --- a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue @@ -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(); } }