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); } } },