diff --git a/openhis-ui-vue3/src/views/surgicalschedule/index.vue b/openhis-ui-vue3/src/views/surgicalschedule/index.vue index 34e3c05fc..42849fd75 100755 --- a/openhis-ui-vue3/src/views/surgicalschedule/index.vue +++ b/openhis-ui-vue3/src/views/surgicalschedule/index.vue @@ -1741,27 +1741,39 @@ function handleTemporaryMedicalSubmit(data) { } }) - // 🔧 修复 Bug #445: 使用稳定的字段组合匹配已提交项目,而不是依赖可能为空的 requestId/chargeItemId - // 构建已提交项目的匹配键集合(药品名称 + 规格 + 数量) - 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') // 过滤掉空项 - ) + // 🔧 修复 Bug #445: 使用稳定可靠的字段组合匹配已提交项目,从已生成列表中剔除待生成项 + // 匹配键:优先使用 chargeItemId(后端费用项目ID,最可靠),其次使用 名称+规格+数量 组合 + const submittedKeys = new Set() + const submittedChargeIds = new Set() - 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 => { - 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) }) } else { - // 如果没有任何匹配键,清空待生成列表(所有项目都已提交) + // 如果没有任何匹配标识,清空待生成列表(保守策略:认为所有项目都已提交) temporaryBillingMedicines.value = [] }