From ffaf85c8f3c1c86d3c8aef83cc32f035944282ff Mon Sep 17 00:00:00 2001 From: Ken Hai Date: Thu, 21 Aug 2025 15:30:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6VbenTree=E7=BB=84=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=9B=9E=E6=98=BE=E9=80=89=E4=B8=AD=20(#6662)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复角色修改时VbenTree组件没有回显选中 * chore: use nextTick Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: merge * chore: 更新 --------- Co-authored-by: haiyinlong Co-authored-by: Jin Mao <50581550+jinmao88@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- playground/src/views/system/role/modules/form.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/playground/src/views/system/role/modules/form.vue b/playground/src/views/system/role/modules/form.vue index cae54a1c6..e3c1d02dc 100644 --- a/playground/src/views/system/role/modules/form.vue +++ b/playground/src/views/system/role/modules/form.vue @@ -5,7 +5,7 @@ import type { Recordable } from '@vben/types'; import type { SystemRoleApi } from '#/api/system/role'; -import { computed, ref } from 'vue'; +import { computed, nextTick, ref } from 'vue'; import { useVbenDrawer, VbenTree } from '@vben/common-ui'; import { IconifyIcon } from '@vben/icons'; @@ -47,20 +47,26 @@ const [Drawer, drawerApi] = useVbenDrawer({ drawerApi.unlock(); }); }, - onOpenChange(isOpen) { + + async onOpenChange(isOpen) { if (isOpen) { const data = drawerApi.getData(); formApi.resetForm(); + if (data) { formData.value = data; id.value = data.id; - formApi.setValues(data); } else { id.value = undefined; } if (permissions.value.length === 0) { - loadPermissions(); + await loadPermissions(); + } + // Wait for Vue to flush DOM updates (form fields mounted) + await nextTick(); + if (data) { + formApi.setValues(data); } } },