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 });