Fix Bug #445: 门诊手术安排-已生成医嘱的计费项目未从待生成列表剔除
根因:submit后本地过滤逻辑中submittedKeys的字段名不匹配 - originalMedicine中的名称字段是adviceName而非medicineName,导致 名称+规格+数量的匹配键无法正确匹配已提交项 - 修复:增加chargeItemId作为首选匹配标识(后端唯一ID最可靠), 名称匹配增加adviceName字段兜底 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1741,27 +1741,39 @@ function handleTemporaryMedicalSubmit(data) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 🔧 修复 Bug #445: 使用稳定的字段组合匹配已提交项目,而不是依赖可能为空的 requestId/chargeItemId
|
// 🔧 修复 Bug #445: 使用稳定可靠的字段组合匹配已提交项目,从已生成列表中剔除待生成项
|
||||||
// 构建已提交项目的匹配键集合(药品名称 + 规格 + 数量)
|
// 匹配键:优先使用 chargeItemId(后端费用项目ID,最可靠),其次使用 名称+规格+数量 组合
|
||||||
const submittedKeys = new Set(
|
const submittedKeys = new Set()
|
||||||
(data.temporaryAdvices || [])
|
const submittedChargeIds = new Set()
|
||||||
.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 (submittedKeys.size > 0) {
|
;(data.temporaryAdvices || []).forEach(a => {
|
||||||
|
const om = a.originalMedicine || {}
|
||||||
|
// 收集 chargeItemId(最可靠的匹配标识)
|
||||||
|
if (om.chargeItemId) {
|
||||||
|
submittedChargeIds.add(om.chargeItemId)
|
||||||
|
}
|
||||||
|
// 构建名称+规格+数量的匹配键(用于无 chargeItemId 的兜底匹配)
|
||||||
|
// 注意:originalMedicine 中的名称字段是 adviceName(来自 billingMedicines.map 时的字段)
|
||||||
|
const name = om.medicineName || om.adviceName || om.advice_name || a.adviceName || ''
|
||||||
|
const spec = om.specification || om.volume || ''
|
||||||
|
const qty = om.quantity || 0
|
||||||
|
if (name) {
|
||||||
|
submittedKeys.add(`${name}|||${spec}|||${qty}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (submittedChargeIds.size > 0 || submittedKeys.size > 0) {
|
||||||
temporaryBillingMedicines.value = (temporaryBillingMedicines.value || []).filter(m => {
|
temporaryBillingMedicines.value = (temporaryBillingMedicines.value || []).filter(m => {
|
||||||
const key = `${m.medicineName || ''}|||${m.specification || ''}|||${m.quantity || 0}`
|
// 优先用 chargeItemId 匹配
|
||||||
|
if (m.chargeItemId && submittedChargeIds.has(m.chargeItemId)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// 兜底用 名称+规格+数量 匹配
|
||||||
|
const key = `${m.medicineName || m.adviceName || ''}|||${m.specification || m.volume || ''}|||${m.quantity || 0}`
|
||||||
return !submittedKeys.has(key)
|
return !submittedKeys.has(key)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// 如果没有任何匹配键,清空待生成列表(所有项目都已提交)
|
// 如果没有任何匹配标识,清空待生成列表(保守策略:认为所有项目都已提交)
|
||||||
temporaryBillingMedicines.value = []
|
temporaryBillingMedicines.value = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user