1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2025-05-01 14:49:00 +08:00

fix: 修复新增菜单报错并且选中新增的菜单节点

This commit is contained in:
hadeas 2024-04-01 12:36:32 +00:00
parent 0141c0287e
commit 008bed05a9
2 changed files with 5 additions and 2 deletions

View File

@ -22,6 +22,7 @@
:show-irrelevant-nodes="false" :show-irrelevant-nodes="false"
:pattern="pattern" :pattern="pattern"
:data="treeData" :data="treeData"
:selected-keys="[currentMenu?.code]"
:render-prefix="renderPrefix" :render-prefix="renderPrefix"
:render-suffix="renderSuffix" :render-suffix="renderSuffix"
:on-update:selected-keys="onSelect" :on-update:selected-keys="onSelect"

View File

@ -202,15 +202,17 @@ async function onSave() {
await validation() await validation()
okLoading.value = true okLoading.value = true
try { try {
let newFormData
if (!modalForm.value.parentId) modalForm.value.parentId = null if (!modalForm.value.parentId) modalForm.value.parentId = null
if (modalAction.value === 'add') { if (modalAction.value === 'add') {
await api.addPermission(modalForm.value) const res = await api.addPermission(modalForm.value)
newFormData = res.data
} else if (modalAction.value === 'edit') { } else if (modalAction.value === 'edit') {
await api.savePermission(modalForm.value.id, modalForm.value) await api.savePermission(modalForm.value.id, modalForm.value)
} }
okLoading.value = false okLoading.value = false
$message.success('保存成功') $message.success('保存成功')
emit('refresh', modalForm.value) emit('refresh', modalAction.value === 'add' ? newFormData : modalForm.value)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
okLoading.value = false okLoading.value = false