11 Commits

Author SHA1 Message Date
6d85686b06 测试合并v14 2026-01-15 17:06:32 +08:00
b33cb6f9a1 测试合并v13 2026-01-15 17:04:46 +08:00
072e71b025 测试合并v12 2026-01-15 16:58:14 +08:00
47394de43c Merge pull request 'document' (#2) from document into develop
Reviewed-on: #2
2026-01-15 07:37:39 +00:00
f0f1dde6b6 测试合并 2026-01-15 07:37:39 +00:00
1ab1165697 测试合并 2026-01-15 07:37:39 +00:00
a8f1b1fdfa feat(doctorstation): 添加医嘱类型对应的药品分类筛选功能
- 在处方列表组件中根据医嘱类型自动设置categoryCode筛选条件
- 为西药类型设置categoryCode为'2'
- 为中成药类型设置categoryCode为'1'
- 为耗材和诊疗类型清空categoryCode筛选条件
- 更新基础医嘱列表组件以接收并应用categoryCode查询参数
- 实现医嘱类型改变时的联动筛选逻辑
2026-01-15 15:34:34 +08:00
3b94d19199 Merge remote-tracking branch 'origin/develop' into develop 2026-01-15 15:13:20 +08:00
db1139a14f fix(prescription): 解决处方列表中价格显示的空值异常问题
- 在处方列表组件中添加对unitPrice和totalPrice的空值检查,防止NaN显示
- 优化价格计算逻辑,确保无效价格值被正确处理并显示为默认值
- 更新数据库查询中的条件判断,改进UNION查询的逻辑结构
- 添加对adviceTypes参数的有效性验证,确保查询条件的正确执行
2026-01-15 15:13:09 +08:00
chenjinyang
bea74aeac2 使用element-plus进行提示替换HTML原生弹窗 2026-01-15 15:01:05 +08:00
chenjinyang
634a1f45f9 根据LIS分组开发手册完成功能 2026-01-15 14:36:54 +08:00
8 changed files with 605 additions and 621 deletions

10
md/test.html Normal file
View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试合并11112</title>
</head>
<body>
</body>
</html>

View File

@@ -4,7 +4,7 @@ import com.core.common.core.domain.R;
import com.openhis.check.domain.LisGroupInfo; import com.openhis.check.domain.LisGroupInfo;
public interface ILisGroupInfoAppService { public interface ILisGroupInfoAppService {
R<?> getLisGroupInfoList(); R<?> getLisGroupInfoList(Integer pageNum, Integer pageSize);
R<?> add(LisGroupInfo lisGroupInfo); R<?> add(LisGroupInfo lisGroupInfo);

View File

@@ -1,6 +1,7 @@
package com.openhis.web.check.appservice.impl; package com.openhis.web.check.appservice.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R; import com.core.common.core.domain.R;
import com.openhis.check.domain.LisGroupInfo; import com.openhis.check.domain.LisGroupInfo;
import com.openhis.check.service.ILisGroupInfoService; import com.openhis.check.service.ILisGroupInfoService;
@@ -17,11 +18,14 @@ public class LisGroupInfoAppServiceImpl implements ILisGroupInfoAppService {
@Resource @Resource
private ILisGroupInfoService lisGroupInfoService; private ILisGroupInfoService lisGroupInfoService;
@Override @Override
public R<?> getLisGroupInfoList() { public R<?> getLisGroupInfoList(Integer pageNum, Integer pageSize) {
List<LisGroupInfo> list = lisGroupInfoService.list(); Page<LisGroupInfo> page = new Page<>(pageNum, pageSize);
Page<LisGroupInfo> list = lisGroupInfoService.page(page);
return R.ok(list); return R.ok(list);
} }
@Override @Override
public R<?> add(LisGroupInfo lisGroupInfo) { public R<?> add(LisGroupInfo lisGroupInfo) {
if (ObjectUtil.isEmpty(lisGroupInfo)) { if (ObjectUtil.isEmpty(lisGroupInfo)) {

View File

@@ -19,8 +19,8 @@ public class LisGroupInfoController {
* *
* */ * */
@GetMapping("/list") @GetMapping("/list")
public R<?> getLisGroupInfoList(){ public R<?> getLisGroupInfoList(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
return R.ok(lisGroupInfoAppService.getLisGroupInfoList()); return R.ok(lisGroupInfoAppService.getLisGroupInfoList(pageNum, pageSize));
} }
/* /*

View File

@@ -44,248 +44,247 @@
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)
T1.tenant_id, T1.tenant_id,
1 AS advice_type, 1 AS advice_type,
T1.bus_no AS bus_no, T1.bus_no AS bus_no,
T1.category_code AS category_code, T1.category_code AS category_code,
T1.pharmacology_category_code AS pharmacology_category_code, T1.pharmacology_category_code AS pharmacology_category_code,
T1.part_percent AS part_percent, T1.part_percent AS part_percent,
T1.unit_conversion_ratio AS unit_conversion_ratio, T1.unit_conversion_ratio AS unit_conversion_ratio,
T1.part_attribute_enum AS part_attribute_enum, T1.part_attribute_enum AS part_attribute_enum,
T1.tho_part_attribute_enum AS tho_part_attribute_enum, T1.tho_part_attribute_enum AS tho_part_attribute_enum,
T1.skin_test_flag AS skin_test_flag, T1.skin_test_flag AS skin_test_flag,
T1.inject_flag AS inject_flag, T1.inject_flag AS inject_flag,
T1.ID AS advice_definition_id, T1.ID AS advice_definition_id,
T1.NAME AS advice_name, T1.NAME AS advice_name,
T1.bus_no AS advice_bus_no, T1.bus_no AS advice_bus_no,
T1.py_str AS py_str, T1.py_str AS py_str,
T1.wb_str AS wb_str, T1.wb_str AS wb_str,
T1.yb_no AS yb_no, T1.yb_no AS yb_no,
T1.merchandise_name AS product_name, T1.merchandise_name AS product_name,
0 AS activity_type, 0 AS activity_type,
T1.unit_code AS unit_code, T1.unit_code AS unit_code,
T1.min_unit_code AS min_unit_code, T1.min_unit_code AS min_unit_code,
T2.total_volume AS volume, T2.total_volume AS volume,
T2.method_code AS method_code, T2.method_code AS method_code,
T2.rate_code AS rate_code, T2.rate_code AS rate_code,
T2.org_id AS org_id, T2.org_id AS org_id,
T2.location_id AS location_id, T2.location_id AS location_id,
CAST(T2.dose AS TEXT) AS dose, CAST(T2.dose AS TEXT) AS dose,
T2.dose_unit_code AS dose_unit_code, T2.dose_unit_code AS dose_unit_code,
T3.NAME AS supplier, T3.NAME AS supplier,
T3.id AS supplier_id, T3.id AS supplier_id,
T1.manufacturer_text AS manufacturer, T1.manufacturer_text AS manufacturer,
T5.id AS charge_item_definition_id, T5.id AS charge_item_definition_id,
T5.instance_table AS advice_table_name, T5.instance_table AS advice_table_name,
T6.def_location_id AS position_id, T6.def_location_id AS position_id,
t1.restricted_flag AS restricted_flag, t1.restricted_flag AS restricted_flag,
t1.restricted_scope AS restricted_scope, t1.restricted_scope AS restricted_scope,
T1.dosage_instruction AS dosage_instruction, T1.dosage_instruction AS dosage_instruction,
T1.chrgitm_lv as chrgitm_lv T1.chrgitm_lv as chrgitm_lv
FROM med_medication_definition AS t1 FROM med_medication_definition AS t1
INNER JOIN med_medication AS T2 ON T2.medication_def_id = T1.ID INNER JOIN med_medication AS T2 ON T2.medication_def_id = T1.ID
AND T2.delete_flag = '0' AND T2.status_enum = #{statusEnum} AND T2.delete_flag = '0' AND T2.status_enum = #{statusEnum}
LEFT JOIN adm_supplier AS T3 LEFT JOIN adm_supplier AS T3
ON T3.ID = T1.supply_id ON T3.ID = T1.supply_id
AND T3.delete_flag = '0' AND T3.delete_flag = '0'
LEFT JOIN adm_charge_item_definition AS T5 ON T5.instance_id = T1.ID LEFT JOIN adm_charge_item_definition AS T5 ON T5.instance_id = T1.ID
AND T5.delete_flag = '0' AND T5.status_enum = #{statusEnum} AND T5.delete_flag = '0' AND T5.status_enum = #{statusEnum}
LEFT JOIN adm_organization_location AS T6 LEFT JOIN adm_organization_location AS T6
ON T6.distribution_category_code = T1.category_code ON T6.distribution_category_code = T1.category_code
AND T6.delete_flag = '0' AND T6.item_code = '1' AND T6.organization_id = #{organizationId} AND AND T6.delete_flag = '0' AND T6.item_code = '1' AND T6.organization_id = #{organizationId} AND
(CURRENT_TIME :: time (6) BETWEEN T6.start_time AND T6.end_time) (CURRENT_TIME :: time (6) BETWEEN T6.start_time AND T6.end_time)
WHERE T1.delete_flag = '0' WHERE T1.delete_flag = '0'
AND T2.status_enum = #{statusEnum} AND T2.status_enum = #{statusEnum}
<if test="pricingFlag ==1"> <if test="pricingFlag ==1">
AND 1 = 2 AND 1 = 2
</if> </if>
<if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()"> <if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()">
AND T1.id IN AND T1.id IN
<foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")"> <foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")">
#{itemId} #{itemId}
</foreach> </foreach>
</if> </if>
AND T5.instance_table = #{medicationTableName} AND T5.instance_table = #{medicationTableName}
) )
</if> <if test="adviceTypes.contains(2) or adviceTypes.contains(3)">UNION ALL</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, 2 AS advice_type,
2 AS advice_type, T1.bus_no AS bus_no,
T1.bus_no AS bus_no, T1.category_code AS category_code,
T1.category_code AS category_code, '' AS pharmacology_category_code,
'' AS pharmacology_category_code, T1.part_percent AS part_percent,
T1.part_percent AS part_percent, 0 AS unit_conversion_ratio,
0 AS unit_conversion_ratio, null AS part_attribute_enum,
null AS part_attribute_enum, null AS tho_part_attribute_enum,
null AS tho_part_attribute_enum, null AS skin_test_flag,
null AS skin_test_flag, null AS inject_flag,
null AS inject_flag, T1.ID AS advice_definition_id,
T1.ID AS advice_definition_id, T1.NAME AS advice_name,
T1.NAME AS advice_name, T1.bus_no AS advice_bus_no,
T1.bus_no AS advice_bus_no, T1.py_str AS py_str,
T1.py_str AS py_str, T1.wb_str AS wb_str,
T1.wb_str AS wb_str, T1.yb_no AS yb_no,
T1.yb_no AS yb_no, '' AS product_name,
'' AS product_name, 0 AS activity_type,
0 AS activity_type, T1.unit_code AS unit_code,
T1.unit_code AS unit_code, T1.min_unit_code AS min_unit_code,
T1.min_unit_code AS min_unit_code, T1.SIZE AS volume,
T1.SIZE AS volume, '' AS method_code,
'' AS method_code, '' AS rate_code,
'' AS rate_code, T1.org_id AS org_id,
T1.org_id AS org_id, T1.location_id AS location_id,
T1.location_id AS location_id, '' AS dose,
'' AS dose, '' AS dose_unit_code,
'' AS dose_unit_code, T2.NAME AS supplier,
T2.NAME AS supplier, T2.id AS supplier_id,
T2.id AS supplier_id, T1.manufacturer_text AS manufacturer,
T1.manufacturer_text AS manufacturer, T4.id AS charge_item_definition_id,
T4.id AS charge_item_definition_id, T4.instance_table AS advice_table_name,
T4.instance_table AS advice_table_name, T5.def_location_id AS position_id,
T5.def_location_id AS position_id, 0 AS restricted_flag,
0 AS restricted_flag, '' AS restricted_scope,
'' AS restricted_scope, '' AS dosage_instruction,
'' AS dosage_instruction, T1.chrgitm_lv as chrgitm_lv
T1.chrgitm_lv as chrgitm_lv FROM adm_device_definition AS T1
FROM adm_device_definition AS T1 LEFT JOIN adm_supplier AS T2
LEFT JOIN adm_supplier AS T2 ON T2.ID = T1.supply_id
ON T2.ID = T1.supply_id AND T2.delete_flag = '0'
AND T2.delete_flag = '0' LEFT JOIN adm_charge_item_definition AS T4 ON T4.instance_id = T1.ID
LEFT JOIN adm_charge_item_definition AS T4 ON T4.instance_id = T1.ID AND T4.delete_flag = '0' AND T4.status_enum = #{statusEnum}
AND T4.delete_flag = '0' AND T4.status_enum = #{statusEnum} LEFT JOIN adm_organization_location AS T5 ON T5.distribution_category_code = T1.category_code
LEFT JOIN adm_organization_location AS T5 ON T5.distribution_category_code = T1.category_code AND T5.delete_flag = '0' AND T5.item_code = '2' AND T5.organization_id = #{organizationId} AND
AND T5.delete_flag = '0' AND T5.item_code = '2' AND T5.organization_id = #{organizationId} AND (CURRENT_TIME :: time (6) BETWEEN T5.start_time AND T5.end_time)
(CURRENT_TIME :: time (6) BETWEEN T5.start_time AND T5.end_time) WHERE T1.delete_flag = '0'
WHERE T1.delete_flag = '0' <if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()">
<if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()"> AND T1.id IN
AND T1.id IN <foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")">
<foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")"> #{itemId}
#{itemId} </foreach>
</foreach> </if>
</if> 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, 3 AS advice_type,
3 AS advice_type, T1.bus_no AS bus_no,
T1.bus_no AS bus_no, T1.category_code AS category_code,
T1.category_code AS category_code, '' AS pharmacology_category_code,
'' AS pharmacology_category_code, 1 AS part_percent,
1 AS part_percent, 0 AS unit_conversion_ratio,
0 AS unit_conversion_ratio, null AS part_attribute_enum,
null AS part_attribute_enum, null AS tho_part_attribute_enum,
null AS tho_part_attribute_enum, null AS skin_test_flag,
null AS skin_test_flag, null AS inject_flag,
null AS inject_flag, T1.ID AS advice_definition_id,
T1.ID AS advice_definition_id, T1.NAME AS advice_name,
T1.NAME AS advice_name, T1.bus_no AS advice_bus_no,
T1.bus_no AS advice_bus_no, T1.py_str AS py_str,
T1.py_str AS py_str, T1.wb_str AS wb_str,
T1.wb_str AS wb_str, T1.yb_no AS yb_no,
T1.yb_no AS yb_no, '' AS product_name,
'' AS product_name, T1.type_enum AS activity_type,
T1.type_enum AS activity_type, '' AS unit_code,
'' AS unit_code, '' AS min_unit_code,
'' AS min_unit_code, '' AS volume,
'' AS volume, '' AS method_code,
'' AS method_code, '' AS rate_code,
'' AS rate_code, T1.org_id AS org_id,
T1.org_id AS org_id, T1.location_id AS location_id,
T1.location_id AS location_id, '' AS dose,
'' AS dose, '' AS dose_unit_code,
'' AS dose_unit_code, '' AS supplier,
'' AS supplier, null AS supplier_id,
null AS supplier_id, '' AS manufacturer,
'' AS manufacturer, T2.ID AS charge_item_definition_id,
T2.ID AS charge_item_definition_id, T2.instance_table AS advice_table_name,
T2.instance_table AS advice_table_name, T3.organization_id AS position_id,
T3.organization_id AS position_id, 0 AS restricted_flag,
0 AS restricted_flag, '' AS restricted_scope,
'' AS restricted_scope, '' AS dosage_instruction,
'' AS dosage_instruction, T1.chrgitm_lv as chrgitm_lv
T1.chrgitm_lv as chrgitm_lv FROM wor_activity_definition AS T1
FROM wor_activity_definition AS T1 LEFT JOIN adm_charge_item_definition AS T2
LEFT JOIN adm_charge_item_definition AS T2 ON T2.instance_id = T1.ID
ON T2.instance_id = T1.ID AND T2.delete_flag = '0' AND T2.status_enum = #{statusEnum}
AND T2.delete_flag = '0' AND T2.status_enum = #{statusEnum} AND T2.instance_table = #{activityTableName}
AND T2.instance_table = #{activityTableName} LEFT JOIN adm_organization_location AS T3 ON T3.activity_definition_id = T1.ID
LEFT JOIN adm_organization_location AS T3 ON T3.activity_definition_id = T1.ID AND T3.delete_flag = '0' AND (CURRENT_TIME :: time (6) BETWEEN T3.start_time AND T3.end_time)
AND T3.delete_flag = '0' AND (CURRENT_TIME :: time (6) BETWEEN T3.start_time AND T3.end_time) WHERE T1.delete_flag = '0'
WHERE T1.delete_flag = '0' <if test="pricingFlag ==1">
<if test="pricingFlag ==1"> AND (T1.pricing_flag = #{pricingFlag} OR T1.pricing_flag IS NULL)
AND (T1.pricing_flag = #{pricingFlag} OR T1.pricing_flag IS NULL) </if>
</if> <if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()">
<if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()"> AND T1.id IN
AND T1.id IN <foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")">
<foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")"> #{itemId}
#{itemId} </foreach>
</foreach> </if>
</if> AND T1.status_enum = #{statusEnum}
AND T1.status_enum = #{statusEnum} )
) </if>
</if> </if>
</trim> <!-- 如果没有有效的adviceTypes提供一个空的默认查询以避免语法错误 -->
</when> <if test="adviceTypes == null or adviceTypes.isEmpty() or (!adviceTypes.contains(1) and !adviceTypes.contains(2) and !adviceTypes.contains(3))">
<otherwise> SELECT
-- 当没有指定adviceTypes或adviceTypes为空时返回空结果集但保持正确的SQL语法 mmd.tenant_id,
SELECT CAST(0 AS INTEGER) AS advice_type,
NULL::varchar AS tenant_id, CAST('' AS VARCHAR) AS bus_no,
NULL::integer AS advice_type, CAST('' AS VARCHAR) AS category_code,
NULL::varchar AS bus_no, CAST('' AS VARCHAR) AS pharmacology_category_code,
NULL::varchar AS category_code, CAST(0 AS NUMERIC) AS part_percent,
NULL::varchar AS pharmacology_category_code, CAST(0 AS NUMERIC) AS unit_conversion_ratio,
NULL::numeric AS part_percent, CAST(0 AS INTEGER) AS part_attribute_enum,
NULL::numeric AS unit_conversion_ratio, CAST(0 AS INTEGER) AS tho_part_attribute_enum,
NULL::integer AS part_attribute_enum, CAST(0 AS INTEGER) AS skin_test_flag,
NULL::integer AS tho_part_attribute_enum, CAST(0 AS INTEGER) AS inject_flag,
NULL::integer AS skin_test_flag, CAST(0 AS BIGINT) AS advice_definition_id,
NULL::integer AS inject_flag, CAST('' AS VARCHAR) AS advice_name,
NULL::bigint AS advice_definition_id, CAST('' AS VARCHAR) AS advice_bus_no,
NULL::varchar AS advice_name, CAST('' AS VARCHAR) AS py_str,
NULL::varchar AS advice_bus_no, CAST('' AS VARCHAR) AS wb_str,
NULL::varchar AS py_str, CAST('' AS VARCHAR) AS yb_no,
NULL::varchar AS wb_str, CAST('' AS VARCHAR) AS product_name,
NULL::varchar AS yb_no, CAST(0 AS INTEGER) AS activity_type,
NULL::varchar AS product_name, CAST('' AS VARCHAR) AS unit_code,
NULL::integer AS activity_type, CAST('' AS VARCHAR) AS min_unit_code,
NULL::varchar AS unit_code, CAST(0 AS NUMERIC) AS volume,
NULL::varchar AS min_unit_code, CAST('' AS VARCHAR) AS method_code,
NULL::numeric AS volume, CAST('' AS VARCHAR) AS rate_code,
NULL::varchar AS method_code, CAST(0 AS BIGINT) AS org_id,
NULL::varchar AS rate_code, CAST(0 AS BIGINT) AS location_id,
NULL::bigint AS org_id, CAST('' AS VARCHAR) AS dose,
NULL::bigint AS location_id, CAST('' AS VARCHAR) AS dose_unit_code,
NULL::varchar AS dose, CAST('' AS VARCHAR) AS supplier,
NULL::varchar AS dose_unit_code, CAST(0 AS BIGINT) AS supplier_id,
NULL::varchar AS supplier, CAST('' AS VARCHAR) AS manufacturer,
NULL::bigint AS supplier_id, CAST(0 AS BIGINT) AS charge_item_definition_id,
NULL::varchar AS manufacturer, CAST('' AS VARCHAR) AS advice_table_name,
NULL::bigint AS charge_item_definition_id, CAST(0 AS BIGINT) AS position_id,
NULL::varchar AS advice_table_name, CAST(0 AS INTEGER) AS restricted_flag,
NULL::bigint AS position_id, CAST('' AS VARCHAR) AS restricted_scope,
NULL::integer AS restricted_flag, CAST('' AS VARCHAR) AS dosage_instruction,
NULL::varchar AS restricted_scope, CAST(0 AS INTEGER) AS chrgitm_lv
NULL::varchar AS dosage_instruction, FROM med_medication_definition mmd
NULL::integer AS chrgitm_lv WHERE 1 = 0 -- 仍然确保不返回任何行,但使用真实表确保类型正确
WHERE 1 = 0 -- 确保不返回任何行 </if>
</otherwise>
</choose>
) AS abi ) AS abi
${ew.customSqlSegment} ${ew.customSqlSegment}
</select> </select>

View File

@@ -197,7 +197,10 @@ watch(
// 直接更新查询参数 // 直接更新查询参数
queryParams.value.searchKey = newValue.searchKey || ''; queryParams.value.searchKey = newValue.searchKey || '';
// 更新categoryCode
queryParams.value.categoryCode = newValue.categoryCode || '';
// 处理类型筛选 // 处理类型筛选
if (newValue.adviceType !== undefined && newValue.adviceType !== null && newValue.adviceType !== '') { if (newValue.adviceType !== undefined && newValue.adviceType !== null && newValue.adviceType !== '') {
// 单个类型 // 单个类型
@@ -215,8 +218,18 @@ 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;
return Number(price).toFixed(2) + ' 元'; // 检查价格是否为有效数字
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 '-'; return '-';
} }

View File

@@ -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 元'
}} }}
@@ -782,6 +782,19 @@
// 当医嘱类型改变时,清空当前选择的项目名称,因为不同类型项目的数据结构可能不兼容 // 当医嘱类型改变时,清空当前选择的项目名称,因为不同类型项目的数据结构可能不兼容
prescriptionList[scope.$index].adviceName = undefined; prescriptionList[scope.$index].adviceName = undefined;
adviceQueryParams.adviceType = value; adviceQueryParams.adviceType = value;
// 根据选择的类型设置categoryCode用于药品分类筛选
if (value == 1) { // 西药
adviceQueryParams.categoryCode = '2';
} else if (value == 2) { // 中成药
adviceQueryParams.categoryCode = '1';
} else if (value == 3) { // 耗材
adviceQueryParams.categoryCode = ''; // 耗材不需要categoryCode筛选
} else if (value == 4) { // 诊疗
adviceQueryParams.categoryCode = ''; // 诊疗不需要categoryCode筛选
} else {
adviceQueryParams.categoryCode = ''; // 全部类型
}
} }
" "
@clear=" @clear="
@@ -907,7 +920,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 +2865,25 @@ function getGroupMarkers() {
function calculateTotalPrice(row, index) { function calculateTotalPrice(row, index) {
nextTick(() => { nextTick(() => {
if (row.adviceType == 3) { if (row.adviceType == 3) {
row.totalPrice = (row.unitPrice * row.quantity).toFixed(6); // 检查价格是否为有效数字
if (row.unitPrice !== undefined && row.unitPrice !== null && !isNaN(row.unitPrice) && isFinite(row.unitPrice)) {
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) {
row.totalPrice = (row.minUnitPrice * row.quantity).toFixed(6); if (row.minUnitPrice !== undefined && row.minUnitPrice !== null && !isNaN(row.minUnitPrice) && isFinite(row.minUnitPrice)) {
row.totalPrice = (row.minUnitPrice * row.quantity).toFixed(6);
} else {
row.totalPrice = '0.000000';
}
} else { } else {
row.totalPrice = (row.unitPrice * row.quantity).toFixed(6); if (row.unitPrice !== undefined && row.unitPrice !== null && !isNaN(row.unitPrice) && isFinite(row.unitPrice)) {
row.totalPrice = (row.unitPrice * row.quantity).toFixed(6);
} else {
row.totalPrice = '0.000000';
}
} }
} }
}); });

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="lis-group-maintain"> <div class="lis-group-maintain">
<!-- 标题区域 --> <!-- 标题区域 -->
<div class="header"> <div class="header">
<h2>LIS分组维护</h2> <h2>LIS分组维护</h2>
@@ -10,125 +10,128 @@
<div class="table-container"> <div class="table-container">
<table class="data-table"> <table class="data-table">
<thead> <thead>
<tr> <tr>
<th style="width: 50px;"></th> <th style="width: 50px;"></th>
<th style="width: 150px;">卫生机构</th> <th style="width: 150px;">卫生机构</th>
<th style="width: 150px;">日期</th> <th style="width: 150px;">日期</th>
<th style="width: 200px;">LIS分组名称</th> <th style="width: 200px;">LIS分组名称</th>
<th style="width: 120px;">采血管</th> <th style="width: 120px;">采血管</th>
<th style="width: 300px;">备注</th> <th style="width: 300px;">备注</th>
<th style="width: 150px;">操作</th> <th style="width: 150px;">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr <tr
v-for="(item, index) in tableData" v-for="(item, index) in tableData"
:key="item.id || index" :key="item.id || index"
:class="{ 'editing-row': item.editing }" :class="{ 'editing-row': item.editing, 'success-row': item.success, 'deleting-row': item.deleting }"
> >
<td>{{ index + 1 }}</td> <td>{{ index + 1 }}</td>
<td> <td>
<template v-if="item.editing"> <template v-if="item.editing">
<input <input
type="text" type="text"
v-model="item.healthInstitution" v-model="item.healthInstitution"
placeholder="请输入卫生机构" disabled
:class="{ 'error-input': item.errors?.healthInstitution }" >
> </template>
<span v-if="item.errors?.healthInstitution" class="error-message">{{ item.errors.healthInstitution }}</span> <template v-else>
{{ item.healthInstitution }}
</template>
</td>
<td>
<template v-if="item.editing">
<input type="text" v-model="item.date" disabled>
</template>
<template v-else>
{{ item.date }}
</template>
</td>
<td>
<template v-if="item.editing">
<input
type="text"
v-model="item.lisGroupName"
placeholder="请输入分组名称"
:class="{ 'error-input': item.errors?.lisGroupName, 'focus-target': item.isNew }"
>
<span v-if="item.errors?.lisGroupName" class="error-message">{{ item.errors.lisGroupName }}</span>
</template>
<template v-else>
{{ item.lisGroupName }}
</template>
</td>
<td>
<template v-if="item.editing">
<select
v-model="item.bloodCollectionTube"
:class="{ 'error-input': item.errors?.bloodCollectionTube }"
>
<option value="">请选择采血管</option>
<option v-for="tube in bloodTubeOptions" :key="tube" :value="tube">
{{ tube }}
</option>
</select>
<span v-if="item.errors?.bloodCollectionTube" class="error-message">{{ item.errors.bloodCollectionTube }}</span>
</template>
<template v-else>
{{ item.bloodCollectionTube }}
</template>
</td>
<td>
<template v-if="item.editing">
<input type="text" v-model="item.remark" placeholder="请输入备注信息">
</template>
<template v-else>
{{ item.remark || '' }}
</template>
</td>
<td>
<div class="actions">
<template v-if="!item.editing">
<button class="btn btn-edit" @click="startEdit(item)"></button>
<button class="btn btn-primary" @click="addRow">+</button>
<button class="btn btn-delete" @click="deleteRow(index)">🗑</button>
</template> </template>
<template v-else> <template v-else>
{{ item.healthInstitution }} <button class="btn btn-confirm" @click="confirmEdit(item)"></button>
<button class="btn btn-cancel" @click="cancelEdit(item)">×</button>
</template> </template>
</td> </div>
<td> </td>
<template v-if="item.editing"> </tr>
<input type="text" v-model="item.date" disabled>
</template>
<template v-else>
{{ item.date }}
</template>
</td>
<td>
<template v-if="item.editing">
<input
type="text"
v-model="item.lisGroupName"
placeholder="请输入分组名称"
:class="{ 'error-input': item.errors?.lisGroupName }"
>
<span v-if="item.errors?.lisGroupName" class="error-message">{{ item.errors.lisGroupName }}</span>
</template>
<template v-else>
{{ item.lisGroupName }}
</template>
</td>
<td>
<template v-if="item.editing">
<select
v-model="item.bloodCollectionTube"
:class="{ 'error-input': item.errors?.bloodCollectionTube }"
>
<option value="">请选择采血管</option>
<option v-for="tube in bloodTubeOptions" :key="tube" :value="tube">
{{ tube }}
</option>
</select>
<span v-if="item.errors?.bloodCollectionTube" class="error-message">{{ item.errors.bloodCollectionTube }}</span>
</template>
<template v-else>
{{ item.bloodCollectionTube }}
</template>
</td>
<td>
<template v-if="item.editing">
<input type="text" v-model="item.remark" placeholder="请输入备注信息">
</template>
<template v-else>
{{ item.remark || '' }}
</template>
</td>
<td>
<div class="actions">
<template v-if="!item.editing">
<button class="btn btn-edit" @click="startEdit(item)"></button>
<button class="btn btn-primary" @click="addRow">+</button>
<button class="btn btn-delete" @click="deleteRow(index)">🗑</button>
</template>
<template v-else>
<button class="btn btn-confirm" @click="confirmEdit(item)"></button>
<button class="btn btn-cancel" @click="cancelEdit(item)">×</button>
</template>
</div>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- 分页区域 --> <!-- 分页区域 -->
<div class="pagination"> <div class="pagination">
<button class="pagination-btn"></button> <button class="pagination-btn" @click="prevPage" :disabled="currentPage <= 1"></button>
<span>1</span> <span>{{ currentPage }}</span>
<button class="pagination-btn"></button> <button class="pagination-btn" @click="nextPage" :disabled="currentPage >= totalPages"></button>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import {computed, onMounted, reactive, ref} from 'vue' import {computed, nextTick, onMounted, reactive, ref} from 'vue'
import {addLisGroup, delLisGroup, listLisGroup, updateLisGroup} from '@/api/system/checkType' import {addLisGroup, delLisGroup, listLisGroup, updateLisGroup} from '@/api/system/checkType'
import {getDicts} from "@/api/system/dict/data"; import {getDicts} from "@/api/system/dict/data";
import useUserStore from '@/store/modules/user';
import {ElMessage, ElMessageBox} from 'element-plus';
export default { export default {
name: 'LisGroupMaintain', name: 'LisGroupMaintain',
setup() { setup() {
// 获取用户store
const userStore = useUserStore();
// 加载状态 // 加载状态
const loading = ref(false) const loading = ref(false)
// 采血管选项 // 采血管选项
const bloodTubeOptions = ref([]); const bloodTubeOptions = ref([]);
// 加载采血管颜色字典数据 // 加载采血管颜色字典数据
const loadBloodTubeDict = async () => { const loadBloodTubeDict = async () => {
try { try {
@@ -138,22 +141,26 @@ export default {
bloodTubeOptions.value = response.data.map(item => item.label || item.dictLabel); bloodTubeOptions.value = response.data.map(item => item.label || item.dictLabel);
} }
} catch (error) { } catch (error) {
console.error('获取采血管颜色字典失败:', error);
// 如果字典获取失败,使用默认选项作为备选 // 如果字典获取失败,使用默认选项作为备选
bloodTubeOptions.value = ['黄管', '紫管', '蓝管']; bloodTubeOptions.value = ['黄管', '紫管', '蓝管'];
} }
}; };
// 分页相关数据 // 分页相关数据
const currentPage = ref(1) const currentPage = ref(1)
const pageSize = ref(10) const pageSize = ref(10)
const totalItems = ref(2) // 总数据量,实际应用中应该从后端获取 const totalItems = ref(2) // 总数据量,实际应用中应该从后端获取
// 总页数 // 总页数
const totalPages = computed(() => { const totalPages = computed(() => {
return Math.ceil(totalItems.value / pageSize.value) return Math.ceil(totalItems.value / pageSize.value)
}) })
// 获取当前用户的卫生机构名称
const getCurrentHospital = () => {
return userStore.hospitalName || userStore.orgName || '演示医院';
};
// 表格数据 // 表格数据
const tableData = reactive([]) const tableData = reactive([])
@@ -165,7 +172,7 @@ export default {
const day = String(date.getDate()).padStart(2, '0') const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}` return `${year}-${month}-${day}`
} }
// 加载LIS分组数据 // 加载LIS分组数据
const loadLisGroups = async () => { const loadLisGroups = async () => {
// 确保采血管字典数据已加载 // 确保采血管字典数据已加载
@@ -174,217 +181,85 @@ export default {
} }
try { try {
loading.value = true loading.value = true
// 构建查询参数 // 构建查询参数
const query = { const query = {
pageNum: currentPage.value, pageNum: currentPage.value,
pageSize: pageSize.value pageSize: pageSize.value
} }
console.log('准备调用接口,查询参数:', query)
// 调用接口获取数据 // 调用接口获取数据
// 注意根据checkType.js中的定义这个接口使用GET方法和params参数
const response = await listLisGroup(query) const response = await listLisGroup(query)
console.log('接口返回结果类型:', typeof response)
console.log('接口返回结果:', response)
console.log('响应是否包含code字段:', response && 'code' in response)
console.log('响应是否包含data字段:', response && 'data' in response)
// 清空现有数据 // 清空现有数据
tableData.splice(0, tableData.length) tableData.splice(0, tableData.length)
totalItems.value = 0 totalItems.value = 0
// 适配可能的不同响应格式 // 处理明确的数据结构
let items = [] if (response && response.code === 200) {
let total = 0 // 清空现有数据
tableData.splice(0, tableData.length);
// 检查响应是否存在
if (response) { // 获取最内层的数据结构
// 处理标准响应格式 const innerResponse = response.data;
if (typeof response === 'object') { if (innerResponse && innerResponse.code === 200) {
// 检查是否是标准API响应格式 {code, data, msg} const data = innerResponse.data;
if ('code' in response) { if (data && Array.isArray(data.records)) {
console.log('响应包含code字段:', response.code) // 更新总记录数
totalItems.value = data.total || 0;
// 成功状态码处理
if (response.code === 200 || response.code === '200' || response.code === 0) { // 处理每条记录
console.log('响应状态码为成功状态') data.records.forEach((item, index) => {
const formattedItem = {
// 检查data字段 id: item.id,
if ('data' in response) { healthInstitution: item.hospital,
console.log('响应包含data字段数据类型:', typeof response.data) date: item.date,
lisGroupName: item.groupName,
// 格式1: {data: {rows: [], total: number}} bloodCollectionTube: item.tube,
if (response.data && typeof response.data === 'object') { remark: item.remark || '',
// 处理双重嵌套格式 {data: {code, msg, data: []}} editing: false
if (response.data.data && (Array.isArray(response.data.data) || typeof response.data.data === 'object')) { };
console.log('匹配到格式: 双重嵌套 data.data');
tableData.push(formattedItem);
// 如果data.data是数组直接使用
if (Array.isArray(response.data.data)) {
items = response.data.data;
total = items.length;
console.log('双重嵌套格式1: data.data是数组数据量:', items.length);
}
// 如果data.data是对象检查是否有rows字段
else if (Array.isArray(response.data.data.rows)) {
items = response.data.data.rows;
total = response.data.data.total !== undefined ? response.data.data.total : items.length;
console.log('双重嵌套格式2: data.data包含rows数据量:', items.length, ',总数:', total);
}
}
// 标准格式检查
else if (Array.isArray(response.data.rows)) {
items = response.data.rows
total = response.data.total !== undefined ? response.data.total : items.length
console.log('匹配到格式1: response.data.rows数据量:', items.length, ',总数:', total)
}
// 格式2: {data: []}
else if (Array.isArray(response.data)) {
items = response.data
total = items.length
console.log('匹配到格式2: response.data直接是数组数据量:', items.length)
}
// 检查是否有其他可能的格式
else {
console.log('响应data不是预期格式详细数据:', response.data)
// 尝试将整个data对象作为单个条目处理有些API可能直接返回单个对象
if (response.data) {
items = [response.data]
total = 1
console.log('尝试将整个data对象作为单个条目处理')
}
}
}
} else {
console.log('响应不包含data字段')
}
} else {
// 非成功状态码
const errorMsg = response.msg || response.message || `请求失败,状态码: ${response.code}`
console.error('请求失败:', errorMsg)
showMessage(errorMsg, 'error')
}
}
// 格式3: 响应本身是一个对象但没有code字段可能是单个记录
else if (!Array.isArray(response)) {
console.log('响应是对象但没有code字段尝试作为单个记录处理')
items = [response]
total = 1
}
}
// 格式4: 响应本身是数组
if (Array.isArray(response)) {
items = response
total = items.length
console.log('匹配到格式4: 响应本身是数组,数据量:', items.length)
}
// 记录最终解析到的数据量
console.log('最终解析到的数据量:', items.length, ',总数:', total)
} else {
console.error('接口返回空数据')
showMessage('获取LIS分组数据失败服务器返回空响应', 'error')
}
// 处理获取到的数据
if (items && items.length > 0) {
// 处理每条数据,确保字段正确映射
items.forEach((item, index) => {
// 确保item是对象类型
if (typeof item === 'object' && item !== null) {
console.log(`处理记录 ${index + 1} 原始数据:`, item);
// 创建格式化后的对象,确保字段存在
// 根据网络响应截图更正字段映射关系
const formattedItem = {
id: item.id || `temp_${Date.now()}_${index}`, // 确保有ID
// 更正字段映射hospital -> healthInstitution
healthInstitution: item.hospital || item.org || item.healthInstitution || '',
// 优先使用date字段
date: item.date || item.createTime || item.createDate || '',
// 更正字段映射groupName -> lisGroupName
lisGroupName: item.groupName || item.name || item.lisGroupName || '',
// 更正字段映射tube -> bloodCollectionTube
bloodCollectionTube: item.tube || item.property || item.bloodCollectionTube || item.bloodTube || '',
remark: item.remark || item.note || '',
editing: false,
// 保留原始对象的所有其他属性
...item
};
tableData.push(formattedItem);
console.log(`处理记录 ${index + 1} 格式化后数据:`, {
id: formattedItem.id,
healthInstitution: formattedItem.healthInstitution,
date: formattedItem.date,
lisGroupName: formattedItem.lisGroupName,
bloodCollectionTube: formattedItem.bloodCollectionTube,
remark: formattedItem.remark
}); });
} else { } else {
console.warn(`记录 ${index + 1} 不是有效对象,跳过处理:`, item); totalItems.value = 0;
} }
}); } else {
totalItems.value = 0;
totalItems.value = total; }
console.log('数据加载完成,表格显示', tableData.length, '条记录,总数:', totalItems.value);
} else { } else {
console.log('未获取到有效数据,表格为空'); // 非成功状态码
const errorMsg = response.msg || response.message || `请求失败,状态码: ${response.code}`
showMessage(errorMsg, 'error')
totalItems.value = 0;
} }
} catch (error) { } catch (error) {
// 详细的错误信息记录 // 提取错误信息
console.error('加载LIS分组数据异常:', error)
// 提取更详细的错误信息
let errorMessage = '加载LIS分组数据失败请稍后重试' let errorMessage = '加载LIS分组数据失败请稍后重试'
if (error.response) { if (error.response) {
// 服务器响应了但状态码不是2xx // 服务器响应了但状态码不是2xx
console.error('HTTP错误状态:', error.response.status)
console.error('HTTP错误响应体:', error.response.data)
if (error.response.data) { if (error.response.data) {
errorMessage = error.response.data.msg || errorMessage = error.response.data.msg ||
error.response.data.message || error.response.data.message ||
error.response.data.error || error.response.data.error ||
`服务器错误 (${error.response.status})` `服务器错误 (${error.response.status})`
} else { } else {
errorMessage = `服务器错误 (${error.response.status})` errorMessage = `服务器错误 (${error.response.status})`
} }
// 额外记录响应体详情便于调试
if (typeof error.response.data === 'object') {
console.error('响应体详细结构:', JSON.stringify(error.response.data, null, 2))
}
} else if (error.request) { } else if (error.request) {
// 请求已发出,但未收到响应 // 请求已发出,但未收到响应
console.error('请求已发送但未收到响应:', error.request)
errorMessage = '网络错误,服务器未响应,请检查网络连接' errorMessage = '网络错误,服务器未响应,请检查网络连接'
} else if (error.message) { } else if (error.message) {
// 请求配置出错 // 请求配置出错
console.error('请求配置错误:', error.message)
errorMessage = error.message errorMessage = error.message
} else {
console.error('未知错误类型:', typeof error)
} }
// 显示错误信息 // 显示错误信息
showMessage(errorMessage, 'error') showMessage(errorMessage, 'error')
// 确保表格状态正确
console.log('异常处理后表格状态:', {
tableDataLength: tableData.length,
totalItems: totalItems.value,
currentPage: currentPage.value
})
} finally { } finally {
loading.value = false loading.value = false
console.log('数据加载操作完成loading状态已更新为false')
console.log('最终表格数据量:', tableData.length, ',总数:', totalItems.value)
} }
} }
@@ -398,53 +273,42 @@ export default {
// 验证数据 // 验证数据
const validateData = (item) => { const validateData = (item) => {
const errors = {} const errors = {}
// 清除之前的错误信息 // 清除之前的错误信息
delete item.errors delete item.errors
// 验证卫生机构
if (!item.healthInstitution || item.healthInstitution.trim() === '') {
errors.healthInstitution = '卫生机构不能为空'
} else if (item.healthInstitution.length > 100) {
errors.healthInstitution = '卫生机构名称不能超过100个字符'
}
// 验证LIS分组名称 // 验证LIS分组名称
if (!item.lisGroupName || item.lisGroupName.trim() === '') { if (!item.lisGroupName || item.lisGroupName.trim() === '') {
errors.lisGroupName = 'LIS分组名称不能为空' errors.lisGroupName = 'LIS分组名称不能为空'
} else if (item.lisGroupName.length > 50) { } else if (item.lisGroupName.length > 50) {
errors.lisGroupName = 'LIS分组名称不能超过50个字符' errors.lisGroupName = 'LIS分组名称不能超过50个字符'
} }
// 验证采血管 // 验证采血管
if (!item.bloodCollectionTube) { if (!item.bloodCollectionTube) {
errors.bloodCollectionTube = '请选择采血管' errors.bloodCollectionTube = '请选择采血管'
} }
// 验证备注长度 // 验证备注长度
if (item.remark && item.remark.length > 200) { if (item.remark && item.remark.length > 200) {
errors.remark = '备注信息不能超过200个字符' errors.remark = '备注信息不能超过200个字符'
} }
if (Object.keys(errors).length > 0) { if (Object.keys(errors).length > 0) {
item.errors = errors item.errors = errors
return false return false
} }
return true return true
} }
// 显示提示信息 // 显示提示信息
const showMessage = (message, type = 'success') => { const showMessage = (message, type = 'success') => {
// 在实际项目中,这里可以使用Element Plus或其他UI库的消息组件 // 使用Element Plus的消息组件
// 这里为了简单起见使用浏览器的alert但添加了类型标识
if (type === 'error') { if (type === 'error') {
console.error(message) ElMessage.error(message)
alert(`错误: ${message}`)
} else { } else {
console.log(message) ElMessage.success(message)
// 可以使用更友好的提示方式这里暂时注释掉alert以避免频繁弹窗
// alert(message)
} }
} }
@@ -455,24 +319,24 @@ export default {
showMessage('请检查并修正错误信息', 'error') showMessage('请检查并修正错误信息', 'error')
return return
} }
// 检查是否有重复的分组名称(在同一个卫生机构内) // 检查是否有重复的分组名称(在同一个卫生机构内)
const duplicate = tableData.find(data => const duplicate = tableData.find(data =>
data.id !== item.id && data.id !== item.id &&
data.healthInstitution === item.healthInstitution && data.healthInstitution === item.healthInstitution &&
data.lisGroupName === item.lisGroupName data.lisGroupName === item.lisGroupName
) )
if (duplicate) { if (duplicate) {
if (!item.errors) item.errors = {} if (!item.errors) item.errors = {}
item.errors.lisGroupName = '该分组名称已存在' item.errors.lisGroupName = '该分组名称已存在'
showMessage('分组名称重复,请修改', 'error') showMessage('分组名称重复,请修改', 'error')
return return
} }
try { try {
loading.value = true loading.value = true
// 准备提交数据(使用后端期望的字段名) // 准备提交数据(使用后端期望的字段名)
const submitData = { const submitData = {
id: item.id, id: item.id,
@@ -482,7 +346,7 @@ export default {
tube: item.bloodCollectionTube, // 前端字段映射到后端字段 tube: item.bloodCollectionTube, // 前端字段映射到后端字段
remark: item.remark remark: item.remark
} }
let response let response
// 判断是新增还是修改 // 判断是新增还是修改
if (item.isNew) { if (item.isNew) {
@@ -492,29 +356,35 @@ export default {
// 修改 // 修改
response = await updateLisGroup(submitData) response = await updateLisGroup(submitData)
} }
// 处理响应 // 处理响应
if (response.code === 200) { if (response.code === 200) {
// 保存编辑 // 保存编辑
item.editing = false item.editing = false
delete item.originalData delete item.originalData
delete item.errors delete item.errors
// 先检查是否是新增记录再删除isNew属性 // 先检查是否是新增记录再删除isNew属性
const isNewRecord = item.isNew const isNewRecord = item.isNew
delete item.isNew delete item.isNew
// 添加保存成功样式,包括新增记录
item.success = true
// 0.5秒后移除成功样式
setTimeout(() => {
item.success = false
}, 500)
showMessage('保存成功') showMessage('保存成功')
// 如果是新增,重新加载数据确保数据一致 // 修改完成后重新请求后端本页数据确保数据准确
if (isNewRecord) { setTimeout(() => {
loadLisGroups() loadLisGroups()
} }, 500)
} else { } else {
showMessage(`保存失败: ${response.msg || '未知错误'}`, 'error') showMessage(`保存失败: ${response.msg || '未知错误'}`, 'error')
} }
} catch (error) { } catch (error) {
console.error('保存LIS分组数据失败:', error)
showMessage(`保存失败: ${error.message || '未知错误'}`, 'error') showMessage(`保存失败: ${error.message || '未知错误'}`, 'error')
} finally { } finally {
loading.value = false loading.value = false
@@ -543,24 +413,25 @@ export default {
item.editing = false item.editing = false
} }
} catch (error) { } catch (error) {
console.error('取消编辑失败:', error)
showMessage('取消编辑失败', 'error') showMessage('取消编辑失败', 'error')
} }
} }
// 添加新行 // 添加新行
const addRow = () => { const addRow = async () => {
// 检查是否已有正在编辑的行 // 检查是否已有正在编辑的行
const editingRow = tableData.find(item => item.editing) const editingRow = tableData.find(item => item.editing)
if (editingRow) { if (editingRow) {
showMessage('请先完成当前行的编辑', 'error') showMessage('请先完成当前行的编辑', 'error')
return return
} }
const newId = String(Math.max(...tableData.map(item => parseInt(item.id) || 0), 0) + 1) const newId = String(Math.max(...tableData.map(item => parseInt(item.id) || 0), 0) + 1)
// 从用户信息中获取当前卫生机构
const currentHospital = getCurrentHospital()
tableData.push({ tableData.push({
id: newId, id: '',
healthInstitution: '', // 默认 healthInstitution: currentHospital, // 默认当前操作工号的卫生机构
date: getCurrentDate(), // 默认当前系统时间 date: getCurrentDate(), // 默认当前系统时间
lisGroupName: '', lisGroupName: '',
bloodCollectionTube: '', bloodCollectionTube: '',
@@ -569,8 +440,15 @@ export default {
errors: null, errors: null,
isNew: true // 标记为新记录 isNew: true // 标记为新记录
}) })
showMessage('请填写新记录信息') // 等待DOM更新后聚焦到第一个输入框
await nextTick()
const focusElement = document.querySelector('.focus-target')
if (focusElement) {
focusElement.focus()
// 清除focus-target类避免下次添加行时影响
focusElement.classList.remove('focus-target')
}
} }
// 删除行 // 删除行
@@ -581,36 +459,66 @@ export default {
showMessage('请先完成或取消编辑', 'error') showMessage('请先完成或取消编辑', 'error')
return return
} }
if (confirm(`确定要删除"${item.lisGroupName}"这条记录吗?`)) { try {
try { // 使用Element Plus的确认对话框
loading.value = true await ElMessageBox.confirm(
`确定要删除"${item.lisGroupName}"这条记录吗?`,
// 如果是新添加的记录,直接从数组中移除 '删除确认',
if (item.isNew) { {
tableData.splice(index, 1) confirmButtonText: '确定',
showMessage('删除成功') cancelButtonText: '取消',
totalItems.value-- type: 'warning'
} else { }
// 调用API删除 )
const response = await delLisGroup(item.id)
loading.value = true
if (response.code === 200) {
tableData.splice(index, 1) // 添加删除行标记,触发渐隐效果
showMessage('删除成功') item.deleting = true
// 更新总数 // 等待300ms让渐隐效果完成
totalItems.value-- await new Promise(resolve => setTimeout(resolve, 300))
} else {
showMessage(`删除失败: ${response.msg || '未知错误'}`, 'error') // 如果是新添加的记录,直接从数组中移除
} if (item.isNew) {
tableData.splice(index, 1)
showMessage('删除成功')
totalItems.value--
} else {
// 调用API删除
const response = await delLisGroup(item.id)
if (response.code === 200) {
// 更新总数
totalItems.value--
// 检查当前页码是否仍然有效
const newTotalPages = Math.ceil(totalItems.value / pageSize.value)
if (currentPage.value > newTotalPages && newTotalPages > 0) {
// 如果当前页码大于总页数且总页数大于0调整为最后一页
currentPage.value = newTotalPages
}
// 重新加载当前页数据,保持页码不变
loadLisGroups()
showMessage('删除成功')
} else {
showMessage(`删除失败: ${response.msg || '未知错误'}`, 'error')
// 如果删除失败,移除删除标记
item.deleting = false
} }
} catch (error) {
console.error('删除LIS分组数据失败:', error)
showMessage(`删除失败: ${error.message || '未知错误'}`, 'error')
} finally {
loading.value = false
} }
} catch (error) {
if (error !== 'cancel') {
showMessage(`删除失败: ${error.message || '未知错误'}`, 'error')
// 如果删除失败,移除删除标记
if (tableData[index]) {
tableData[index].deleting = false
}
}
} finally {
loading.value = false
} }
} }
@@ -638,7 +546,7 @@ export default {
loadLisGroups() loadLisGroups()
} }
} }
// 组件挂载时加载数据 // 组件挂载时加载数据
onMounted(() => { onMounted(() => {
// 加载采血管字典数据 // 加载采血管字典数据
@@ -680,7 +588,7 @@ export default {
align-items: center; align-items: center;
} }
.header h1 { .header h2 {
font-size: 18px; font-size: 18px;
font-weight: 500; font-weight: 500;
color: #333; color: #333;
@@ -718,6 +626,12 @@ export default {
background-color: #f0f8ff; background-color: #f0f8ff;
} }
/* 保存成功行样式 */
.success-row {
background-color: #f6ffed !important;
transition: background-color 0.3s ease;
}
.actions { .actions {
white-space: nowrap; white-space: nowrap;
} }
@@ -732,7 +646,7 @@ export default {
/* 分页样式 */ /* 分页样式 */
.pagination { .pagination {
display: flex; display: flex;
justify-content: flex-end; justify-content: center;
align-items: center; align-items: center;
padding: 16px 0; padding: 16px 0;
margin-top: 8px; margin-top: 8px;
@@ -741,6 +655,14 @@ export default {
.pagination span { .pagination span {
font-size: 14px; font-size: 14px;
margin: 0 16px; margin: 0 16px;
background-color: #1890FF;
color: white;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
} }
.pagination-btn { .pagination-btn {
@@ -946,33 +868,34 @@ input:disabled {
.lis-group-maintain { .lis-group-maintain {
padding: 10px; padding: 10px;
} }
.header h1 { .header h1 {
font-size: 16px; font-size: 16px;
} }
.table-container { .table-container {
border-radius: 0; border-radius: 0;
} }
.data-table { .data-table {
font-size: 12px; font-size: 12px;
min-width: 600px; /* 确保表格在小屏幕上可以横向滚动 */ border-collapse: collapse;
min-width: 768px; /* 确保表格在小屏幕上可以横向滚动 */
} }
.data-table th, .data-table th,
.data-table td { .data-table td {
padding: 8px; padding: 8px;
text-align: center; text-align: center;
} }
.btn { .btn {
width: 20px; width: 20px;
height: 20px; height: 20px;
font-size: 11px; font-size: 11px;
margin-right: 2px; margin-right: 2px;
} }
.pagination-btn { .pagination-btn {
width: 28px; width: 28px;
height: 28px; height: 28px;
@@ -984,7 +907,16 @@ input:disabled {
/* 平滑过渡效果 */ /* 平滑过渡效果 */
.btn, .btn,
.pagination-btn, .pagination-btn,
.editing-row { .editing-row,
tr {
transition: all 0.3s ease;
}
/* 删除行渐隐效果 */
.deleting-row {
opacity: 0;
height: 0;
overflow: hidden;
transition: all 0.3s ease; transition: all 0.3s ease;
} }