Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-gjjs
Overview
Overview
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
zhouqian
vue-gjjs
Commits
0377f18c
Commit
0377f18c
authored
Dec 24, 2021
by
潘际乾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
菜单栏问题修复、支持多层
parent
aaae98b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
113 deletions
+86
-113
SubMenu.vue
src/components/SubMenu.vue
+23
-15
SideMenu.vue
src/views/Layout/SideMenu.vue
+63
-98
No files found.
src/components/SubMenu.vue
View file @
0377f18c
<
template
>
<
template
>
<div>
<div>
<template
v-for=
"(item
, index
) in subMenuList"
>
<template
v-for=
"(item) in subMenuList"
>
<el-submenu
<el-submenu
v-if=
"item.children && item.children.length > 0"
v-if=
"item.children && item.children.length > 0"
:key=
"item.
path + '_' +
index"
:key=
"item.index"
:index=
"item.path + '_' +
index"
:index=
"item.
index"
>
>
<template
slot=
"title"
>
<template
slot=
"title"
>
<i
class=
"el-icon-caret-right"
v-if=
"openFlgArr[index]"
></i>
<i
<i
class=
"el-icon-caret-bottom"
v-else
></i>
class=
"el-icon-caret-bottom"
v-if=
"getOpenFlag(item.index)"
></i>
<i
class=
"el-icon-caret-right"
v-else
></i>
<!--
<img
:src=
"item.icon"
alt=
""
>
-->
<!--
<img
:src=
"item.icon"
alt=
""
>
-->
<span>
{{
item
.
name
}}
</span>
<span>
{{
item
.
name
}}
</span>
</
template
>
</
template
>
<SubMenu
:subMenuList=
"item.children"
/>
<SubMenu
:subMenuList=
"item.children"
:openFlgArr=
"openFlgArr"
/>
</el-submenu>
</el-submenu>
<el-menu-item
v-else
:key=
"item.path"
:index=
"item.path"
>
<el-menu-item
v-else
:key=
"item.path"
:index=
"item.path"
>
<
template
slot=
"title"
>
<
template
slot=
"title"
>
...
@@ -28,19 +31,24 @@
...
@@ -28,19 +31,24 @@
import
SubMenu
from
"./SubMenu.vue"
;
import
SubMenu
from
"./SubMenu.vue"
;
export
default
{
export
default
{
name
:
"SubMenu"
,
name
:
"SubMenu"
,
components
:
{
SubMenu
},
components
:
{
SubMenu
},
props
:
[
'subMenuList'
,
'openFlgArr'
],
props
:
[
"subMenuList"
,
"openFlgArr"
],
methods
:
{
getOpenFlag
(
index
)
{
return
this
.
openFlgArr
.
includes
(
index
);
},
},
};
};
</
script
>
</
script
>
<
style
>
<
style
>
.el-menu--collapse
>
div
>
.el-menu-item
span
,
.el-menu--collapse
>
div
>
.el-menu-item
span
,
.el-menu--collapse
>
div
>
.el-submenu
>
.el-submenu__title
span
{
.el-menu--collapse
>
div
>
.el-submenu
>
.el-submenu__title
span
{
height
:
0
;
height
:
0
;
width
:
0
;
width
:
0
;
overflow
:
hidden
;
overflow
:
hidden
;
visibility
:
hidden
;
visibility
:
hidden
;
display
:
inline-block
;
display
:
inline-block
;
}
}
</
style
>
</
style
>
src/views/Layout/SideMenu.vue
View file @
0377f18c
...
@@ -7,15 +7,9 @@
...
@@ -7,15 +7,9 @@
@
click=
"closeMenu"
@
click=
"closeMenu"
></c-button>
></c-button>
<c-button
icon=
"el-icon-s-unfold"
v-else
@
click=
"openMenu"
></c-button>
<c-button
icon=
"el-icon-s-unfold"
v-else
@
click=
"openMenu"
></c-button>
<!--
<c-input
prefix-icon=
"el-icon-search"
v-if=
"menuOpen"
v-model=
"searchContent"
@
keyup
.
enter
.
native=
"searchMenuEvent"
placeholder=
"全局搜索"
></c-input>
-->
<c-search-input
v-show=
"menuOpen"
></c-search-input>
<c-search-input
v-show=
"menuOpen"
></c-search-input>
</div>
</div>
<c-content
:height=
"250"
>
<c-content
:height=
"250"
>
<!--
<img
src=
"../../assets/menu_bottom.png"
style=
"position: fixed; width: 200px; bottom: 0"
/>
-->
<el-menu
<el-menu
:default-active=
"activeMenu"
:default-active=
"activeMenu"
class=
"el-menu-vertical-demo"
class=
"el-menu-vertical-demo"
...
@@ -24,10 +18,6 @@
...
@@ -24,10 +18,6 @@
@
close=
"handleClose"
@
close=
"handleClose"
:collapse=
"!menuOpen"
:collapse=
"!menuOpen"
>
>
<!--
<el-menu-item
index=
"/business/office"
>
<i
class=
"el-icon-menu"
></i>
<span
slot=
"title"
>
主页
</span>
</el-menu-item>
-->
<SubMenu
:subMenuList=
"menus"
:openFlgArr=
"openFlgArr"
></SubMenu>
<SubMenu
:subMenuList=
"menus"
:openFlgArr=
"openFlgArr"
></SubMenu>
</el-menu>
</el-menu>
</c-content>
</c-content>
...
@@ -39,18 +29,17 @@ import SubMenu from "~/components/SubMenu.vue";
...
@@ -39,18 +29,17 @@ import SubMenu from "~/components/SubMenu.vue";
export
default
{
export
default
{
components
:
{
Button
,
SubMenu
},
components
:
{
Button
,
SubMenu
},
data
:
function
()
{
data
:
function
()
{
return
{
return
{
recordIndext
:
''
,
openFlgArr
:
[],
openFlgArr
:
[],
openFlgArrCopy
:
[],
menuOpen
:
true
,
menuOpen
:
true
,
searchContent
:
""
,
menuList
:
[
menuList
:
[
// { inifrm: "0", ininam: "公共夹", pntmiu: "" },
// { inifrm: "0", ininam: "公共夹", pntmiu: "" },
// { inifrm: "sptsel", ininam: "待办任务", pntmiu: "0" },
// { inifrm: "sptsel", ininam: "待办任务", pntmiu: "0" },
// { inifrm: "trnrel", ininam: "复核任务", pntmiu: "0" },
// { inifrm: "trnrel", ininam: "复核任务", pntmiu: "0" },
// { inifrm: "diasel", ininam: "备忘录选择交易", pntmiu: "0" },
// { inifrm: "diasel", ininam: "备忘录选择交易", pntmiu: "0" },
{
inifrm
:
"1"
,
ininam
:
"汇款"
,
pntmiu
:
""
},
{
inifrm
:
"1"
,
ininam
:
"汇款"
,
pntmiu
:
""
},
{
inifrm
:
"infcpd"
,
ininam
:
"汇款查询"
,
pntmiu
:
"1"
},
{
inifrm
:
"infcpd"
,
ininam
:
"汇款查询"
,
pntmiu
:
"1"
},
{
inifrm
:
"cptopn"
,
ininam
:
"汇出汇款"
,
pntmiu
:
"1"
},
{
inifrm
:
"cptopn"
,
ininam
:
"汇出汇款"
,
pntmiu
:
"1"
},
{
inifrm
:
"cptadv"
,
ininam
:
"汇入汇款"
,
pntmiu
:
"1"
},
{
inifrm
:
"cptadv"
,
ininam
:
"汇入汇款"
,
pntmiu
:
"1"
},
...
@@ -83,25 +72,30 @@ export default {
...
@@ -83,25 +72,30 @@ export default {
{
inifrm
:
"infbpd"
,
ininam
:
"进口单据查询"
,
pntmiu
:
"4"
},
{
inifrm
:
"infbpd"
,
ininam
:
"进口单据查询"
,
pntmiu
:
"4"
},
{
inifrm
:
"inftxm"
,
ininam
:
"条式语句查询"
,
pntmiu
:
"4"
},
{
inifrm
:
"inftxm"
,
ininam
:
"条式语句查询"
,
pntmiu
:
"4"
},
{
inifrm
:
"5"
,
ininam
:
"进口代收"
,
pntmiu
:
""
},
{
inifrm
:
"5"
,
ininam
:
"进口代收"
,
pntmiu
:
""
},
{
inifrm
:
"bctdav"
,
ininam
:
"进口代收"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctdav"
,
ininam
:
"进口代收"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctame"
,
ininam
:
"进口代收修改"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctame"
,
ininam
:
"进口代收修改"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctacc"
,
ininam
:
"进口代收承兑"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctacc"
,
ininam
:
"进口代收承兑"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctdor"
,
ininam
:
"进口代收拒付"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctdor"
,
ininam
:
"进口代收拒付"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctset"
,
ininam
:
"进口代收付款"
,
pntmiu
:
"5"
},
{
inifrm
:
"bctset"
,
ininam
:
"进口代收付款"
,
pntmiu
:
"5"
},
{
inifrm
:
"6"
,
ininam
:
"出口托收"
,
pntmiu
:
""
},
{
inifrm
:
"6"
,
ininam
:
"出口托收"
,
pntmiu
:
""
},
{
inifrm
:
"botdav"
,
ininam
:
"出口托收寄单"
,
pntmiu
:
"6"
},
{
inifrm
:
"botdav"
,
ininam
:
"出口托收寄单"
,
pntmiu
:
"6"
},
{
inifrm
:
"botame"
,
ininam
:
"出口托收修改"
,
pntmiu
:
"6"
},
{
inifrm
:
"botame"
,
ininam
:
"出口托收修改"
,
pntmiu
:
"6"
},
{
inifrm
:
"botdcr"
,
ininam
:
"出口托收拒付/不符点"
,
pntmiu
:
"6"
},
{
inifrm
:
"botdcr"
,
ininam
:
"出口托收拒付/不符点"
,
pntmiu
:
"6"
},
{
inifrm
:
"botset"
,
ininam
:
"出口托收收汇"
,
pntmiu
:
"6"
},
{
inifrm
:
"botset"
,
ininam
:
"出口托收收汇"
,
pntmiu
:
"6"
},
{
inifrm
:
"botcan"
,
ininam
:
"出口托收闭卷"
,
pntmiu
:
"6"
},
{
inifrm
:
"botcan"
,
ininam
:
"出口托收闭卷"
,
pntmiu
:
"6"
},
{
inifrm
:
"7"
,
ininam
:
"静态参数管理"
,
pntmiu
:
""
,
},
{
inifrm
:
"7"
,
ininam
:
"静态参数管理"
,
pntmiu
:
""
},
{
inifrm
:
"infusr"
,
ininam
:
"用户信息"
,
pntmiu
:
"7"
},
{
inifrm
:
"infusr"
,
ininam
:
"用户信息"
,
pntmiu
:
"7"
},
{
inifrm
:
"8"
,
ininam
:
"转让证"
,
pntmiu
:
""
},
{
inifrm
:
"8"
,
ininam
:
"转让证"
,
pntmiu
:
""
},
{
inifrm
:
"lttopn"
,
ininam
:
"转让证开立"
,
pntmiu
:
"8"
},
{
inifrm
:
"lttopn"
,
ininam
:
"转让证开立"
,
pntmiu
:
"8"
},
{
inifrm
:
"lttame"
,
ininam
:
"转让证修改"
,
pntmiu
:
"8"
},
{
inifrm
:
"lttame"
,
ininam
:
"转让证修改"
,
pntmiu
:
"8"
},
{
inifrm
:
"lttcan"
,
ininam
:
"转让证注销"
,
pntmiu
:
"8"
},
{
inifrm
:
"lttcan"
,
ininam
:
"转让证注销"
,
pntmiu
:
"8"
},
{
inifrm
:
"aaaaaa"
,
ininam
:
"你你你你"
,
pntmiu
:
"8"
},
{
inifrm
:
"bbbbbb"
,
ininam
:
"我我我我"
,
pntmiu
:
"aaaaaa"
},
{
inifrm
:
"cccccc"
,
ininam
:
"他他他他"
,
pntmiu
:
"bbbbbb"
},
{
inifrm
:
"dddddd"
,
ininam
:
"她她她她"
,
pntmiu
:
"bbbbbb"
},
{
inifrm
:
"eeeeee"
,
ininam
:
"EEEEEEE"
,
pntmiu
:
"aaaaaa"
},
{
inifrm
:
"ffffff"
,
ininam
:
"FFFFFFF"
,
pntmiu
:
"eeeeee"
},
],
],
menusOrigin
:
[],
menus
:
[],
menus
:
[],
};
};
},
},
...
@@ -113,69 +107,14 @@ export default {
...
@@ -113,69 +107,14 @@ export default {
mounted
()
{
mounted
()
{
const
arr
=
[];
const
arr
=
[];
this
.
generateMenuTree
(
arr
);
this
.
generateMenuTree
(
arr
);
this
.
menusOrigin
=
arr
;
this
.
menus
=
arr
;
this
.
menus
=
this
.
menusOrigin
;
this
.
initOpenFlgIndex
();
this
.
openFlgArr
=
new
Array
(
this
.
menus
.
length
).
fill
(
true
)
},
},
methods
:
{
methods
:
{
searchMenuEvent
()
{
if
(
this
.
searchContent
.
trim
()
===
""
)
{
this
.
menus
=
this
.
menusOrigin
;
return
;
}
const
res
=
[];
for
(
let
i
=
0
;
i
<
this
.
menusOrigin
.
length
;
i
++
)
{
const
menu
=
this
.
menusOrigin
[
i
];
const
r
=
this
.
eachItem
(
menu
);
if
(
r
!==
null
)
{
res
.
push
(
r
);
}
}
this
.
menus
=
res
;
},
eachItem
(
item
)
{
if
(
item
.
name
.
indexOf
(
this
.
searchContent
)
>
-
1
)
{
// if (item.children.length > 0) {
// if (this.hasAvailableChild(item.children)) {
// return item;
// }
// return null;
// } else {
// // TODO 判断此处是否为叶子节点
// return item;
// }
return
item
;
}
const
arr
=
[];
for
(
let
i
=
0
;
i
<
item
.
children
.
length
;
i
++
)
{
const
child
=
item
.
children
[
i
];
const
r
=
this
.
eachItem
(
child
);
if
(
r
!==
null
)
{
arr
.
push
(
r
);
}
}
if
(
arr
.
length
>
0
)
{
return
{
name
:
item
.
name
,
path
:
item
.
path
,
icon
:
item
.
icon
,
children
:
arr
,
};
}
return
null
;
},
hasAvailableChild
(
children
)
{
for
(
let
i
=
0
;
i
<
children
.
length
;
i
++
)
{
const
child
=
children
.
length
[
i
];
if
(
child
.
children
.
length
>
0
)
{
return
this
.
hasAvailableChild
(
child
.
children
);
}
else
{
// TODO 判断此处是否为叶子节点
return
true
;
}
}
},
generateMenuTree
(
list
,
item
)
{
generateMenuTree
(
list
,
item
)
{
const
cc
=
[],
c
=
[];
let
n
=
0
;
for
(
let
i
=
0
;
i
<
this
.
menuList
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
menuList
.
length
;
i
++
)
{
const
menuItem
=
this
.
menuList
[
i
];
const
menuItem
=
this
.
menuList
[
i
];
if
(
!
item
)
{
if
(
!
item
)
{
...
@@ -183,55 +122,82 @@ export default {
...
@@ -183,55 +122,82 @@ export default {
const
children
=
[];
const
children
=
[];
menuItem
.
path
=
"/business"
;
menuItem
.
path
=
"/business"
;
this
.
generateMenuTree
(
children
,
menuItem
);
this
.
generateMenuTree
(
children
,
menuItem
);
list
.
push
(
{
const
child
=
{
name
:
menuItem
.
ininam
,
name
:
menuItem
.
ininam
,
path
:
menuItem
.
path
,
path
:
menuItem
.
path
,
children
,
children
,
});
};
if
(
children
.
length
>
0
)
{
child
[
"index"
]
=
child
.
path
+
"_"
+
n
++
;
cc
.
push
(
child
);
}
else
{
c
.
push
(
child
);
}
}
}
}
else
{
}
else
{
if
(
menuItem
.
pntmiu
===
item
.
inifrm
)
{
if
(
menuItem
.
pntmiu
===
item
.
inifrm
)
{
const
children
=
[];
const
children
=
[];
menuItem
.
path
=
item
.
path
+
"/"
+
menuItem
.
inifrm
;
menuItem
.
path
=
item
.
path
+
"/"
+
menuItem
.
inifrm
;
this
.
generateMenuTree
(
children
,
menuItem
);
this
.
generateMenuTree
(
children
,
menuItem
);
list
.
push
(
{
const
child
=
{
name
:
menuItem
.
ininam
,
name
:
menuItem
.
ininam
,
path
:
menuItem
.
path
,
path
:
menuItem
.
path
,
icon
:
"el-icon-document"
,
icon
:
"el-icon-document"
,
children
,
children
,
});
};
if
(
children
.
length
>
0
)
{
child
[
"index"
]
=
child
.
path
+
"_"
+
n
++
;
cc
.
push
(
child
);
}
else
{
c
.
push
(
child
);
}
}
}
}
}
}
}
list
.
push
(...
cc
,
...
c
);
},
},
handleOpen
(
index
,
indexPath
)
{
handleOpen
(
index
,
indexPath
)
{
// console.log(index, indexPath);
// console.log(index, indexPath);
this
.
$set
(
this
.
openFlgArr
,
index
.
split
(
"_"
)[
1
],
false
)
const
arr
=
Object
.
assign
([],
this
.
openFlgArr
);
this
.
recordIndext
=
index
.
split
(
"_"
)[
1
]
arr
.
push
(
index
);
this
.
openFlgArr
=
arr
;
},
},
handleClose
(
index
,
indexPath
)
{
handleClose
(
index
,
indexPath
)
{
// console.log(index, indexPath);
// console.log(index, indexPath);
this
.
$set
(
this
.
openFlgArr
,
index
.
split
(
"_"
)[
1
],
true
)
const
arr
=
Object
.
assign
([],
this
.
openFlgArr
);
this
.
openFlgArr
=
arr
.
filter
((
idx
)
=>
idx
!==
index
);
},
},
openMenu
()
{
openMenu
()
{
this
.
menuOpen
=
true
;
this
.
menuOpen
=
true
;
const
aside
=
document
.
querySelector
(
"aside"
);
const
aside
=
document
.
querySelector
(
"aside"
);
aside
.
className
=
aside
.
className
.
split
(
" "
)[
0
];
aside
.
className
=
aside
.
className
.
split
(
" "
)[
0
];
// if(){
this
.
initOpenFlgIndex
();
// this.openFlgArr = new Array(this.menus.length).fill(true);
},
// this.$set(this.openFlgArr,this.recordIndext , false)
initOpenFlgIndex
()
{
// }else{
const
r
=
[];
// this.openFlgArr = new Array(this.menus.length).fill(true);
this
.
getOpenMenusIndex
(
this
.
menus
,
r
);
// }
this
.
openFlgArr
=
r
;
},
getOpenMenusIndex
(
menus
,
arr
)
{
for
(
let
i
=
0
;
i
<
menus
.
length
;
i
++
)
{
const
menu
=
menus
[
i
];
if
(
menu
.
path
===
this
.
activeMenu
)
{
return
true
;
}
if
(
menu
.
children
.
length
>
0
)
{
if
(
this
.
getOpenMenusIndex
(
menu
.
children
,
arr
))
{
arr
.
push
(
menu
.
index
);
return
true
;
}
}
}
return
false
;
},
},
closeMenu
()
{
closeMenu
()
{
this
.
menuOpen
=
false
;
this
.
menuOpen
=
false
;
const
aside
=
document
.
querySelector
(
"aside"
);
const
aside
=
document
.
querySelector
(
"aside"
);
aside
.
className
=
aside
.
className
+
" fold"
;
aside
.
className
=
aside
.
className
+
" fold"
;
this
.
openFlgArr
=
new
Array
(
this
.
menus
.
length
).
fill
(
true
)
this
.
openFlgArr
=
[];
},
},
},
},
};
};
...
@@ -324,4 +290,4 @@ export default {
...
@@ -324,4 +290,4 @@ export default {
height
:
35px
;
height
:
35px
;
line-height
:
35px
;
line-height
:
35px
;
}
}
</
style
>
</
style
>
\ No newline at end of file
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