From b4e13e1305a8fa1bdea072df3ef6f3409feb5c88 Mon Sep 17 00:00:00 2001 From: chenqi Date: Wed, 18 Mar 2026 15:01:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=97=A8=E8=AF=8A?= =?UTF-8?q?=E5=88=92=E4=BB=B7=E6=96=B0=E5=A2=9E=E6=94=B6=E8=B4=B9=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=80=BB=E9=87=91=E9=A2=9D=E6=9C=AA=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=9A=84=E9=97=AE=E9=A2=98=20(BUG=20#216)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题原因: - prescriptionlist.vue 文件中引用了 calculateTotalPrice 函数但未定义 - 选择收费项目后未设置默认数量,也未触发总金额计算 修复内容: 1. 添加 calculateTotalPrice 函数,根据单价×数量自动计算总金额 2. 选择诊疗项目后自动设置默认执行次数为1并计算总金额 3. 选择耗材项目后自动设置默认数量为1并计算总金额 验证: - 构建成功,无编译错误 --- .../bargain/component/prescriptionlist.vue | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue index 22e30cec..bffdacba 100644 --- a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue @@ -567,6 +567,9 @@ function selectAdviceBase(key, row) { prescriptionList.value[rowIndex.value].locationId = stock.locationId; prescriptionList.value[rowIndex.value].unitPrice = stock.price; prescriptionList.value[rowIndex.value].positionName = stock.locationName; + // 设置默认数量为1,并计算总金额 + prescriptionList.value[rowIndex.value].quantity = 1; + calculateTotalPrice(prescriptionList.value[rowIndex.value], rowIndex.value); } } else { // 诊疗:设置执行科室和价格 @@ -576,6 +579,9 @@ function selectAdviceBase(key, row) { } else { prescriptionList.value[rowIndex.value].unitPrice = 0; } + // 设置默认执行次数为1,并计算总金额 + prescriptionList.value[rowIndex.value].quantity = 1; + calculateTotalPrice(prescriptionList.value[rowIndex.value], rowIndex.value); } expandOrder.value = [key]; @@ -804,6 +810,37 @@ function handleSingOut() { } }); } + +// 计算总价 +function calculateTotalPrice(row, index) { + nextTick(() => { + // 对于诊疗(adviceType=3)和耗材(adviceType=2),使用unitPrice * quantity计算总价 + if (row.adviceType == 3 || row.adviceType == 2) { + // 检查价格是否为有效数字 + if (row.unitPrice !== undefined && row.unitPrice !== null && !isNaN(row.unitPrice) && isFinite(row.unitPrice)) { + row.totalPrice = (row.unitPrice * row.quantity).toFixed(2); + } else { + row.totalPrice = '0.00'; + } + } else { + // 其他类型(如药品) + if (row.unitCode == row.minUnitCode) { + if (row.minUnitPrice !== undefined && row.minUnitPrice !== null && !isNaN(row.minUnitPrice) && isFinite(row.minUnitPrice)) { + row.totalPrice = (row.minUnitPrice * row.quantity).toFixed(2); + } else { + row.totalPrice = '0.00'; + } + } else { + if (row.unitPrice !== undefined && row.unitPrice !== null && !isNaN(row.unitPrice) && isFinite(row.unitPrice)) { + row.totalPrice = (row.unitPrice * row.quantity).toFixed(2); + } else { + row.totalPrice = '0.00'; + } + } + } + }); +} + defineExpose({ getListInfo });