tree support accordion

This commit is contained in:
baiyaaaaa
2017-01-14 16:02:52 +08:00
committed by 杨奕
parent 39cbb051f1
commit 2072156e5b
6 changed files with 535 additions and 307 deletions

View File

@@ -5,7 +5,8 @@
:node="child"
:props="props"
:key="getNodeKey(child)"
:render-content="renderContent">
:render-content="renderContent"
@click.native="handleChildNodeClick(child)">
</el-tree-node>
<div class="el-tree__empty-block" v-if="!root.childNodes || root.childNodes.length === 0">
<span class="el-tree__empty-text">{{ emptyText }}</span>
@@ -16,10 +17,25 @@
<script type="text/ecmascript-6">
import TreeStore from './model/tree-store';
import {t} from 'element-ui/src/locale';
import emitter from 'element-ui/src/mixins/emitter';
export default {
name: 'ElTree',
mixins: [emitter],
components: {
ElTreeNode: require('./tree-node.vue')
},
data() {
return {
store: null,
root: null,
currentNode: null
};
},
props: {
data: {
type: Array
@@ -64,40 +80,8 @@
highlightCurrent: Boolean,
currentNodeKey: [String, Number],
load: Function,
filterNodeMethod: Function
},
created() {
this.isTree = true;
this.store = new TreeStore({
key: this.nodeKey,
data: this.data,
lazy: this.lazy,
props: this.props,
load: this.load,
currentNodeKey: this.currentNodeKey,
checkStrictly: this.checkStrictly,
defaultCheckedKeys: this.defaultCheckedKeys,
defaultExpandedKeys: this.defaultExpandedKeys,
autoExpandParent: this.autoExpandParent,
defaultExpandAll: this.defaultExpandAll,
filterNodeMethod: this.filterNodeMethod
});
this.root = this.store.root;
},
data() {
return {
store: null,
root: null,
currentNode: null
};
},
components: {
ElTreeNode: require('./tree-node.vue')
filterNodeMethod: Function,
accordion: Boolean
},
computed: {
@@ -156,7 +140,31 @@
},
setChecked(data, checked, deep) {
this.store.setChecked(data, checked, deep);
},
handleChildNodeClick(node) {
this.broadcast('ElTreeNode', 'tree-node-click', node);
}
},
created() {
this.isTree = true;
this.store = new TreeStore({
key: this.nodeKey,
data: this.data,
lazy: this.lazy,
props: this.props,
load: this.load,
currentNodeKey: this.currentNodeKey,
checkStrictly: this.checkStrictly,
defaultCheckedKeys: this.defaultCheckedKeys,
defaultExpandedKeys: this.defaultExpandedKeys,
autoExpandParent: this.autoExpandParent,
defaultExpandAll: this.defaultExpandAll,
filterNodeMethod: this.filterNodeMethod
});
this.root = this.store.root;
}
};
</script>