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