From 02fa679d625a069a3cc88e0be5a5abde48215edf Mon Sep 17 00:00:00 2001 From: zhuguojian <984737666@qq.com> Date: Tue, 24 Dec 2024 11:48:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=8F=9C=E5=8D=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=99=9A=E6=8B=9F=E5=8C=96=E6=A0=91=E5=BD=A2?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/menu/index.vue | 275 +++++++++++++++++++++++++------- 1 file changed, 219 insertions(+), 56 deletions(-) diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index b2c93bbe..82177cf4 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -67,65 +67,87 @@ - - - - - - - - - - - - - - - - + + @@ -155,13 +177,26 @@ const queryParams = reactive({ const queryFormRef = ref() // 搜索的表单 const isExpandAll = ref(false) // 是否展开,默认全部折叠 const refreshTable = ref(true) // 重新渲染表格状态 +const currentNode = ref(null) // 当前选中节点 /** 查询列表 */ const getList = async () => { loading.value = true try { const data = await MenuApi.getMenuList(queryParams) - list.value = handleTree(data) + // 为每个节点添加 showInfo 属性和样式对象 + const addProps = (items: any[]) => { + items.forEach(item => { + item.showInfo = false + item.popupStyle = {} + if (item.children && item.children.length > 0) { + addProps(item.children) + } + }) + } + const processedData = handleTree(data) + addProps(processedData) + list.value = processedData } finally { loading.value = false } @@ -233,8 +268,136 @@ const handleStatusChanged = async (menu: MenuVO, val: number) => { } } +const handleCurrentChange = (data: any) => { + currentNode.value = data + // 关闭所有信息面板 + list.value.forEach((item: any) => { + item.showInfo = false + }) +} + +// 添加点击外部关闭弹出层的处理 +onMounted(() => { + document.addEventListener('click', (event: MouseEvent) => { + const target = event.target as HTMLElement + if (!target.closest('.menu-info-popup') && !target.closest('.info-button')) { + list.value.forEach((item: any) => { + item.showInfo = false + }) + } + }) +}) + /** 初始化 **/ onMounted(() => { getList() }) + + \ No newline at end of file