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) => {