Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-operate-sys-cscec
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fulixin
dsk-operate-sys-cscec
Commits
15354a47
Commit
15354a47
authored
Feb 27, 2024
by
tianhongyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生成菜单递归 卡死优化
parent
5165b094
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
23 deletions
+15
-23
index.js
dsk-operate-ui/src/utils/index.js
+9
-17
index.vue
...ectCostLedger/detail/components/ProjectSideMenu/index.vue
+6
-6
No files found.
dsk-operate-ui/src/utils/index.js
View file @
15354a47
...
...
@@ -1064,17 +1064,13 @@ export function findAncestors(data, targetId, idKey = "id", childrenKey = "child
export
function
addTreeLevel
(
tree
,
startLevel
=
1
,
removeEmptyChildren
=
true
)
{
if
(
tree
instanceof
Array
&&
tree
?.
length
)
{
tree
.
forEach
(
node
=>
{
addTreeLevel
(
node
,
startLevel
,
removeEmptyChildren
);
node
[
"level"
]
=
startLevel
;
if
(
node
?.
children
)
{
addTreeLevel
(
node
.
children
,
startLevel
+
1
,
removeEmptyChildren
);
removeEmptyChildren
&&
!
node
.
children
?.
length
?
delete
node
.
children
:
null
;
}
});
}
else
if
(
Object
.
prototype
.
toString
.
call
(
tree
)
==
"[object Object]"
)
{
tree
[
"level"
]
=
startLevel
;
if
(
tree
?.
children
)
{
addTreeLevel
(
tree
.
children
,
startLevel
+
1
,
removeEmptyChildren
);
removeEmptyChildren
&&
!
tree
.
children
?.
length
?
delete
tree
.
children
:
null
;
}
}
return
tree
;
}
...
...
@@ -1086,15 +1082,11 @@ export function addTreeLevel(tree, startLevel = 1, removeEmptyChildren = true) {
export
function
addNodeParent
(
tree
,
parent
=
null
)
{
if
(
tree
instanceof
Array
&&
tree
?.
length
)
{
tree
.
forEach
(
node
=>
{
addNodeParent
(
node
,
parent
);
node
[
"parent"
]
=
parent
?
parent
:
JSON
.
parse
(
JSON
.
stringify
(
parent
));
if
(
node
.
children
instanceof
Array
&&
node
.
children
.
length
)
{
addNodeParent
(
node
.
children
,
node
);
}
});
}
else
if
(
Object
.
prototype
.
toString
.
call
(
tree
)
==
"[object Object]"
)
{
tree
[
"parent"
]
=
JSON
.
parse
(
JSON
.
stringify
(
parent
));
if
(
tree
?.
children
?.
length
)
{
addNodeParent
(
tree
.
children
,
tree
);
}
}
return
tree
;
}
\ No newline at end of file
dsk-operate-ui/src/views/projectCostLedger/detail/components/ProjectSideMenu/index.vue
View file @
15354a47
...
...
@@ -120,12 +120,11 @@ export default {
// 合并默认配置
const
_options
=
this
.
mergeMenuOptions
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
menuOptions
)));
this
.
tempMenuOptions
=
_options
;
console
.
log
(
this
.
tempMenuOptions
);
// 映射配置
//
const resultData = this.mapDataByMenuOptions(JSON.parse(JSON.stringify(this.comMenuTree)), _options);
//
if (resultData) {
//
this.tempMenuTree = resultData;
//
}
const
resultData
=
this
.
mapDataByMenuOptions
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
comMenuTree
)),
_options
);
if
(
resultData
)
{
this
.
tempMenuTree
=
resultData
;
}
}
},
mergeMenuOptions
(
options
)
{
...
...
@@ -188,7 +187,8 @@ export default {
// 添加层级
const
levelResult
=
addTreeLevel
(
mapedData
);
const
parentResult
=
addNodeParent
(
levelResult
);
return
parentResult
;
console
.
log
(
parentResult
);
// return parentResult;
}
}
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment