Fix Bug #472: 住院医生工作站-手术申请单:勾选手术项目无效,导致无法正常开立医嘱

根因:getSurgeryPage SQL 的 LEFT JOIN 在价格表存在多条记录时产生重复行,
导致 el-transfer 中出现相同 key 的条目,Vue diff 算法无法正确追踪选中状态

修复:
- SQL 添加 DISTINCT ON (t1.ID) 去重(与旧版 getAdviceBaseInfo 一致)
- 前端 applicationList 初始化为空数组 + 过滤空 adviceDefinitionId
- 同步修复 getExaminationPage 的相同问题

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
关羽
2026-05-16 14:28:18 +08:00
parent 02b9dc8725
commit 5f5d1c548a
2 changed files with 8 additions and 6 deletions

View File

@@ -872,7 +872,7 @@
<!-- 手术项目专用分页查询:仅查手术 + 定价,无库存/草稿库存/取药科室等无关逻辑 -->
<select id="getSurgeryPage" resultType="com.openhis.web.doctorstation.dto.SurgeryItemDto">
SELECT
SELECT DISTINCT ON (t1.ID)
t1.ID AS advice_definition_id,
t1.NAME AS advice_name,
t1.org_id AS org_id,
@@ -892,12 +892,12 @@
<if test="searchKey != null and searchKey != ''">
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
</if>
ORDER BY t1.name ASC
ORDER BY t1.ID, t1.name ASC, t2.ID ASC
</select>
<!-- 检查项目专用分页查询:仅查检查(23) + 定价,无库存/草稿库存/取药科室等无关逻辑 -->
<select id="getExaminationPage" resultType="com.openhis.web.doctorstation.dto.SurgeryItemDto">
SELECT
SELECT DISTINCT ON (t1.ID)
t1.ID AS advice_definition_id,
t1.NAME AS advice_name,
t1.org_id AS org_id,
@@ -917,7 +917,7 @@
<if test="searchKey != null and searchKey != ''">
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
</if>
ORDER BY t1.name ASC
ORDER BY t1.ID, t1.name ASC, t2.ID ASC
</select>
</mapper>

View File

@@ -128,7 +128,7 @@ const emits = defineEmits(['submitOk']);
const props = defineProps({});
const state = reactive({});
const applicationListAll = ref();
const applicationList = ref();
const applicationList = ref([]);
const orgOptions = ref([]); // 科室选项
const loading = ref(false); // 加载状态
const mapToTransferItem = (item) => {
@@ -174,7 +174,9 @@ const loadPage = (key) => {
dbTotal.value = res.data.total || 0;
const records = res.data.records;
applicationListAll.value = records;
applicationList.value = records.map(mapToTransferItem);
applicationList.value = records
.filter(item => item.adviceDefinitionId != null)
.map(mapToTransferItem);
// 仅在无搜索时缓存
if (!key) {
surgeryRecordsCache = records;