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
343eecbc
Commit
343eecbc
authored
Mar 05, 2024
by
tyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix ,菜单默认打开二级目录
parent
a8e212cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
9 deletions
+47
-9
index.vue
.../projectCostLedger/detail/components/DirectCost/index.vue
+1
-1
ProjectMenuItem.vue
...ger/detail/components/ProjectSideMenu/ProjectMenuItem.vue
+1
-1
index.vue
...ectCostLedger/detail/components/ProjectSideMenu/index.vue
+45
-7
No files found.
dsk-operate-ui/src/views/projectCostLedger/detail/components/DirectCost/index.vue
View file @
343eecbc
...
...
@@ -158,7 +158,7 @@ export default {
menuDetails
:{},
menuOptions
:
{
nodeName
:
"menuName"
,
nodeValue
:
"menu
Name
"
,
nodeValue
:
"menu
Id
"
,
children
:
"childrenList"
},
detailsId
:
''
,
...
...
dsk-operate-ui/src/views/projectCostLedger/detail/components/ProjectSideMenu/ProjectMenuItem.vue
View file @
343eecbc
...
...
@@ -15,7 +15,7 @@
</div>
</
template
>
<!-- 子集递归 -->
<project-menu-item
v-for=
"(child,index) of menuItem.children"
:menuItem=
"child"
:key=
"
child.nodeValue
"
></project-menu-item>
<project-menu-item
v-for=
"(child,index) of menuItem.children"
:menuItem=
"child"
:key=
"
`${child.nodeValue}-${child.level}`
"
></project-menu-item>
</el-submenu>
</template>
<!-- 无子集菜单 -->
...
...
dsk-operate-ui/src/views/projectCostLedger/detail/components/ProjectSideMenu/index.vue
View file @
343eecbc
<
template
>
<div
class=
"project-side-menu-container"
>
<el-menu
mode=
"vertical"
class=
"project-side-menu-instance"
:unique-opened=
"uniqueOpened"
:default-active=
"createMenuIndex(comDefaultActive)"
@
select=
"menuSelect"
@
open=
"subMenuOpen"
@
close=
"subMenuClose"
ref=
"customElMenu"
>
:default-openeds=
"comDefaultOpeneds"
@
select=
"menuSelect"
@
open=
"subMenuOpen"
@
close=
"subMenuClose"
ref=
"customElMenu"
>
<template
v-for=
"(item,index) of tempMenuTree"
>
<project-menu-item
:menuItem=
"item"
:key=
"
item.nodeValue
"
>
<project-menu-item
:menuItem=
"item"
:key=
"
`$
{item.nodeValue}-${item.level}`
">
<template
:slot=
"`$
{item.nodeName}-${item.level}`" slot-scope="scope">
<slot
:name=
"`$
{scope.data.nodeName}-${scope.data.level}`" :data="scope.data">
</slot>
</
template
>
...
...
@@ -46,6 +46,11 @@ export default {
defaultActive
:
{
type
:
[
String
,
Number
],
default
:
""
},
// 默认展开的二级菜单
defaultOpeneds
:
{
type
:
Array
,
default
:
()
=>
[]
}
},
watch
:
{
...
...
@@ -61,6 +66,11 @@ export default {
handler
(
newValue
)
{
this
.
comDefaultActive
=
newValue
;
}
},
defaultOpeneds
:
{
handler
(
newValue
)
{
this
.
comDefaultOpeneds
=
newValue
?
newValue
:
[];
}
}
},
data
()
{
...
...
@@ -75,12 +85,13 @@ export default {
tempMenuOptions
:
{},
tempMenuTree
:
[],
comMenuTree
:
this
.
menuTree
,
comDefaultActive
:
this
.
defaultActive
comDefaultActive
:
this
.
defaultActive
,
comDefaultOpeneds
:
this
.
defaultOpeneds
};
},
//可访问data属性
created
()
{
this
.
openTargetAllSubMenu
(
this
.
comDefaultOpeneds
);
},
//计算集
computed
:
{
...
...
@@ -91,8 +102,33 @@ export default {
//方法集
methods
:
{
// 展开所有指定层级的菜单 默认二级
openTargetAllSubMenu
()
{
openTargetAllSubMenu
(
openeds
=
[],
level
=
2
)
{
// 组件外传入了值 使用传入值,否则默认获取二级菜单打开二级
if
(
openeds
instanceof
Array
&&
openeds
.
length
)
{
// 转换为字符串
this
.
comDefaultOpeneds
=
openeds
.
map
(
item
=>
this
.
createMenuIndex
(
item
));
}
else
{
// 递归查找当前二级目录index
const
_tempTree
=
this
.
tempMenuTree
;
const
result
=
this
.
findTargetLevelIndex
(
_tempTree
,
2
,
[]);
this
.
comDefaultOpeneds
=
result
;
}
},
findTargetLevelIndex
(
data
=
[],
level
=
2
,
result
=
[])
{
if
(
data
.
length
)
{
for
(
const
item
of
data
)
{
// level大于传入level直接跳出循环
if
(
item
.
level
>
level
)
break
;
// 确保打开菜单为目录
if
(
item
.
level
<=
level
&&
item
.
children
instanceof
Array
)
{
result
.
push
(
item
.
nodeValue
);
}
if
(
item
.
children
instanceof
Array
&&
item
.
children
.
length
)
{
this
.
findTargetLevelIndex
(
item
.
children
,
level
,
result
);
}
}
}
return
result
.
map
(
item
=>
this
.
createMenuIndex
(
item
));
},
// 事件订阅
subMenuOpen
(
menuPath
,
menuPathArray
)
{
...
...
@@ -130,7 +166,7 @@ export default {
return
null
;
},
// 初始化树形结构
initMenuTree
(
array
=
[])
{
async
initMenuTree
(
array
=
[])
{
if
(
array
?.
length
)
{
// 合并默认配置
const
_options
=
this
.
mergeMenuOptions
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
menuOptions
)));
...
...
@@ -139,6 +175,8 @@ export default {
const
resultData
=
this
.
mapDataByMenuOptions
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
comMenuTree
)),
_options
);
if
(
resultData
)
{
this
.
tempMenuTree
=
resultData
;
await
this
.
$nextTick
();
this
.
openTargetAllSubMenu
(
this
.
comDefaultOpeneds
);
}
}
},
...
...
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