update 文档拆分详情树节点模糊查询

This commit is contained in:
赵霄
2023-09-22 13:56:49 +08:00
parent dee6e28a33
commit f05229c835
3 changed files with 12 additions and 45 deletions
@@ -6,9 +6,7 @@
<a-input-search class="tree-search" v-model="searchValue" :placeholder="$t('nodeQuickLookup')" @search="onSearch" />
<div class="page-tree-box page-tree-box-has-search">
<a-spin :spinning="loading">
<a-tree :show-line="true" :show-icon="false" :tree-data="treeData"
:replace-fields="{key: 'id', title: 'name'}" :selected-keys="selectedKeys">
<a-tree :show-line="true" :show-icon="true" :tree-data="treeData" :selected-keys="selectedKeys">
<template #title="record">
<div class="tree-operate-node"
@mouseenter="handleTreeMouseover(record.id)"
@@ -328,50 +326,19 @@ export default {
// 获取左侧目录数据
loadMenuData () {
const params = {
infoId: this.infoId
infoId: this.infoId,
name: this.searchValue
}
this.loading = true
getClauseTreeData(params).then(res => {
if (res.success) {
this.data = this.toTree(res.result)
this.treeData = [...this.data]
// this.treeData = res.result || []
this.treeData = res.result || []
console.log(this.treeData)
}
}).finally(() => {
this.loading = false
})
},
// 将数据拼成树形结构
toTree (config) {
// 删除 所有 children,以防止多次调用
config.forEach(function (item) {
delete item.children
})
// 将数据存储为 以 id 为 KEY 的 map 索引数据列
const map = {}
config.forEach((item) => {
if (!item.name) {
item.name = ''
}
item.label = item.name
item.key = item.id
item.title = item.name + (item.itemName ? ' ' + item.itemName : '')
map[item.id] = item
})
const val = []
config.forEach((item) => {
// 以当前遍历项,的pid,去map对象中找到索引的id
const parent = map[item.pid]
// 如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
if (parent) {
(parent.children || (parent.children = [])).push(item)
} else {
// 如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级
val.push(item)
}
})
return val
},
// 用于点击空白处隐藏增删改菜单
clearMenu () {
this.nodeTreeItem = null
@@ -553,7 +520,7 @@ export default {
this.loadMenuData()
},
onSearch () {
this.loadMenuData()
}
},
beforeDestroy () {