From 4de4d9099e5505fbe4ca7d1dfca6249ded42fc39 Mon Sep 17 00:00:00 2001 From: HuangShun <148689675+huabuweixin@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:56:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D122=20=E9=97=A8=E8=AF=8A?= =?UTF-8?q?=E5=8C=BB=E7=94=9F=E7=AB=99-=E3=80=8B=E5=8C=BB=E5=98=B1TAB?= =?UTF-8?q?=EF=BC=9A=E7=82=B9=E5=87=BB=E9=80=89=E4=B8=AD=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=90=8E=E6=9F=A5=E8=AF=A2=E6=A1=86=E8=87=AA=E5=8A=A8=E5=85=B3?= =?UTF-8?q?=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prescription/prescriptionlist.vue | 73 ++++++++++++++++--- 1 file changed, 62 insertions(+), 11 deletions(-) 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 1f1ef711..3706f18f 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue @@ -1432,6 +1432,14 @@ function handleSkinTestChange(row, index) { row.skinTestFlag_enumText = row.skinTestFlag == 1 ? '是' : '否'; } +/** + * 选择药品回调 + */ +/** + * 延迟函数 + */ +const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms)); + /** * 选择药品回调 */ @@ -1457,30 +1465,72 @@ function selectAdviceBase(key, row) { setNewRow(key, row); } - function setNewRow(key, row) { + async function setNewRow(key, row) { // 每次选择药品时,将当前行数据完全重置,清空所有旧数据 const preservedData = { uniqueKey: prescriptionList.value[rowIndex.value].uniqueKey, isEdit: true, statusEnum: 1, + showPopover: false, // 确保popover关闭 }; // 完全替换整个对象,只保留必要的初始字段 prescriptionList.value[rowIndex.value] = preservedData; setValue(row); + + // 确保在setValue之后再次设置showPopover为false,防止被覆盖 + prescriptionList.value[rowIndex.value].showPopover = false; + expandOrder.value = [key]; - nextTick(() => { - if (row.adviceType == 1) { - if (row.injectFlag == 1) { - inputRefs.value['executeNum']?.focus(); - } else { - inputRefs.value['doseQuantity']?.focus(); - } - } else { - inputRefs.value['quantity']?.focus(); + + // 自动聚焦到单次用量字段 - 使用 async/await 多次尝试 + await nextTick(); + + // 第一次尝试 - 快速定位 + await sleep(300); + focusDoseQuantityInput(row); + + } + + // 聚焦到单次用量输入框的函数 + function focusDoseQuantityInput(row) { + // 找到展开行对应的输入框并聚焦 + const expandedRows = document.querySelectorAll('.el-table__expanded-cell'); + + if (expandedRows.length > 0) { + // 在最后一个展开行中查找输入框 + const lastExpandedRow = expandedRows[expandedRows.length - 1]; + + // 查找doseQuantity输入框(优先) + let targetInput = lastExpandedRow.querySelector('[data-prop="doseQuantity"] .el-input-number__inner'); + + // 如果没找到,尝试其他方式 + if (!targetInput && row.adviceType == 1) { + // 西药的情况:找第一个el-input-number + targetInput = lastExpandedRow.querySelector('.el-input-number__inner'); + } else if (!targetInput) { + // 诊疗/耗材的情况:找quantity输入框 + targetInput = lastExpandedRow.querySelector('[data-prop="quantity"] .el-input-number__inner'); } - }); + + // 最后的备用方案 + if (!targetInput) { + targetInput = lastExpandedRow.querySelector('input:not([disabled]):not([readonly])'); + } + + // 聚焦到输入框 + if (targetInput) { + targetInput.focus(); + // 选中文本,便于用户直接输入 + if (targetInput.select) { + targetInput.select(); + } + return true; + } + } + + return false; } } @@ -2277,6 +2327,7 @@ function setValue(row) { uniqueKey: prescriptionList.value[rowIndex.value].uniqueKey, isEdit: prescriptionList.value[rowIndex.value].isEdit, statusEnum: prescriptionList.value[rowIndex.value].statusEnum, + showPopover: false, // 确保查询框关闭 }; prescriptionList.value[rowIndex.value].orgId = undefined; prescriptionList.value[rowIndex.value].dose = undefined;