fix(prescription): 解决处方列表中价格显示的空值异常问题
- 在处方列表组件中添加对unitPrice和totalPrice的空值检查,防止NaN显示 - 优化价格计算逻辑,确保无效价格值被正确处理并显示为默认值 - 更新数据库查询中的条件判断,改进UNION查询的逻辑结构 - 添加对adviceTypes参数的有效性验证,确保查询条件的正确执行
This commit is contained in:
@@ -44,9 +44,9 @@
|
|||||||
abi.dosage_instruction,
|
abi.dosage_instruction,
|
||||||
abi.chrgitm_lv
|
abi.chrgitm_lv
|
||||||
FROM (
|
FROM (
|
||||||
<choose>
|
<!-- 确保至少有一个查询被执行以避免语法错误 -->
|
||||||
<when test="adviceTypes != null and !adviceTypes.isEmpty()">
|
<if test="adviceTypes != null and !adviceTypes.isEmpty() and (adviceTypes.contains(1) or adviceTypes.contains(2) or adviceTypes.contains(3))">
|
||||||
<trim prefixOverrides="UNION ALL">
|
<!-- 如果有有效的adviceTypes,则执行对应的查询 -->
|
||||||
<if test="adviceTypes.contains(1)">
|
<if test="adviceTypes.contains(1)">
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT ON (T1.ID)
|
DISTINCT ON (T1.ID)
|
||||||
@@ -113,10 +113,10 @@
|
|||||||
</if>
|
</if>
|
||||||
AND T5.instance_table = #{medicationTableName}
|
AND T5.instance_table = #{medicationTableName}
|
||||||
)
|
)
|
||||||
|
<if test="adviceTypes.contains(2) or adviceTypes.contains(3)">UNION ALL</if>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="adviceTypes.contains(2)">
|
<if test="adviceTypes.contains(2)">
|
||||||
UNION ALL
|
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT ON (T1.ID)
|
DISTINCT ON (T1.ID)
|
||||||
T1.tenant_id,
|
T1.tenant_id,
|
||||||
@@ -176,10 +176,10 @@
|
|||||||
AND T4.instance_table = #{deviceTableName}
|
AND T4.instance_table = #{deviceTableName}
|
||||||
AND T1.status_enum = #{statusEnum}
|
AND T1.status_enum = #{statusEnum}
|
||||||
)
|
)
|
||||||
|
<if test="adviceTypes.contains(3)">UNION ALL</if>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="adviceTypes.contains(3)">
|
<if test="adviceTypes.contains(3)">
|
||||||
UNION ALL
|
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT ON (T1.ID)
|
DISTINCT ON (T1.ID)
|
||||||
T1.tenant_id,
|
T1.tenant_id,
|
||||||
@@ -240,52 +240,51 @@
|
|||||||
AND T1.status_enum = #{statusEnum}
|
AND T1.status_enum = #{statusEnum}
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</if>
|
||||||
</when>
|
<!-- 如果没有有效的adviceTypes,提供一个空的默认查询以避免语法错误 -->
|
||||||
<otherwise>
|
<if test="adviceTypes == null or adviceTypes.isEmpty() or (!adviceTypes.contains(1) and !adviceTypes.contains(2) and !adviceTypes.contains(3))">
|
||||||
-- 当没有指定adviceTypes或adviceTypes为空时,返回空结果集但保持正确的SQL语法
|
|
||||||
SELECT
|
SELECT
|
||||||
NULL::varchar AS tenant_id,
|
mmd.tenant_id,
|
||||||
NULL::integer AS advice_type,
|
CAST(0 AS INTEGER) AS advice_type,
|
||||||
NULL::varchar AS bus_no,
|
CAST('' AS VARCHAR) AS bus_no,
|
||||||
NULL::varchar AS category_code,
|
CAST('' AS VARCHAR) AS category_code,
|
||||||
NULL::varchar AS pharmacology_category_code,
|
CAST('' AS VARCHAR) AS pharmacology_category_code,
|
||||||
NULL::numeric AS part_percent,
|
CAST(0 AS NUMERIC) AS part_percent,
|
||||||
NULL::numeric AS unit_conversion_ratio,
|
CAST(0 AS NUMERIC) AS unit_conversion_ratio,
|
||||||
NULL::integer AS part_attribute_enum,
|
CAST(0 AS INTEGER) AS part_attribute_enum,
|
||||||
NULL::integer AS tho_part_attribute_enum,
|
CAST(0 AS INTEGER) AS tho_part_attribute_enum,
|
||||||
NULL::integer AS skin_test_flag,
|
CAST(0 AS INTEGER) AS skin_test_flag,
|
||||||
NULL::integer AS inject_flag,
|
CAST(0 AS INTEGER) AS inject_flag,
|
||||||
NULL::bigint AS advice_definition_id,
|
CAST(0 AS BIGINT) AS advice_definition_id,
|
||||||
NULL::varchar AS advice_name,
|
CAST('' AS VARCHAR) AS advice_name,
|
||||||
NULL::varchar AS advice_bus_no,
|
CAST('' AS VARCHAR) AS advice_bus_no,
|
||||||
NULL::varchar AS py_str,
|
CAST('' AS VARCHAR) AS py_str,
|
||||||
NULL::varchar AS wb_str,
|
CAST('' AS VARCHAR) AS wb_str,
|
||||||
NULL::varchar AS yb_no,
|
CAST('' AS VARCHAR) AS yb_no,
|
||||||
NULL::varchar AS product_name,
|
CAST('' AS VARCHAR) AS product_name,
|
||||||
NULL::integer AS activity_type,
|
CAST(0 AS INTEGER) AS activity_type,
|
||||||
NULL::varchar AS unit_code,
|
CAST('' AS VARCHAR) AS unit_code,
|
||||||
NULL::varchar AS min_unit_code,
|
CAST('' AS VARCHAR) AS min_unit_code,
|
||||||
NULL::numeric AS volume,
|
CAST(0 AS NUMERIC) AS volume,
|
||||||
NULL::varchar AS method_code,
|
CAST('' AS VARCHAR) AS method_code,
|
||||||
NULL::varchar AS rate_code,
|
CAST('' AS VARCHAR) AS rate_code,
|
||||||
NULL::bigint AS org_id,
|
CAST(0 AS BIGINT) AS org_id,
|
||||||
NULL::bigint AS location_id,
|
CAST(0 AS BIGINT) AS location_id,
|
||||||
NULL::varchar AS dose,
|
CAST('' AS VARCHAR) AS dose,
|
||||||
NULL::varchar AS dose_unit_code,
|
CAST('' AS VARCHAR) AS dose_unit_code,
|
||||||
NULL::varchar AS supplier,
|
CAST('' AS VARCHAR) AS supplier,
|
||||||
NULL::bigint AS supplier_id,
|
CAST(0 AS BIGINT) AS supplier_id,
|
||||||
NULL::varchar AS manufacturer,
|
CAST('' AS VARCHAR) AS manufacturer,
|
||||||
NULL::bigint AS charge_item_definition_id,
|
CAST(0 AS BIGINT) AS charge_item_definition_id,
|
||||||
NULL::varchar AS advice_table_name,
|
CAST('' AS VARCHAR) AS advice_table_name,
|
||||||
NULL::bigint AS position_id,
|
CAST(0 AS BIGINT) AS position_id,
|
||||||
NULL::integer AS restricted_flag,
|
CAST(0 AS INTEGER) AS restricted_flag,
|
||||||
NULL::varchar AS restricted_scope,
|
CAST('' AS VARCHAR) AS restricted_scope,
|
||||||
NULL::varchar AS dosage_instruction,
|
CAST('' AS VARCHAR) AS dosage_instruction,
|
||||||
NULL::integer AS chrgitm_lv
|
CAST(0 AS INTEGER) AS chrgitm_lv
|
||||||
WHERE 1 = 0 -- 确保不返回任何行
|
FROM med_medication_definition mmd
|
||||||
</otherwise>
|
WHERE 1 = 0 -- 仍然确保不返回任何行,但使用真实表确保类型正确
|
||||||
</choose>
|
</if>
|
||||||
) AS abi
|
) AS abi
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -215,9 +215,19 @@ getList();
|
|||||||
// 从priceList列表中获取价格
|
// 从priceList列表中获取价格
|
||||||
function getPriceFromInventory(row) {
|
function getPriceFromInventory(row) {
|
||||||
if (row.priceList && row.priceList.length > 0) {
|
if (row.priceList && row.priceList.length > 0) {
|
||||||
const price = row.priceList[0].price || 0;
|
const price = row.priceList[0].price;
|
||||||
|
// 检查价格是否为有效数字
|
||||||
|
if (price !== undefined && price !== null && !isNaN(price) && isFinite(price)) {
|
||||||
return Number(price).toFixed(2) + ' 元';
|
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 '-';
|
return '-';
|
||||||
}
|
}
|
||||||
function getList() {
|
function getList() {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
' ' +
|
' ' +
|
||||||
scope.row.volume +
|
scope.row.volume +
|
||||||
' [' +
|
' [' +
|
||||||
Number(scope.row.unitPrice).toFixed(2) +
|
(scope.row.unitPrice !== undefined && scope.row.unitPrice !== null && !isNaN(scope.row.unitPrice) && isFinite(scope.row.unitPrice) ? Number(scope.row.unitPrice).toFixed(2) : '-') +
|
||||||
' 元' +
|
' 元' +
|
||||||
'/' +
|
'/' +
|
||||||
scope.row.unitCode_dictText +
|
scope.row.unitCode_dictText +
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
<span class="medicine-info"> 注射药品:{{ scope.row.injectFlag_enumText }} </span>
|
<span class="medicine-info"> 注射药品:{{ scope.row.injectFlag_enumText }} </span>
|
||||||
<span class="total-amount">
|
<span class="total-amount">
|
||||||
总金额:{{
|
总金额:{{
|
||||||
scope.row.totalPrice
|
(scope.row.totalPrice !== undefined && scope.row.totalPrice !== null && !isNaN(scope.row.totalPrice) && isFinite(scope.row.totalPrice))
|
||||||
? Number(scope.row.totalPrice).toFixed(2) + ' 元'
|
? Number(scope.row.totalPrice).toFixed(2) + ' 元'
|
||||||
: '0.00 元'
|
: '0.00 元'
|
||||||
}}
|
}}
|
||||||
@@ -631,7 +631,7 @@
|
|||||||
" " +
|
" " +
|
||||||
scope.row.volume +
|
scope.row.volume +
|
||||||
" [" +
|
" [" +
|
||||||
Number(scope.row.unitPrice).toFixed(2) +
|
(scope.row.unitPrice !== undefined && scope.row.unitPrice !== null && !isNaN(scope.row.unitPrice) && isFinite(scope.row.unitPrice) ? Number(scope.row.unitPrice).toFixed(2) : '-') +
|
||||||
" 元" +
|
" 元" +
|
||||||
"/" +
|
"/" +
|
||||||
scope.row.unitCode_dictText +
|
scope.row.unitCode_dictText +
|
||||||
@@ -687,7 +687,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<span class="total-amount">
|
<span class="total-amount">
|
||||||
总金额:{{
|
总金额:{{
|
||||||
scope.row.totalPrice
|
(scope.row.totalPrice !== undefined && scope.row.totalPrice !== null && !isNaN(scope.row.totalPrice) && isFinite(scope.row.totalPrice))
|
||||||
? Number(scope.row.totalPrice).toFixed(2) + ' 元'
|
? Number(scope.row.totalPrice).toFixed(2) + ' 元'
|
||||||
: '0.00 元'
|
: '0.00 元'
|
||||||
}}
|
}}
|
||||||
@@ -702,7 +702,7 @@
|
|||||||
<span style="font-size: 16px; font-weight: 600">
|
<span style="font-size: 16px; font-weight: 600">
|
||||||
{{ scope.row.adviceName }}
|
{{ scope.row.adviceName }}
|
||||||
{{
|
{{
|
||||||
scope.row.unitPrice
|
(scope.row.unitPrice !== undefined && scope.row.unitPrice !== null && !isNaN(scope.row.unitPrice) && isFinite(scope.row.unitPrice))
|
||||||
? Number(scope.row.unitPrice).toFixed(2) + '/次'
|
? Number(scope.row.unitPrice).toFixed(2) + '/次'
|
||||||
: '-' + '元'
|
: '-' + '元'
|
||||||
}}
|
}}
|
||||||
@@ -748,7 +748,7 @@
|
|||||||
<span class="total-amount">
|
<span class="total-amount">
|
||||||
总金额:
|
总金额:
|
||||||
{{
|
{{
|
||||||
scope.row.totalPrice
|
(scope.row.totalPrice !== undefined && scope.row.totalPrice !== null && !isNaN(scope.row.totalPrice) && isFinite(scope.row.totalPrice))
|
||||||
? Number(scope.row.totalPrice).toFixed(2) + ' 元'
|
? Number(scope.row.totalPrice).toFixed(2) + ' 元'
|
||||||
: '0.00 元'
|
: '0.00 元'
|
||||||
}}
|
}}
|
||||||
@@ -907,7 +907,7 @@
|
|||||||
<el-table-column label="总金额" align="right" prop="" header-align="center" width="100">
|
<el-table-column label="总金额" align="right" prop="" header-align="center" width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span v-if="!scope.row.isEdit" style="text-align: right">
|
<span v-if="!scope.row.isEdit" style="text-align: right">
|
||||||
{{ scope.row.totalPrice ? Number(scope.row.totalPrice).toFixed(2) + ' 元' : '-' }}
|
{{ (scope.row.totalPrice !== undefined && scope.row.totalPrice !== null && !isNaN(scope.row.totalPrice) && isFinite(scope.row.totalPrice)) ? Number(scope.row.totalPrice).toFixed(2) + ' 元' : '-' }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -2852,12 +2852,25 @@ function getGroupMarkers() {
|
|||||||
function calculateTotalPrice(row, index) {
|
function calculateTotalPrice(row, index) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (row.adviceType == 3) {
|
if (row.adviceType == 3) {
|
||||||
|
// 检查价格是否为有效数字
|
||||||
|
if (row.unitPrice !== undefined && row.unitPrice !== null && !isNaN(row.unitPrice) && isFinite(row.unitPrice)) {
|
||||||
row.totalPrice = (row.unitPrice * row.quantity).toFixed(6);
|
row.totalPrice = (row.unitPrice * row.quantity).toFixed(6);
|
||||||
|
} else {
|
||||||
|
row.totalPrice = '0.000000'; // 或者设置为 0
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (row.unitCode == row.minUnitCode) {
|
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(6);
|
row.totalPrice = (row.minUnitPrice * row.quantity).toFixed(6);
|
||||||
} else {
|
} else {
|
||||||
|
row.totalPrice = '0.000000';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (row.unitPrice !== undefined && row.unitPrice !== null && !isNaN(row.unitPrice) && isFinite(row.unitPrice)) {
|
||||||
row.totalPrice = (row.unitPrice * row.quantity).toFixed(6);
|
row.totalPrice = (row.unitPrice * row.quantity).toFixed(6);
|
||||||
|
} else {
|
||||||
|
row.totalPrice = '0.000000';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user