Skip to content

Commit

Permalink
fix: 修复选择上级菜单过滤失效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Oct 12, 2024
1 parent 5ebdaa0 commit 777f371
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/views/system/menu/MenuAddModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
allow-search
:data="(menuSelectTree as any)"
:fallback-option="false"
:field-names="{
key: 'id',
title: 'title',
children: 'children',
}"
:filter-tree-node="filterOptions"
/>
</a-form-item>
<a-form-item v-if="[1, 2].includes(form.type)" label="菜单图标" field="icon">
Expand Down Expand Up @@ -121,7 +117,7 @@
</template>

<script setup lang="ts">
import { type FormInstance, Message } from '@arco-design/web-vue'
import { type FormInstance, Message, type TreeNodeData } from '@arco-design/web-vue'
import { mapTree } from 'xe-utils'
import { type MenuResp, addMenu, getMenu, updateMenu } from '@/apis/system'
import { useForm } from '@/hooks'
Expand All @@ -143,12 +139,20 @@ const menuSelectTree = computed(() => {
const menus = JSON.parse(JSON.stringify(props.menus)) as MenuResp[]
const data = filterTree(menus, (i) => [1, 2].includes(i.type))
return mapTree(data, (i) => ({
id: i.id,
key: i.id,
title: i.title,
children: i.children
}))
})
// 过滤菜单树
const filterOptions = (searchKey: string, nodeData: TreeNodeData) => {
if (nodeData.title) {
return nodeData.title.toLowerCase().includes(searchKey.toLowerCase())
}
return false
}
const dataId = ref('')
const isUpdate = computed(() => !!dataId.value)
const title = computed(() => (isUpdate.value ? '修改菜单' : '新增菜单'))
Expand Down

0 comments on commit 777f371

Please sign in to comment.