Files
mes-ui-d2/src/pages/demo/playground/store/menu/index.vue
liyang 59d0a00a93 card模式下footer的上边框样式修改
Former-commit-id: 9e898e7e522c12314d66ef4bac387c03e5807721 [formerly 9e898e7e522c12314d66ef4bac387c03e5807721 [formerly 9e898e7e522c12314d66ef4bac387c03e5807721 [formerly 9e898e7e522c12314d66ef4bac387c03e5807721 [formerly f2188f2d4b7589959a2e8b52d3ba6ea07146505c [formerly dc767a687eb356eec775d76fc23aeea1ddd987a1]]]]]
Former-commit-id: e51c4e427397e1a77716faabf2582f49557edd1e
Former-commit-id: 2831a1a04ececfdd57e28c04eb69fe2e5e955edb
Former-commit-id: 88d4e5e800517bd71e4ce7baab6e69faf43cbcb9 [formerly 24a005ea8a56b0a909ab7956acfee1496fc72d90]
Former-commit-id: 0092b2e3dea957158e3c3dd4f7a1f0a53c29ed03
Former-commit-id: 503bf624641dd20063cc6fdea9724e0189dcf76c
Former-commit-id: 66b113f3ccf61ded5590e656d0a9c5ba9bdd5dca
Former-commit-id: 754fca3037fd666bf94956bde01cc93dac410749
Former-commit-id: ba4e08db986e9c30e17cf678d64227660742fe34
2018-07-24 08:55:09 +08:00

168 lines
4.5 KiB
Vue

<template>
<d2-container type="ghost">
<el-row :gutter="20" class="d2-mt d2-mb">
<el-col :span="12">
<el-card shadow="never">
<template slot="header">顶栏菜单</template>
<el-button-group class="d2-mb">
<el-button @click="handleMenuHeaderSet">设置空菜单</el-button>
<el-button @click="menuHeaderReset">恢复</el-button>
</el-button-group>
<div style="height: 400px; overflow: auto;">
<d2-highlight :code="JSON.stringify(menuHeader, null, 2)"/>
<!-- <tree-view
class="tree-view-small"
:data="menuHeader"
:options="{
rootObjectKey: 'menuHeader',
maxDepth: 1
}"/> -->
</div>
</el-card>
</el-col>
<el-col :span="12">
<el-card shadow="never">
<template slot="header">侧栏菜单</template>
<el-button-group class="d2-mb">
<el-button @click="handleMenuAsideSet">设置空菜单</el-button>
<el-button @click="menuAsideReset">恢复</el-button>
</el-button-group>
<div style="height: 400px; overflow: auto;">
<d2-highlight :code="JSON.stringify(menuAside, null, 2)"/>
<!-- <tree-view
class="tree-view-small"
:data="menuAside"
:options="{
rootObjectKey: 'menuAside',
maxDepth: 1
}"/> -->
</div>
</el-card>
</el-col>
</el-row>
</d2-container>
</template>
<script>
import clonedeep from 'lodash.clonedeep'
import { mapState, mapMutations } from 'vuex'
export default {
data () {
return {
menuEmpty: [
{
title: '空菜单演示',
icon: 'folder-o',
children: [
{
title: '空菜单 1',
children: [
{ title: '空菜单 1-1' },
{ title: '空菜单 1-2' }
]
},
{ title: '空菜单 2' },
{ title: '空菜单 3' }
]
}
],
menuHeaderChanged: false,
menuAsideChanged: false,
menuHeaderBak: [],
menuAsideBak: []
}
},
computed: {
...mapState({
menuHeader: state => state.d2admin.menuHeader,
menuAside: state => state.d2admin.menuAside
})
},
created () {
this.menuHeaderBak = clonedeep(this.menuHeader)
this.menuAsideBak = clonedeep(this.menuAside)
},
beforeDestroy () {
if (this.menuHeaderChanged && this.menuAsideChanged) {
this.d2adminMenuHeaderSet(this.menuHeaderBak)
this.d2adminMenuAsideSet(this.menuAsideBak)
this.$notify({
title: '菜单恢复',
message: '对侧边栏和顶栏菜单的修改已经复原',
type: 'success'
})
return
}
if (this.menuHeaderChanged) {
this.d2adminMenuHeaderSet(this.menuHeaderBak)
this.$notify({
title: '菜单恢复',
message: '对顶栏菜单的修改已经复原',
type: 'success'
})
return
}
if (this.menuAsideChanged) {
this.d2adminMenuAsideSet(this.menuAsideBak)
this.$notify({
title: '菜单恢复',
message: '对侧边栏菜单的修改已经复原',
type: 'success'
})
}
},
methods: {
...mapMutations([
'd2adminMenuHeaderSet',
'd2adminMenuAsideSet'
]),
/**
* 修改顶栏菜单
*/
handleMenuHeaderSet () {
this.menuHeaderChanged = true
this.d2adminMenuHeaderSet(this.menuEmpty)
this.$notify({
title: '菜单修改',
message: '对顶栏菜单的修改已经生效',
type: 'success'
})
},
/**
* 修改侧边栏菜单
*/
handleMenuAsideSet () {
this.menuAsideChanged = true
this.d2adminMenuAsideSet(this.menuEmpty)
this.$notify({
title: '菜单修改',
message: '对侧边栏菜单的修改已经生效',
type: 'success'
})
},
/**
* 恢复顶栏菜单
*/
menuHeaderReset () {
this.d2adminMenuHeaderSet(this.menuHeaderBak)
this.$notify({
title: '菜单恢复',
message: '对顶栏菜单的修改已经复原',
type: 'success'
})
},
/**
* 恢复侧边栏菜单
*/
menuAsideReset () {
this.d2adminMenuAsideSet(this.menuAsideBak)
this.$notify({
title: '菜单恢复',
message: '对侧边栏菜单的修改已经复原',
type: 'success'
})
}
}
}
</script>