# Menu 菜单
# 代码演示
患者中心
特别关注
ICU 李思
ICU 陈笑笑
ICU 吴中山
科室高危
妇产科
泌尿男科
其他科室
ICU 急诊
中医内科
普通外科
医学整形
住院部
患者列表
个人设置
基础用法
menu组件可以选定主题色, 组件库中内置了两套皮肤, light浅色版(默认), primary 深色版本. 自定义配色可以通过传入 styleConfig对象进行对应的样式调整, 具体调整项, 请参考例子。
查看代码 < />
<template>
<w-radio-group v-model="theme">
<w-radio label="light">light</w-radio>
<w-radio label="dark">dark</w-radio>
<w-radio label="custom">自定义</w-radio>
</w-radio-group>
<w-menu defaultActived="1" :theme="theme !== 'custom' ? theme : ''"
:styleConfig="theme === 'custom' ? styleConfig : {}">
<w-menu-item index="1">患者中心</w-menu-item>
<w-submenu index="2" width="140px">
<template slot="sub-title">特别关注</template>
<w-menu-item index="2-1">
<w-tag size="super-mini">ICU</w-tag>
<span style="margin-left: 10px">李思</span>
</w-menu-item>
<w-menu-item index="2-2">
<w-tag size="super-mini">ICU</w-tag>
<span style="margin-left: 10px">陈笑笑</span>
</w-menu-item>
<w-menu-item index="2-3">
<w-tag size="super-mini">ICU</w-tag>
<span style="margin-left: 10px">吴中山</span>
</w-menu-item>
<w-submenu index="2-4" width="140px">
<template slot="sub-title">科室高危</template>
<w-menu-item index="2-4-1">
妇产科
</w-menu-item>
<w-menu-item index="2-4-2">
泌尿男科
</w-menu-item>
<w-submenu index="2-4-3" width="140px">
<template slot="sub-title">其他科室</template>
<w-menu-item index="2-4-3-1">
<w-tag size="super-mini">ICU</w-tag>
<span style="margin-left: 10px">急诊</span>
</w-menu-item>
<w-menu-item index="2-4-3-2">
中医内科
</w-menu-item>
<w-menu-item index="2-4-3-3">
普通外科
</w-menu-item>
<w-menu-item index="2-4-3-4">
医学整形
</w-menu-item>
<w-menu-item index="2-4-3-5">
住院部
</w-menu-item>
</w-submenu>
</w-submenu>
</w-submenu>
<w-menu-item index="3">患者列表</w-menu-item>
<w-menu-item index="4">个人设置</w-menu-item>
</w-menu>
</template>
<script>
export default {
data () {
return {
theme: 'light',
styleConfig: {
backgroundColor: '#1C55E9',
textColor: '#fff',
activedTextColor: '#fff',
activedBorder: '#FFB127',
activedBackground: '#FFB127',
disabledTextColor: 'rgba(255,255,255,.6)'
}
}
}
}
</script>
患者中心
特别关注
男性患者
ICU 李思
ICU 吴中山
女性患者
ICU 陈笑笑
男性患者
ICU 李思
ICU 吴中山
女性患者
ICU 陈笑笑
工作中心
今日就诊
未就诊
已就诊
就诊流程
填写病历
检查项目
检验项目
开具处方
填写病历
检查项目
检验项目
开具处方
今日就诊
未就诊
已就诊
就诊流程
填写病历
检查项目
检验项目
开具处方
填写病历
检查项目
检验项目
开具处方
个人设置
当前激活菜单index: 4
侧栏
默认menu是横向的模式(mode = 'horizontal'), 设置 mode = 'vertical' 可以将其变成侧栏模式, 侧栏也有自定义样式的能力, 需要通过 styleConfig 参数进行配置, 具体参数请查看例子或参考说明。
查看代码 < />
<template>
<w-radio-group v-model="theme">
<w-radio label="light">light</w-radio>
<w-radio label="dark">dark</w-radio>
<w-radio label="custom">自定义</w-radio>
</w-radio-group>
<w-menu :defaultActived="actived" mode="vertical"
:theme="theme !== 'custom' ? theme : ''"
:styleConfig="theme === 'custom' ? styleConfig : {}"
@select="handleSelectChange">
<w-menu-item index="1" disabled>
<i class="w-icon w-icon-user" />患者中心</w-menu-item>
<w-submenu index="2">
<template slot="sub-title">
<i class="w-icon w-icon-mark" />特别关注</template>
<w-menu-group title="男性患者">
<w-menu-item index="2-1">
<w-tag size="mini">ICU</w-tag>
<span style="margin-left: 10px">李思</span>
</w-menu-item>
<w-menu-item index="2-2">
<w-tag size="mini">ICU</w-tag>
<span style="margin-left: 10px">吴中山</span>
</w-menu-item>
</w-menu-group>
<w-menu-group>
<template slot="title">女性患者</template>
<w-menu-item index="2-3">
<w-tag size="mini">ICU</w-tag>
<span style="margin-left: 10px">陈笑笑</span>
</w-menu-item>
</w-menu-group>
</w-submenu>
<w-submenu index="3">
<template slot="sub-title">
<i class="w-icon w-icon-time" />工作中心</template>
<w-menu-item index="3-1">
今日就诊
</w-menu-item>
<w-menu-item index="3-2">
未就诊
</w-menu-item>
<w-menu-item index="3-3">
已就诊
</w-menu-item>
<w-submenu index="3-4">
<template slot="sub-title">
就诊流程</template>
<w-menu-item index="3-4-1">
填写病历
</w-menu-item>
<w-menu-item index="3-4-2">
检查项目
</w-menu-item>
<w-menu-item index="3-4-3">
检验项目
</w-menu-item>
<w-menu-item index="3-4-4">
开具处方
</w-menu-item>
</w-submenu>
</w-submenu>
<w-menu-item index="4">
<i class="w-icon w-icon-config" />个人设置
</w-menu-item>
</w-menu>
</template>
<script>
export default {
data () {
return {
theme: 'light',
styleConfig: {
backgroundColor: '#1C55E9',
submenuBackground: '#0637ad',
textColor: '#fff',
hoverBackground: '#608eff',
activedTextColor: '#fff',
activedBackground: '#FFB127',
disabledTextColor: 'rgba(255,255,255,.6)'
},
actived: '4',
}
},
methods: {
handleSelectChange (val) {
this.actived = val
}
}
}
</script>
<style lang="scss">
.menu-vertical-demo {
.slot-wrapper {
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
background-color: #E5E8ED;
overflow: hidden;
}
.w-radio-group {
width: 100%;
margin-bottom: 25px;
}
i.w-icon {
margin-right: 10px;
}
.w-menu {
float: left;
width: 200px;
min-height: 340px;
}
.w-menu.is-custom {
i.w-icon {
color: #fff;
}
}
.content {
float: right;
width: calc(100% - 220px);
padding: 15px;
box-sizing: border-box;
background-color: #fff;
}
}
</style>
展开
折叠
患者中心
特别关注
男性患者
ICU 李思
ICU 吴中山
女性患者
ICU 陈笑笑
男性患者
ICU 李思
ICU 吴中山
女性患者
ICU 陈笑笑
工作中心
今日就诊
未就诊
已就诊
就诊流程
填写病历
检查项目
检验项目
开具处方
填写病历
检查项目
检验项目
开具处方
今日就诊
未就诊
已就诊
就诊流程
填写病历
检查项目
检验项目
开具处方
填写病历
检查项目
检验项目
开具处方
个人设置
可折叠
折叠的功能只是针对 mode = 'vertical' 模式的, 有参数 collapse 控制是否展开与折叠。
查看代码 < />
<template>
<div>
<div class="tool-zoom">
<w-switch v-model="collapse"
active-text="折叠" inactive-text="展开">
</w-switch>
</div>
<w-menu mode="vertical" defaultActived="2-1"
:collapse="collapse" :defaultOpened="['3-1']"
fold-icon="w-icon-arrow-bottom"
@select="handleSelectChange">
<w-menu-item index="1" disabled>
<i class="w-icon w-icon-user" />
<span slot="title">患者中心</span>
</w-menu-item>
<w-submenu index="2" width="140px">
<template slot="sub-title">
<i class="w-icon w-icon-mark" />
<span>特别关注</span>
</template>
<w-menu-group title="男性患者">
<w-menu-item index="2-1">
<w-tag size="mini">ICU</w-tag>
<span style="margin-left: 10px">李思</span>
</w-menu-item>
<w-menu-item index="2-2">
<w-tag size="mini">ICU</w-tag>
<span style="margin-left: 10px">吴中山</span>
</w-menu-item>
</w-menu-group>
<w-menu-group>
<template>女性患者</template>
<w-menu-item index="2-3">
<w-tag size="mini">ICU</w-tag>
<span style="margin-left: 10px">陈笑笑</span>
</w-menu-item>
</w-menu-group>
</w-submenu>
<w-submenu index="3" width="140px">
<template slot="sub-title">
<i class="w-icon w-icon-time" />
<span>工作中心</span>
</template>
<w-menu-item index="3-1">
今日就诊
</w-menu-item>
<w-menu-item index="3-2">
未就诊
</w-menu-item>
<w-menu-item index="3-3">
已就诊
</w-menu-item>
<w-submenu index="3-4" width="140px">
<template slot="sub-title">
就诊流程</template>
<w-menu-item index="3-4-1">
填写病历
</w-menu-item>
<w-menu-item index="3-4-2">
检查项目
</w-menu-item>
<w-menu-item index="3-4-3">
检验项目
</w-menu-item>
<w-menu-item index="3-4-4">
开具处方
</w-menu-item>
</w-submenu>
</w-submenu>
<w-menu-item index="4">
<i class="w-icon w-icon-config" />
<span slot="title">个人设置</span>
</w-menu-item>
</w-menu>
<div :class="['content', {
'is-menu-collapse': collapse
}]"></div>
</div>
</template>
<script>
export default {
data () {
return {
collapse: false
}
},
methods: {
handleSelectChange (val) {
this.actived = val
}
}
}
</script>
<style lang="scss">
.menu-collapse-demo {
.slot-wrapper {
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
background-color: #E5E8ED;
}
.tool-zoom {
width: 100%;
margin-bottom: 25px;
}
i.w-icon {
margin-right: 8px;
}
.w-menu {
float: left;
width: 200px;
min-height: 340px;
}
.w-menu--collapse {
width: 65px;
}
.content {
float: right;
width: calc(100% - 220px);
padding: 15px;
box-sizing: border-box;
background-color: #fff;
will-change: width;
transition: width .3s cubic-bezier(.645, .045, .355, 1);
}
.is-menu-collapse {
width: calc(100% - 85px);
&>div.is-actived {
i.w-icon {
color: #0b4aed !important;
}
}
}
}
</style>
# API
# Menu Attribute
参数 | 说明 | 类型 | 可选值 | 默认值 | Version |
---|---|---|---|---|---|
collapse | 是否折叠菜单(仅在 mode 为 vertical 时生效) | Boolean | — | false | |
default-actived | 当前激活菜单的 index(默认展开该菜单所在的各级菜单) | String | — | — | v1.2.1 |
default-opened | 当前打开的 sub-menu 的 index 的数组 | Array | — | — | |
fold-icon | submenu折叠的icon | String | — | w-icon-triangle-bottom | v1.4.0 |
mode | 模式 | String | horizontal / vertical | horizontal | |
unique-opened | 是否只保持一个子菜单的展开 | Boolean | — | false | |
style-config | 自定义菜单样式(具体查看style-config说明) | Object | — | — | |
trigger | 子菜单打开的触发方式 | String | hover / click | click | |
theme | 内置菜单主题 | String | light / dark | light |
# 自定义菜单配置 style-config
参数名称 | 说明 | Version |
---|---|---|
activedTextColor | 激活状态下文字颜色 | |
activedBorder | 激活状态下描边颜色 | |
activedBackground | 激活状态下背景色 | |
backgroundColor | 菜单背景色 | |
hoverBackground | 菜单被hover时背景色 | |
submenuBackground | 子菜单的背景色(仅在mode为horizontal模式下生效) | |
textColor | 一般状态下文字颜色 |
# Menu Events
事件名称 | 说明 | 回调参数 | Version |
---|---|---|---|
select | 菜单激活回调 | index: 选中菜单项的 index | |
toggle-submenu | 当前操作的sub-menu的展开状态的回调 | { index: (当前sub-menu的index), status: (展开true或收起false) } |
# SubMenu Attribute
参数 | 说明 | 类型 | 可选值 | 默认值 | Version |
---|---|---|---|---|---|
disabled | 是否禁用 | Boolean | — | false | |
index | 唯一标志 | String | — | — | |
popper-class | 弹出菜单的自定义类名 | String | — | — | |
width | 菜单popper宽度 | String | — | — |
# Menu-Item Attribute
参数 | 说明 | 类型 | 可选值 | 默认值 | Version |
---|---|---|---|---|---|
disabled | 是否禁用 | Boolean | — | false | |
index | 唯一标志 | String | — | — | |
route | vue-router路径数据 | String | Object | — | — |
# Menu-Group Attribute
参数 | 说明 | 类型 | 可选值 | 默认值 | Version |
---|---|---|---|---|---|
title | 分组标题 | String | — | — |
# 贡献者
类型 | 参与者 |
---|---|
设计者 | UED视觉组 |
维护者 | UED前端组 |