From 9f6e94da4b440ef515cefdd509bdf7939a848f83 Mon Sep 17 00:00:00 2001 From: chenqi Date: Tue, 24 Mar 2026 12:48:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(prescription):=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=A4=84=E6=96=B9=E5=88=97=E8=A1=A8=E4=B8=AD=E7=A7=91=E5=AE=A4?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=92=8C=E6=95=B0=E6=8D=AE=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为科室选择下拉框添加最小宽度样式,确保内容完整显示 - 添加orgTreeLoading状态管理,避免重复加载组织机构树 - 在selectAdviceBase方法中添加异步处理和边界检查逻辑 - 实现诊疗项目默认使用患者就诊科室的逻辑验证 - 修复ensureOrgTreeLoaded方法中的加载状态管理 - 在处方删除操作中添加encounterId和patientId参数传递 - 优化组织机构树查找算法,提升性能表现 --- .../bargain/component/prescriptionlist.vue | 84 ++++++++++++++++--- .../prescription/prescriptionlist.vue | 2 + .../components/tcm/tcmAdvice.vue | 2 + 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue index d0d3eb37..6c3e0d51 100644 --- a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue @@ -135,6 +135,8 @@ value-key="id" check-strictly placeholder="请选择执行科室" + style="min-width: 150px; width: auto;" + class="org-select" /> 总金额:{{ scope.row.totalPrice ? scope.row.totalPrice + ' 元' : '0.00 元' }} @@ -302,6 +304,7 @@ const unitCodeList = ref([]); const adviceTableRef = ref([]); const organization = ref([]); const orgTreeLoaded = ref(false); +const orgTreeLoading = ref(false); const rowRules = ref({ conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }], dose: [{ required: true, message: '请输入单次剂量', trigger: 'change' }], @@ -473,9 +476,9 @@ function handleChange(value) { /** * 选择药品/诊疗项目回调 - * 这里恢复为之前“能正常工作”的简单逻辑,只做最小必要的修正 + * 这里恢复为之前"能正常工作"的简单逻辑,只做最小必要的修正 */ -function selectAdviceBase(key, row) { +async function selectAdviceBase(key, row) { if (!row) { console.error('[selectAdviceBase] row 为空'); return; @@ -491,6 +494,16 @@ function selectAdviceBase(key, row) { rowIndex.value = foundIndex; } + // rowIndex 理论上由 handleFocus 设置;防御一下越界 + if (rowIndex.value < 0 || rowIndex.value >= prescriptionList.value.length) { + const foundIndex = prescriptionList.value.findIndex((item) => item.uniqueKey === key); + if (foundIndex === -1) { + console.error('[selectAdviceBase] 找不到对应行,key =', key); + return; + } + rowIndex.value = foundIndex; + } + // 关闭当前行弹窗 const currentRow = prescriptionList.value[rowIndex.value]; if (currentRow) { @@ -499,7 +512,7 @@ function selectAdviceBase(key, row) { // 诊疗(adviceType=3) 才需要加载执行科室树,且只加载一次 if (row.adviceType === 3) { - ensureOrgTreeLoaded(); + await ensureOrgTreeLoaded(); } // 构建单位列表(保持原有逻辑) @@ -573,11 +586,24 @@ function selectAdviceBase(key, row) { } } else { // 诊疗:设置执行科室和价格 - // 🔧 Bug Fix #238: 如果positionId为空,使用orgId作为默认值 - const rowData = JSON.parse(JSON.stringify(row)); - const selectedPositionId = rowData.positionId; - const selectedOrgId = rowData.orgId; - prescriptionList.value[rowIndex.value].orgId = selectedPositionId || selectedOrgId; + // 🔧 Bug Fix #238: 诊疗项目默认使用患者就诊科室(需确保科室在当前用户权限范围内) + if (!prescriptionList.value[rowIndex.value].orgId && props.patientInfo.orgId) { + // 检查患者就诊科室是否在当前用户的organization树中 + const orgIdStr = String(props.patientInfo.orgId); + const findOrgInTree = (tree, targetId) => { + for (const node of tree) { + if (String(node.id) === targetId) return true; + if (node.children && node.children.length > 0) { + if (findOrgInTree(node.children, targetId)) return true; + } + } + return false; + }; + + if (findOrgInTree(organization.value, orgIdStr)) { + prescriptionList.value[rowIndex.value].orgId = props.patientInfo.orgId; + } + } if (row.priceList && row.priceList.length > 0) { prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price; } else { @@ -603,16 +629,33 @@ function selectAdviceBase(key, row) { } function ensureOrgTreeLoaded() { - if (orgTreeLoaded.value) return; - orgTreeLoaded.value = true; - getOrgTree() + if (orgTreeLoaded.value && organization.value.length > 0) { + return Promise.resolve(); + } + if (orgTreeLoading.value) { + // 如果正在加载中,等待加载完成 + return new Promise((resolve) => { + const timer = setInterval(() => { + if (!orgTreeLoading.value) { + clearInterval(timer); + resolve(); + } + }, 100); + }); + } + orgTreeLoading.value = true; + return getOrgTree() .then((res) => { // 组织机构树接口通常返回分页 records,这里做兼容兜底 organization.value = res?.data?.records ?? res?.data ?? []; + orgTreeLoaded.value = true; }) .catch(() => { // 加载失败时允许重试 orgTreeLoaded.value = false; + }) + .finally(() => { + orgTreeLoading.value = false; }); } @@ -906,4 +949,23 @@ defineExpose({ getListInfo }); .el-table__cell .el-form-item--default { margin-bottom: 0px; } + +/* 🔧 Bug Fix #238: 科室选择框样式,确保内容完整显示 */ +.org-select { + min-width: 150px; + width: auto; + + :deep(.el-select__wrapper) { + min-width: 150px; + } + + :deep(.el-select__selection) { + min-width: 120px; + } + + :deep(.el-select__selected-item) { + max-width: none; + white-space: nowrap; + } +} \ No newline at end of file diff --git a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue index 08c9b9ab..3222adfa 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue @@ -1991,6 +1991,8 @@ function handleDelete() { requestId: deleteItem.requestId, dbOpType: '3', adviceType: deleteItem.adviceType, + encounterId: deleteItem.encounterId, // 🔧 BugFix#219: 添加就诊ID + patientId: deleteItem.patientId, // 🔧 BugFix#219: 添加患者ID }); } } diff --git a/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue b/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue index 05ab55f2..119e582c 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue @@ -981,6 +981,8 @@ function handleDelete(pIndex) { prescriptionNo: deleteItem.prescriptionNo, dbOpType: '3', adviceType: deleteItem.adviceType, + encounterId: deleteItem.encounterId, // 🔧 BugFix#219: 添加就诊ID + patientId: deleteItem.patientId, // 🔧 BugFix#219: 添加患者ID }); } }