feat: 优化分组表单

This commit is contained in:
tbphp
2025-07-23 15:39:40 +08:00
parent f4774eb399
commit 5e909b34df
3 changed files with 487 additions and 123 deletions

View File

@@ -61,10 +61,22 @@ function openCreateGroupModal() {
showGroupModal.value = true;
}
function handleGroupCreated() {
function handleGroupCreated(_group: Group) {
showGroupModal.value = false;
emit("refresh");
}
function handleSwitchToGroup(groupId: number) {
// 创建成功后,等待列表刷新完成,然后切换到新创建的分组
emit("refresh");
// 延迟选择新分组,确保列表已更新
setTimeout(() => {
const newGroup = props.groups.find(g => g.id === groupId);
if (newGroup) {
emit("group-select", newGroup);
}
}, 100);
}
</script>
<template>
@@ -123,7 +135,11 @@ function handleGroupCreated() {
</n-button>
</div>
</n-card>
<group-form-modal v-model:show="showGroupModal" @success="handleGroupCreated" />
<group-form-modal
v-model:show="showGroupModal"
@success="handleGroupCreated"
@switch-to-group="handleSwitchToGroup"
/>
</div>
</template>