This commit is contained in:
1378012178@qq.com 2025-08-26 18:49:33 +08:00
commit 80d706dc05
1 changed files with 41 additions and 33 deletions

View File

@ -34,19 +34,22 @@
</a-radio-group> </a-radio-group>
</div> </div>
<div v-if="treeLoading" <!-- <div v-if="treeLoading"
style="width: 350px; height: 20vh; display: flex; justify-content: center; align-items: center;"> style="width: 350px; height: 20vh; display: flex; justify-content: center; align-items: center;">
<a-spin tip="加载中..."></a-spin> <a-spin tip="加载中..."></a-spin>
</div> </div> -->
<a-empty v-if="!treeLoading && treeLoading" /> <a-empty v-if="!treeLoading && treeLoading" />
<a-button v-if="!treeLoading && treeData.length < 1" type="link" class="btnPrivate" @click="addInstruction" <a-button v-if="!treeLoading && treeData.length < 1" type="link" class="btnPrivate" @click="addInstruction"
v-show="mainOrgCode == ownOrgCode" preIcon="ant-design:plus-outlined">新增分类标签</a-button> v-show="mainOrgCode == ownOrgCode" preIcon="ant-design:plus-outlined">新增分类标签</a-button>
<a-menu v-model:selectedKeys="selectedKeys" style="width: 100%;margin-top: 50px;" mode="inline" <a-menu
:open-keys="openKeys" @openChange="onOpenChange"> v-model:openKeys="openKeys"
v-model:selectedKeys="selectedKeys"
style="width: 100%;margin-top: 50px;" mode="inline"
@openChange="onOpenChange">
<template v-for="item in treeData"> <template v-for="item in treeData">
<!-- 第一层判断是否有下级 --> <!-- 第一层判断是否有下级 -->
<a-sub-menu v-if="item.children && item.children.length > 0" :key="item.id"> <a-sub-menu v-if="item.children && item.children.length > 0" :key="item.key">
<template #icon> <template #icon>
<Icon :icon="item.icon" :size="20" v-if="item.icon" /> <Icon :icon="item.icon" :size="20" v-if="item.icon" />
<Icon icon="ant-design:appstore-add-outlined" :size="20" v-else /> <Icon icon="ant-design:appstore-add-outlined" :size="20" v-else />
@ -716,34 +719,39 @@ function getDropDownAction(record) {
} }
function expandTreeNodeToLevel4(directiveData: any) { function expandTreeNodeToLevel4(directiveData: any) {
// console.log("🚀 ~ expandTreeNodeToLevel4 ~ directiveData:", directiveData)
expandedKeys.value = [];
//
const findAndExpandNode = (nodes: any[], level: number, directiveData: any) => { selectedKeys.value = [ directiveData.instructionTagId, directiveData.categoryId, directiveData.typeId, directiveData.id ]
for (const node of nodes) { openKeys.value = [ directiveData.instructionTagId, directiveData.categoryId, directiveData.typeId, directiveData.id ]
// level directiveData // //
if (level === 1 && node.instructionId === directiveData.instructionTagId) { // expandedKeys.value = [];
expandedKeys.value.push(node.key); // //
if (node.children && node.children.length > 0) { // const findAndExpandNode = (nodes: any[], level: number, directiveData: any) => {
findAndExpandNode(node.children, 2, directiveData); // for (const node of nodes) {
} // // level directiveData
} else if (level === 2 && node.categoryId === directiveData.categoryId) { // if (level === 1 && node.instructionId === directiveData.instructionTagId) {
expandedKeys.value.push(node.key); // expandedKeys.value.push(node.key);
if (node.children && node.children.length > 0) { // if (node.children && node.children.length > 0) {
findAndExpandNode(node.children, 3, directiveData); // findAndExpandNode(node.children, 2, directiveData);
} // }
} else if (level === 3 && node.typeId === directiveData.typeId) { // } else if (level === 2 && node.categoryId === directiveData.categoryId) {
expandedKeys.value.push(node.key); // expandedKeys.value.push(node.key);
if (node.children && node.children.length > 0) { // if (node.children && node.children.length > 0) {
findAndExpandNode(node.children, 4, directiveData); // findAndExpandNode(node.children, 3, directiveData);
} // }
} else if (level === 4 && node.key === directiveData.id) { // } else if (level === 3 && node.typeId === directiveData.typeId) {
expandedKeys.value.push(node.key); // expandedKeys.value.push(node.key);
} // if (node.children && node.children.length > 0) {
} // findAndExpandNode(node.children, 4, directiveData);
}; // }
// // } else if (level === 4 && node.key === directiveData.id) {
findAndExpandNode(treeData.value, 1, directiveData); // expandedKeys.value.push(node.key);
// }
// }
// };
// //
// findAndExpandNode(treeData.value, 1, directiveData);
} }
/** /**