fix(charge): 修复收费模块中的数值计算和空指针异常问题

- 修复金额计算精度问题,使用Number转换和toFixed(2)确保数值准确性
- 添加安全访问操作符(?.)避免空指针异常导致页面崩溃
- 修复数组过滤和查找操作的空值处理逻辑
- 优化错误消息显示,提供更友好的用户提示
- 修复模板文件路径引用问题,确保打印功能正常工作
- 统一金额计算逻辑,避免因数据类型不一致导致的计算错误
This commit is contained in:
2026-01-13 17:30:17 +08:00
parent 0f013715b8
commit f5f4e3c48e
10 changed files with 719 additions and 43 deletions

View File

@@ -287,7 +287,7 @@ function getPatientList() {
queryParams.value.receptionTimeETime = undefined;
}
getList(queryParams.value).then((res) => {
patientList.value = res.data.data.records;
patientList.value = res.data?.data?.records || [];
});
}
@@ -363,17 +363,17 @@ function confirmCharge() {
encounterId: patientInfo.value.encounterId,
chargeItemIds: chargeItemIdList.value,
}).then((res) => {
if (res.code == 200) {
if (res.code == 200 && res.data) {
// totalAmount.value = res.data.psnCashPay;
paymentId.value = res.data.paymentId;
chrgBchnoList.value = res.data.chrgBchnoList;
totalAmount.value = res.data.details.find((item) => item.payEnum == 220000).amount;
details.value = res.data.details.filter((item) => {
totalAmount.value = res.data.details?.find((item) => item.payEnum == 220000)?.amount ?? 0;
details.value = res.data.details?.filter((item) => {
return item.amount > 0;
});
}) || [];
openDialog.value = true;
} else {
proxy.$modal.msgError(res.msg);
proxy.$modal.msgError(res?.msg || '预结算失败');
}
});
// console.log(patientInfo)
@@ -517,11 +517,11 @@ async function handleReadCard(value) {
ybMdtrtCertType: userCardInfo.psnCertType,
busiCardInfo: userCardInfo.busiCardInfo,
}).then((res) => {
if (res.code == 200) {
if (res.code == 200 && res.data) {
// totalAmount.value = res.data.psnCashPay;
paymentId.value = res.data.paymentId;
totalAmount.value = res.data.details.find((item) => item.payEnum == 220000).amount;
details.value = res.data.details;
totalAmount.value = res.data.details?.find((item) => item.payEnum == 220000)?.amount ?? 0;
details.value = res.data.details || [];
// chrgBchnoList.value = res.data.chrgBchnoList;
chargeItemIdList.value = selectRows.map((item) => {
return item.id;
@@ -537,7 +537,7 @@ async function handleReadCard(value) {
});
openDialog.value = true;
} else {
proxy.$modal.msgError(res.msg);
proxy.$modal.msgError(res?.msg || '预结算失败');
}
});
}
@@ -648,9 +648,9 @@ function printCharge(row) {
getChargeInfo({ paymentId: row.paymentId }).then((res) => {
// 设置实收金额
if (res.data && res.data.detail) {
const amountDetail = res.data.detail.find((item) => item.payEnum == 220000);
const amountDetail = res.data.detail?.find((item) => item.payEnum == 220000);
if (amountDetail) {
totalAmount.value = amountDetail.amount;
totalAmount.value = amountDetail.amount || 0;
// 为合并的行设置金额相关字段值
rows.forEach((item) => {