From ec62f03acff10564ceac4acc32c4065302d0ee19 Mon Sep 17 00:00:00 2001 From: juzi <819872918@qq.com> Date: Sun, 20 Sep 2026 14:21:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=90=9C=E7=B4=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/menu/index.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index b5163800..7a80aeb9 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -246,6 +246,7 @@ export default { // 查询参数 queryParams: { name: undefined, + status: undefined, visible: undefined }, // 表单参数 @@ -286,10 +287,20 @@ export default { getList() { this.loading = true; listMenu(this.queryParams).then(response => { - this.menuList = this.handleTree(response.data, "id"); + const data = response.data || []; + // 无搜索条件:后端返回全量菜单,可构建成完整树形展示 + // 有搜索条件:后端只返回匹配到的局部数据,父节点可能不在结果集中, + // 此时再走 handleTree 会因父级缺失导致大量数据不显示,故直接平铺展示 + this.menuList = this.isSearching() ? data : this.handleTree(data, "id"); this.loading = false; }); }, + /** 是否存在搜索条件 */ + isSearching() { + const { name, status } = this.queryParams; + const isEmpty = (val) => val === undefined || val === null || val === ''; + return !isEmpty(name) || !isEmpty(status); + }, /** 转换菜单数据结构 */ normalizer(node) { if (node.children && !node.children.length) {