Fix Bug #445: 【手术管理-门诊手术安排】临时医嘱生成界面逻辑错误:已生成医嘱的计费项目未从"待生成"列表中剔除
根因:提交成功后,父组件使用 requestId/chargeItemId 匹配已提交项目来过滤 待生成列表,但这些字段在新建医嘱时往往为空,导致匹配失败,已生成的项目 仍保留在"待生成"列表中。 修复: 1. handleTemporaryMedicalSubmit: 改用稳定的字段组合(药品名称+规格+数量) 匹配已提交项目,从 temporaryBillingMedicines 中移除 2. handleMedicalAdvice: 首次打开弹窗时过滤掉已有 requestId 的项目 3. handleQuoteBilling: 引用计费/刷新时同样过滤掉已有 requestId 的项目 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1552,6 +1552,8 @@ function handleMedicalAdvice(row) {
|
|||||||
// 过滤掉名称为空的项目
|
// 过滤掉名称为空的项目
|
||||||
const medicineName = item.adviceName || item.advice_name;
|
const medicineName = item.adviceName || item.advice_name;
|
||||||
if (!medicineName || medicineName.trim() === '') return false;
|
if (!medicineName || medicineName.trim() === '') return false;
|
||||||
|
// 🔧 修复 Bug #445: 过滤掉已生成医嘱的项目(已有 requestId 的不应出现在"待生成"列表)
|
||||||
|
if (item.requestId) return false;
|
||||||
// 根据药品请求ID去重,避免重复显示
|
// 根据药品请求ID去重,避免重复显示
|
||||||
const itemId = item.requestId || item.id;
|
const itemId = item.requestId || item.id;
|
||||||
if (itemId && seenIds.has(itemId)) return false;
|
if (itemId && seenIds.has(itemId)) return false;
|
||||||
@@ -1739,15 +1741,27 @@ function handleTemporaryMedicalSubmit(data) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 同步更新计费药品列表:移除已生成医嘱的项目,避免数据重复显示
|
// 🔧 修复 Bug #445: 使用稳定的字段组合匹配已提交项目,而不是依赖可能为空的 requestId/chargeItemId
|
||||||
const submittedIds = new Set(
|
// 构建已提交项目的匹配键集合(药品名称 + 规格 + 数量)
|
||||||
(data.temporaryAdvices || []).map(a => a.originalMedicine?.requestId || a.originalMedicine?.chargeItemId).filter(Boolean)
|
const submittedKeys = new Set(
|
||||||
|
(data.temporaryAdvices || [])
|
||||||
|
.map(a => {
|
||||||
|
const om = a.originalMedicine || {}
|
||||||
|
const name = om.medicineName || om.adviceName || om.advice_name || a.adviceName || ''
|
||||||
|
const spec = om.specification || om.volume || ''
|
||||||
|
const qty = om.quantity || 0
|
||||||
|
return `${name}|||${spec}|||${qty}`
|
||||||
|
})
|
||||||
|
.filter(k => k !== '|||0') // 过滤掉空项
|
||||||
)
|
)
|
||||||
if (submittedIds.size > 0) {
|
|
||||||
temporaryBillingMedicines.value = (data.billingMedicines || []).filter(
|
if (submittedKeys.size > 0) {
|
||||||
m => !submittedIds.has(m.requestId || m.chargeItemId)
|
temporaryBillingMedicines.value = (temporaryBillingMedicines.value || []).filter(m => {
|
||||||
)
|
const key = `${m.medicineName || ''}|||${m.specification || ''}|||${m.quantity || 0}`
|
||||||
|
return !submittedKeys.has(key)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
|
// 如果没有任何匹配键,清空待生成列表(所有项目都已提交)
|
||||||
temporaryBillingMedicines.value = []
|
temporaryBillingMedicines.value = []
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1807,7 +1821,8 @@ function handleQuoteBilling() {
|
|||||||
temporaryBillingMedicines.value = []
|
temporaryBillingMedicines.value = []
|
||||||
temporaryAdvices.value = []
|
temporaryAdvices.value = []
|
||||||
|
|
||||||
// 只保留药品类型(adviceType=1),过滤掉耗材(2)和诊疗项目(3)
|
// 🔧 修复 Bug #445: 只保留药品类型(adviceType=1),过滤掉耗材(2)和诊疗项目(3)
|
||||||
|
// 同时过滤掉已有 requestId 的项目(已生成医嘱的不需要再次显示在"待生成"列表中)
|
||||||
const filteredItems = res.data.filter(item => {
|
const filteredItems = res.data.filter(item => {
|
||||||
// 匹配 encounterId
|
// 匹配 encounterId
|
||||||
if (item.encounterId !== temporaryPatientInfo.value.visitId) return false;
|
if (item.encounterId !== temporaryPatientInfo.value.visitId) return false;
|
||||||
@@ -1815,7 +1830,10 @@ function handleQuoteBilling() {
|
|||||||
if (item.adviceType !== 1) return false;
|
if (item.adviceType !== 1) return false;
|
||||||
// 过滤掉名称为空的项目
|
// 过滤掉名称为空的项目
|
||||||
const medicineName = item.adviceName || item.advice_name;
|
const medicineName = item.adviceName || item.advice_name;
|
||||||
return medicineName && medicineName.trim() !== '';
|
if (!medicineName || medicineName.trim() === '') return false;
|
||||||
|
// 🔧 修复 Bug #445: 过滤掉已生成医嘱的项目(已有 requestId)
|
||||||
|
if (item.requestId) return false;
|
||||||
|
return true;
|
||||||
})
|
})
|
||||||
// 🔧 修复:限制返回数量,最多显示前100条,避免数据过多导致页面卡死
|
// 🔧 修复:限制返回数量,最多显示前100条,避免数据过多导致页面卡死
|
||||||
const maxItems = 100
|
const maxItems = 100
|
||||||
|
|||||||
Reference in New Issue
Block a user