Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
V
vue-form
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
vue-form
Commits
1a76fa76
提交
1a76fa76
authored
12月 30, 2019
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
bcfa1fae
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
142 行增加
和
10 行删除
+142
-10
App.vue
examples/App.vue
+60
-2
VueForm.vue
src/VueForm.vue
+2
-1
Main.vue
src/components/layout/Main.vue
+4
-0
Menu.vue
src/components/layout/Menu.vue
+67
-6
Submenu.vue
src/components/layout/Submenu.vue
+9
-1
没有找到文件。
examples/App.vue
浏览文件 @
1a76fa76
<
template
>
<
template
>
<div
id=
"app"
>
<div
id=
"app"
>
<vue-form
<vue-form
asideWidth=
"295px"
:menus=
"menus"
:menus=
"menus"
:default-active=
"currentActive"
@
change=
"handleChange"
@
change=
"handleChange"
@
success=
"handleSuccess"
@
success=
"handleSuccess"
@
error=
"handleError"
@
error=
"handleError"
...
@@ -36,13 +36,64 @@ function url2Json(url) {
...
@@ -36,13 +36,64 @@ function url2Json(url) {
}
}
const
query
=
url2Json
(
location
.
href
)
const
query
=
url2Json
(
location
.
href
)
const
projectId
=
query
.
projectId
||
'1000'
const
projectId
=
query
.
projectId
||
'1000'
const
menus
=
[
{
id
:
'center'
,
title
:
'报名中心'
},
{
id
:
'entry'
,
title
:
'办理入学'
,
isGroup
:
true
,
children
:
[
{
id
:
'entry_required'
,
title
:
'必填项'
,
children
:
[
{
id
:
'entry_protocol'
,
title
:
'入学协议'
,
showProgress
:
true
,
progress
:
0
},
{
id
:
'entry_payment'
,
title
:
'缴费凭证'
,
showProgress
:
true
,
progress
:
0
}
]
}
]
},
{
id
:
'user'
,
title
:
'个人信息'
,
children
:
[
{
id
:
'user_info'
,
title
:
'个人信息修改'
},
{
id
:
'user_password'
,
title
:
'密码修改'
}
]
},
{
id
:
'download'
,
title
:
'相关下载'
}
]
export
default
{
export
default
{
name
:
'app'
,
name
:
'app'
,
data
()
{
data
()
{
return
{
return
{
projectId
,
projectId
,
currentActive
:
query
.
active
||
'profile'
,
currentActive
:
query
.
active
||
'profile'
,
menus
:
projectId
===
'1000'
?
sofiaForm
:
kelleyForm
menus
:
projectId
===
'1000'
?
[...
sofiaForm
,
...
menus
]
:
kelleyForm
}
}
},
},
computed
:
{
computed
:
{
...
@@ -84,3 +135,10 @@ export default {
...
@@ -84,3 +135,10 @@ export default {
}
}
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
>
*
{
margin
:
0
;
padding
:
0
;
}
</
style
>
src/VueForm.vue
浏览文件 @
1a76fa76
<
template
>
<
template
>
<div
class=
"ezj-container"
>
<div
class=
"ezj-container"
>
<ezj-aside
:width=
"asideWidth"
>
<ezj-aside
:width=
"asideWidth"
>
<ezj-menu
:menus=
"menus"
@
select=
"onSelect"
></ezj-menu>
<ezj-menu
:
default-active=
"defaultActive"
:
menus=
"menus"
@
select=
"onSelect"
></ezj-menu>
</ezj-aside>
</ezj-aside>
<ezj-main
:title=
"currentPage.title"
v-if=
"currentPage"
:key=
"activeId"
>
<ezj-main
:title=
"currentPage.title"
v-if=
"currentPage"
:key=
"activeId"
>
<slot>
<slot>
...
@@ -22,6 +22,7 @@ import EzjFormPane from '@/components/layout/FormPane'
...
@@ -22,6 +22,7 @@ import EzjFormPane from '@/components/layout/FormPane'
export
default
{
export
default
{
name
:
'VueForm'
,
name
:
'VueForm'
,
props
:
{
props
:
{
asideWidth
:
String
,
menus
:
{
menus
:
{
type
:
Array
,
type
:
Array
,
required
:
true
,
required
:
true
,
...
...
src/components/layout/Main.vue
浏览文件 @
1a76fa76
...
@@ -24,8 +24,12 @@ export default {
...
@@ -24,8 +24,12 @@ export default {
flex
:
1
;
flex
:
1
;
margin
:
0
40px
;
margin
:
0
40px
;
}
}
.ezj-main__hd
{
margin-bottom
:
26px
;
}
.ezj-main__title
{
.ezj-main__title
{
font-size
:
24px
;
font-size
:
24px
;
line-height
:
1
.4
;
color
:
#000
;
color
:
#000
;
}
}
</
style
>
</
style
>
src/components/layout/Menu.vue
浏览文件 @
1a76fa76
...
@@ -5,19 +5,19 @@
...
@@ -5,19 +5,19 @@
:class=
"
{'ezj-menu__item': true,'has-shadow': menu.hasShadow, 'is-active': menu.isActive}"
:class=
"
{'ezj-menu__item': true,'has-shadow': menu.hasShadow, 'is-active': menu.isActive}"
:key="menu.id"
:key="menu.id"
>
>
<div
class=
"ezj-menu__title"
@
click=
"handle
Click(menu.id
)"
>
{{
menu
.
title
}}
</div>
<div
class=
"ezj-menu__title"
@
click=
"handle
Select(menu.id, menu
)"
>
{{
menu
.
title
}}
</div>
<template
v-if=
"menu.children"
>
<template
v-if=
"menu.children"
>
<template
v-if=
"menu.isGroup"
>
<template
v-if=
"menu.isGroup"
>
<template
v-for=
"submenu in menu.children"
>
<template
v-for=
"submenu in menu.children"
>
<div
class=
"ezj-menu-group"
:key=
"submenu.title"
>
<div
class=
"ezj-menu-group"
:key=
"submenu.title"
v-show=
"menu.isActive"
>
<div
class=
"ezj-menu-group__title"
>
{{
submenu
.
title
}}
</div>
<div
class=
"ezj-menu-group__title"
>
{{
submenu
.
title
}}
</div>
<ezj-submenu
:menus=
"submenu.children"
@
onClick=
"handle
Click
"
></ezj-submenu>
<ezj-submenu
:menus=
"submenu.children"
@
onClick=
"handle
Select
"
></ezj-submenu>
</div>
</div>
</
template
>
</
template
>
</template>
</template>
<
template
v-else
>
<
template
v-else
>
<!-- 子菜单 -->
<!-- 子菜单 -->
<ezj-submenu
:menus=
"menu.children"
@
onClick=
"handle
Click
"
></ezj-submenu>
<ezj-submenu
:menus=
"menu.children"
@
onClick=
"handle
Select"
v-show=
"menu.isActive
"
></ezj-submenu>
</
template
>
</
template
>
</template>
</template>
</div>
</div>
...
@@ -43,7 +43,9 @@ export default {
...
@@ -43,7 +43,9 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
currentActive
:
null
menuList
:
[],
currentActive
:
null
,
activeIds
:
[]
}
}
},
},
watch
:
{
watch
:
{
...
@@ -52,12 +54,71 @@ export default {
...
@@ -52,12 +54,71 @@ export default {
handler
(
value
)
{
handler
(
value
)
{
this
.
currentActive
=
value
this
.
currentActive
=
value
}
}
},
menus
:
{
immediate
:
true
,
deep
:
true
,
handler
(
list
)
{}
}
}
},
},
methods
:
{
methods
:
{
handleClick
(
id
)
{
handleSelect
(
id
,
menu
)
{
// 有子节点的,选中子节点中的第一个
id
=
this
.
getFirstMenuId
(
menu
)
// 当前ID
this
.
currentActive
=
id
this
.
currentActive
=
id
// 设置选中的ID,包含父级的ID
this
.
activeIds
=
this
.
setActiveIds
(
this
.
menus
,
id
)
// 更新选中状态
this
.
changeActiveStatus
(
this
.
menus
,
this
.
activeIds
)
this
.
$emit
(
'select'
,
id
)
this
.
$emit
(
'select'
,
id
)
},
// 更新菜单数据isActve的状态
changeActiveStatus
(
menus
,
selected
)
{
menus
.
forEach
(
item
=>
{
// item.isActive = selected.includes(item.id)
this
.
$set
(
item
,
'isActive'
,
selected
.
includes
(
item
.
id
))
item
.
children
&&
this
.
changeActiveStatus
(
item
.
children
,
selected
)
})
},
// 设置选中的id
setActiveIds
(
arr
,
id
)
{
let
result
=
[]
for
(
const
item
of
arr
)
{
if
(
item
.
id
===
id
||
id
===
undefined
)
{
result
.
push
(
item
.
id
)
break
}
if
(
item
.
children
)
{
result
.
push
(
item
.
id
)
let
childrenResult
=
this
.
setActiveIds
(
item
.
children
,
id
)
result
=
result
.
concat
(
childrenResult
)
if
(
childrenResult
.
length
)
{
break
}
else
{
result
.
length
=
0
}
}
}
return
result
},
getFirstMenuId
(
menu
)
{
if
(
menu
.
children
&&
menu
.
children
.
length
)
{
const
[
first
]
=
menu
.
children
if
(
first
.
children
&&
first
.
children
)
{
return
this
.
getFirstMenuId
(
first
)
}
else
{
return
first
.
id
}
}
return
menu
.
id
}
},
beforeMount
()
{
// 没有设置默认选中的,
if
(
!
this
.
defaultActive
&&
this
.
menus
.
length
)
{
const
[
first
]
=
this
.
menus
this
.
handleSelect
(
first
.
id
,
first
)
}
}
}
}
}
}
...
...
src/components/layout/Submenu.vue
浏览文件 @
1a76fa76
<
template
>
<
template
>
<div
class=
"ezj-submenu"
>
<div
class=
"ezj-submenu"
>
<template
v-for=
"submenu in menus"
>
<template
v-for=
"submenu in menus"
>
<div
class=
"ezj-submenu__item"
:key=
"submenu.id"
@
click=
"$emit('onClick', submenu.id)"
>
<div
class=
"ezj-submenu__item"
:class=
"
{'is-active': submenu.isActive}"
:key="submenu.id"
@click="$emit('onClick', submenu.id, submenu)"
>
<span>
{{
submenu
.
title
}}
</span>
<span>
{{
submenu
.
title
}}
</span>
<!-- 是否必选 -->
<!-- 是否必选 -->
<template
v-if=
"submenu.showRequired"
>
{{
submenu
.
required
?
''
:
'(可选)'
}}
</
template
>
<template
v-if=
"submenu.showRequired"
>
{{
submenu
.
required
?
''
:
'(可选)'
}}
</
template
>
...
@@ -27,6 +32,9 @@ export default {
...
@@ -27,6 +32,9 @@ export default {
</
script
>
</
script
>
<
style
lang=
"scss"
>
<
style
lang=
"scss"
>
.ezj-submenu__item.is-active
{
color
:
#c41230
;
}
.is-success
{
.is-success
{
color
:
#12c44a
;
color
:
#12c44a
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论