Commit bbe409d8 by liwk

菜单列表组件增加全部展开与收起

1 parent 69ac8af4
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="menu-box box"> <div class="menu-box box">
<div class="title" v-html="title"></div> <div class="title" v-html="title"></div>
<gl-row v-if="consoleItem" class="console-btn"> <gl-row v-if="consoleItem" class="console-btn">
<gl-col :span='8'><gl-button @click="openAll">全部展开</gl-button></gl-col> <gl-col :span='8'><gl-button @click="openAll(openOrClose)">{{openOrClose ? '全部展开' : '全部收起'}}</gl-button></gl-col>
<gl-col :span='16'> <gl-col :span='16'>
<gl-button @click="pushSublings" type='primary' :disabled="push">添加同级菜单</gl-button> <gl-button @click="pushSublings" type='primary' :disabled="push">添加同级菜单</gl-button>
<gl-button @click="pushChildren" type='primary' :disabled="push">添加子菜单</gl-button> <gl-button @click="pushChildren" type='primary' :disabled="push">添加子菜单</gl-button>
...@@ -90,12 +90,12 @@ ...@@ -90,12 +90,12 @@
</template> </template>
<script> <script>
import './time.js'
var timeTip = '系统自动生成(格式yyyy-MM-dd HH:mm:ss)' var timeTip = '系统自动生成(格式yyyy-MM-dd HH:mm:ss)'
export default { export default {
name: 'Tree', name: 'Tree',
data() { data() {
return { return {
openOrClose: true,
node: null, node: null,
btnTxt: '修改', btnTxt: '修改',
allNode: null, allNode: null,
...@@ -177,7 +177,6 @@ export default { ...@@ -177,7 +177,6 @@ export default {
}, },
methods: { methods: {
nodeClick(data, node, that) { nodeClick(data, node, that) {
console.log(data, node, that)
this.btnTxt = '修改' this.btnTxt = '修改'
this.node = node this.node = node
this.allNode = data this.allNode = data
...@@ -193,12 +192,18 @@ export default { ...@@ -193,12 +192,18 @@ export default {
this.form.createTime = data.createTime this.form.createTime = data.createTime
this.form.changeTime = data.changeTime this.form.changeTime = data.changeTime
}, },
// 打开全部 // 展开与关闭
openAll() { openAll(val) {
console.log(this.$refs) this.searchChildren(this.$refs.tree.$children[0].store._getAllNodes(), val)
for (let i = 0; i < this.$refs.tree.$children[0].store._getAllNodes().length; i++) { this.openOrClose = !this.openOrClose
this.$refs.tree.$children[0].store._getAllNodes()[i].expanded = true },
} searchChildren(data, val) {
data.forEach(el => {
el.expanded = val
if (el.childNodes) {
this.searchChildren(el.childNodes, val)
}
})
}, },
// 添加同级菜单 // 添加同级菜单
pushSublings() { pushSublings() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!