From 9b1ac64cd6c8b20d11e2c9d5c725485a34b5e041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=BA=91?= <赵云@gentronhealth.com> Date: Thu, 14 May 2026 13:03:25 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#464:=20[=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E8=AF=8A=E7=96=97=E7=9B=AE=E5=BD=95]=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A1=B9=E7=9B=AE=E6=97=B6"=E9=9B=B6?= =?UTF-8?q?=E5=94=AE=E4=BB=B7"=E6=9C=AA=E4=B8=8E"=E8=AF=8A=E7=96=97?= =?UTF-8?q?=E5=AD=90=E9=A1=B9"=E5=90=88=E8=AE=A1=E6=80=BB=E4=BB=B7?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:calculateTotalPrice中form.value.retailPrice赋值被nextTick包裹, 在多调用方(watcher/selectRow/addItem)并发时产生竞态,导致零售价更新丢失 修复:移除nextTick,改为同步赋值确保零售价实时同步总价 Co-Authored-By: Claude Opus 4.7 --- .../components/diagnosisTreatmentDialog.vue | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue index f24b2d348..9c06b4241 100755 --- a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue +++ b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue @@ -473,15 +473,12 @@ function calculateTotalPrice() { } }); totalPrice.value = sum.toFixed(2); - // Bug #464: 零售价与诊疗子项合计总价实时同步 + // Bug #464: 零售价与诊疗子项合计总价实时同步,直接赋值不使用nextTick避免多调用方竞争 const hasValidItem = treatmentItems.value.some( (item) => item.adviceDefinitionId && item.adviceDefinitionId !== '' ); if (hasValidItem) { - // 使用 nextTick 确保总价更新后零售价才更新,避免 Vue 响应式时序问题 - nextTick(() => { - form.value.retailPrice = parseFloat(totalPrice.value) || 0; - }); + form.value.retailPrice = parseFloat(totalPrice.value) || 0; } else { form.value.retailPrice = undefined; } @@ -763,10 +760,7 @@ function selectRow(row, index) { treatmentItems.value[index].adviceDefinitionId = row.id; treatmentItems.value[index].retailPrice = row.retailPrice || 0; medicineSearchKey.value = ''; - // 使用 nextTick 确保 DOM 更新后再计算总价 - nextTick(() => { - calculateTotalPrice(); - }); + calculateTotalPrice(); } // 清空诊疗子项