mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-15 00:59:21 +08:00
fix: 修复选择上级菜单过滤失效的问题
This commit is contained in:
@@ -27,11 +27,7 @@
|
|||||||
allow-search
|
allow-search
|
||||||
:data="(menuSelectTree as any)"
|
:data="(menuSelectTree as any)"
|
||||||
:fallback-option="false"
|
:fallback-option="false"
|
||||||
:field-names="{
|
:filter-tree-node="filterOptions"
|
||||||
key: 'id',
|
|
||||||
title: 'title',
|
|
||||||
children: 'children',
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item v-if="[1, 2].includes(form.type)" label="菜单图标" field="icon">
|
<a-form-item v-if="[1, 2].includes(form.type)" label="菜单图标" field="icon">
|
||||||
@@ -121,7 +117,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<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 { mapTree } from 'xe-utils'
|
||||||
import { type MenuResp, addMenu, getMenu, updateMenu } from '@/apis/system'
|
import { type MenuResp, addMenu, getMenu, updateMenu } from '@/apis/system'
|
||||||
import { useForm } from '@/hooks'
|
import { useForm } from '@/hooks'
|
||||||
@@ -143,12 +139,20 @@ const menuSelectTree = computed(() => {
|
|||||||
const menus = JSON.parse(JSON.stringify(props.menus)) as MenuResp[]
|
const menus = JSON.parse(JSON.stringify(props.menus)) as MenuResp[]
|
||||||
const data = filterTree(menus, (i) => [1, 2].includes(i.type))
|
const data = filterTree(menus, (i) => [1, 2].includes(i.type))
|
||||||
return mapTree(data, (i) => ({
|
return mapTree(data, (i) => ({
|
||||||
id: i.id,
|
key: i.id,
|
||||||
title: i.title,
|
title: i.title,
|
||||||
children: i.children
|
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 dataId = ref('')
|
||||||
const isUpdate = computed(() => !!dataId.value)
|
const isUpdate = computed(() => !!dataId.value)
|
||||||
const title = computed(() => (isUpdate.value ? '修改菜单' : '新增菜单'))
|
const title = computed(() => (isUpdate.value ? '修改菜单' : '新增菜单'))
|
||||||
|
Reference in New Issue
Block a user