fix(prescription): 解决处方列表中价格显示的空值异常问题

- 在处方列表组件中添加对unitPrice和totalPrice的空值检查,防止NaN显示
- 优化价格计算逻辑,确保无效价格值被正确处理并显示为默认值
- 更新数据库查询中的条件判断,改进UNION查询的逻辑结构
- 添加对adviceTypes参数的有效性验证,确保查询条件的正确执行
This commit is contained in:
2026-01-15 15:13:09 +08:00
parent 8f1ad3307c
commit db1139a14f
3 changed files with 274 additions and 252 deletions

View File

@@ -215,8 +215,18 @@ getList();
// 从priceList列表中获取价格
function getPriceFromInventory(row) {
if (row.priceList && row.priceList.length > 0) {
const price = row.priceList[0].price || 0;
return Number(price).toFixed(2) + ' 元';
const price = row.priceList[0].price;
// 检查价格是否为有效数字
if (price !== undefined && price !== null && !isNaN(price) && isFinite(price)) {
return Number(price).toFixed(2) + ' 元';
}
// 如果价格无效,尝试从其他可能的字段获取价格
if (row.totalPrice !== undefined && row.totalPrice !== null && !isNaN(row.totalPrice) && isFinite(row.totalPrice)) {
return Number(row.totalPrice).toFixed(2) + ' 元';
}
if (row.price !== undefined && row.price !== null && !isNaN(row.price) && isFinite(row.price)) {
return Number(row.price).toFixed(2) + ' 元';
}
}
return '-';
}