From 27ef41ece472b3b7ffda5f39a26408996f3580d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=80=E5=BD=A7?= <荀彧@gentronhealth.com> Date: Tue, 12 May 2026 23:34:29 +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() 中同步零售价的条件只检查了第一个子项 (treatmentItems.value[0]),当第一个子项被清空但其他子项有效时,零售价不会同步。submitForm() 中存在相同问题。 修复内容: 1. calculateTotalPrice(): 使用 Array.some() 检查是否有任何有效子项,而非只检查第一个 2. 当无有效子项时,将 retailPrice 重置为 undefined 避免残留旧值 3. submitForm(): childrenJson 序列化和零售价同步同样改用 some() 检查 4. addItem(): 补充缺失的 name 字段,与初始值结构保持一致 Co-Authored-By: Claude Opus 4.7 --- .../components/diagnosisTreatmentDialog.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 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 3bd2b641..89a8768f 100755 --- a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue +++ b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue @@ -475,8 +475,13 @@ function calculateTotalPrice() { }); totalPrice.value = sum.toFixed(2); // Bug #464: 零售价与诊疗子项合计总价实时同步 - if (treatmentItems.value.length > 0 && treatmentItems.value[0].adviceDefinitionId !== '') { + const hasValidItem = treatmentItems.value.some( + (item) => item.adviceDefinitionId && item.adviceDefinitionId !== '' + ); + if (hasValidItem) { form.value.retailPrice = parseFloat(totalPrice.value); + } else { + form.value.retailPrice = undefined; } } catch (error) { totalPrice.value = '0.00'; @@ -486,7 +491,7 @@ function calculateTotalPrice() { // 添加表单项 function addItem() { - treatmentItems.value.push({ adviceDefinitionId: '', childrenRequestNum: 1, retailPrice: 0 }); + treatmentItems.value.push({ adviceDefinitionId: '', childrenRequestNum: 1, name: '', retailPrice: 0 }); // 使用nextTick确保DOM更新后再计算 nextTick(() => { calculateTotalPrice(); @@ -647,12 +652,15 @@ async function submitForm() { form.value.ybMatchFlag ? (form.value.ybMatchFlag = 1) : (form.value.ybMatchFlag = 0); form.value.ruleId ? (form.value.ruleId = 1) : (form.value.ruleId = 0); form.value.childrenJson = - treatmentItems.value.length > 0 && treatmentItems.value[0].adviceDefinitionId != '' + treatmentItems.value.some((item) => item.adviceDefinitionId != '' && item.adviceDefinitionId) ? JSON.stringify(treatmentItems.value) : undefined; // Bug #464 修复:零售价自动与诊疗子项合计总价同步 // 当有子项时,零售价自动设置为子项合计总价 - if (treatmentItems.value.length > 0 && treatmentItems.value[0].adviceDefinitionId != '') { + const hasValidItem = treatmentItems.value.some( + (item) => item.adviceDefinitionId && item.adviceDefinitionId !== '' + ); + if (hasValidItem) { form.value.retailPrice = parseFloat(totalPrice.value) || 0; } proxy.$refs['diagnosisTreatmentRef'].validate(async (valid) => {