diff --git a/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/components/prescriptionList.vue b/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/components/prescriptionList.vue index 99b7bbbd..05d74322 100755 --- a/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/components/prescriptionList.vue +++ b/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/components/prescriptionList.vue @@ -68,9 +68,7 @@ - - -
@@ -232,7 +230,7 @@ import {adviceCancel, adviceExecute, adviceNoExecute, getPrescriptionList} from import {patientInfoList} from '../../components/store/patient.js'; import {lotNumberMatch} from '@/api/public'; import {formatDateStr} from '@/utils/index'; -import {getCurrentInstance, nextTick, ref} from 'vue'; +import {getCurrentInstance, nextTick, ref, provide} from 'vue'; const activeNames = ref([]); const prescriptionList = ref([]); @@ -242,6 +240,8 @@ const therapyEnum = ref(undefined); const { proxy } = getCurrentInstance(); const loading = ref(false); const chooseAll = ref(false); +// 独立维护选中行ID集合,避免el-table内部selection状态异常导致联动全选 +const selectedRowIds = ref(new Set()); const props = defineProps({ exeStatus: { type: Number, @@ -442,6 +442,7 @@ function handleGetPrescription() { chooseAll.value = false; } else { prescriptionList.value = []; + selectedRowIds.value.clear(); // proxy.$message.warning('请选择患者'); } } @@ -530,10 +531,14 @@ function handleCancel() { } function getSelectRows() { - // 获取选中的医嘱信息 - let list = []; - prescriptionList.value.forEach((item, index) => { - list = [...list, ...proxy.$refs['tableRef' + index][0].getSelectionRows()]; + // 优先从独立维护的selectedRowIds集合中获取选中行,避免el-table内部selection状态异常 + const list = []; + prescriptionList.value.forEach((item) => { + item.forEach((row) => { + if (selectedRowIds.value.has(row.requestId)) { + list.push(row); + } + }); }); return list; } @@ -609,12 +614,14 @@ function handelSwicthChange(value) { if (value) { // 全选:选中所有行并联动checkbox item.forEach((row) => { + selectedRowIds.value.add(row.requestId); tableRef[0].toggleRowSelection(row, true); selectAllCheckboxesInRow(row); }); } else { // 取消全选:取消选中所有行并联动checkbox item.forEach((row) => { + selectedRowIds.value.delete(row.requestId); tableRef[0].toggleRowSelection(row, false); unselectAllCheckboxesInRow(row); }); @@ -625,11 +632,14 @@ function handelSwicthChange(value) { // 默认选中全部行 function defaultSelectAllRows() { + // 清空并重建选中集合 + selectedRowIds.value.clear(); prescriptionList.value.forEach((item, index) => { const tableRef = proxy.$refs['tableRef' + index]; if (tableRef && tableRef[0]) { // 选中该表格的所有行 item.forEach((row) => { + selectedRowIds.value.add(row.requestId); tableRef[0].toggleRowSelection(row, true); // 同时选中该行内部的所有checkbox selectAllCheckboxesInRow(row); @@ -709,13 +719,14 @@ function checkAndToggleRowSelection(row) { const tableRef = proxy.$refs['tableRef' + tableIndex]; if (tableRef && tableRef[0]) { const isAllSelected = isAllCheckboxesSelected(row); - const selectedRows = tableRef[0].getSelectionRows(); - const isCurrentlySelected = selectedRows.some((r) => r.requestId === row.requestId); + const isCurrentlySelected = selectedRowIds.value.has(row.requestId); // 根据checkbox状态更新表格行选中状态 if (isAllSelected && !isCurrentlySelected) { + selectedRowIds.value.add(row.requestId); tableRef[0].toggleRowSelection(row, true); } else if (!isAllSelected && isCurrentlySelected) { + selectedRowIds.value.delete(row.requestId); tableRef[0].toggleRowSelection(row, false); } } @@ -728,9 +739,11 @@ function handleRowSelect(selection, row, tableIndex) { const isSelected = selection.some((item) => item.requestId === row.requestId); if (isSelected) { + selectedRowIds.value.add(row.requestId); // 选中行时,选中该行内部的所有checkbox selectAllCheckboxesInRow(row); } else { + selectedRowIds.value.delete(row.requestId); // 取消选中行时,取消选中该行内部的所有checkbox unselectAllCheckboxesInRow(row); } @@ -747,11 +760,13 @@ function handleSelectAll(selection, tableIndex) { if (selection.length > 0) { // 全选时,选中所有行内部的所有checkbox tableData.forEach((row) => { + selectedRowIds.value.add(row.requestId); selectAllCheckboxesInRow(row); }); } else { // 取消全选时,取消选中所有行内部的所有checkbox tableData.forEach((row) => { + selectedRowIds.value.delete(row.requestId); unselectAllCheckboxesInRow(row); }); } @@ -763,16 +778,12 @@ function handleSelectAll(selection, tableIndex) { // 更新全选开关状态 function updateChooseAllStatus() { let allSelected = true; - prescriptionList.value.forEach((item, index) => { - const tableRef = proxy.$refs['tableRef' + index]; - if (tableRef && tableRef[0]) { - const selectedRows = tableRef[0].getSelectionRows(); - if (selectedRows.length !== item.length) { + prescriptionList.value.forEach((item) => { + item.forEach((row) => { + if (!selectedRowIds.value.has(row.requestId)) { allSelected = false; } - } else { - allSelected = false; - } + }); }); chooseAll.value = allSelected; } diff --git a/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/index.vue b/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/index.vue index 54c36670..905890e4 100755 --- a/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/index.vue +++ b/openhis-ui-vue3/src/views/inpatientNurse/medicalOrderExecution/index.vue @@ -51,7 +51,7 @@