fix: 修复门诊划价新增收费项目总金额未自动计算的问题 (BUG #216)
问题原因: - prescriptionlist.vue 文件中引用了 calculateTotalPrice 函数但未定义 - 选择收费项目后未设置默认数量,也未触发总金额计算 修复内容: 1. 添加 calculateTotalPrice 函数,根据单价×数量自动计算总金额 2. 选择诊疗项目后自动设置默认执行次数为1并计算总金额 3. 选择耗材项目后自动设置默认数量为1并计算总金额 验证: - 构建成功,无编译错误
This commit is contained in:
@@ -567,6 +567,9 @@ function selectAdviceBase(key, row) {
|
|||||||
prescriptionList.value[rowIndex.value].locationId = stock.locationId;
|
prescriptionList.value[rowIndex.value].locationId = stock.locationId;
|
||||||
prescriptionList.value[rowIndex.value].unitPrice = stock.price;
|
prescriptionList.value[rowIndex.value].unitPrice = stock.price;
|
||||||
prescriptionList.value[rowIndex.value].positionName = stock.locationName;
|
prescriptionList.value[rowIndex.value].positionName = stock.locationName;
|
||||||
|
// 设置默认数量为1,并计算总金额
|
||||||
|
prescriptionList.value[rowIndex.value].quantity = 1;
|
||||||
|
calculateTotalPrice(prescriptionList.value[rowIndex.value], rowIndex.value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 诊疗:设置执行科室和价格
|
// 诊疗:设置执行科室和价格
|
||||||
@@ -576,6 +579,9 @@ function selectAdviceBase(key, row) {
|
|||||||
} else {
|
} else {
|
||||||
prescriptionList.value[rowIndex.value].unitPrice = 0;
|
prescriptionList.value[rowIndex.value].unitPrice = 0;
|
||||||
}
|
}
|
||||||
|
// 设置默认执行次数为1,并计算总金额
|
||||||
|
prescriptionList.value[rowIndex.value].quantity = 1;
|
||||||
|
calculateTotalPrice(prescriptionList.value[rowIndex.value], rowIndex.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
expandOrder.value = [key];
|
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 });
|
defineExpose({ getListInfo });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user