1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* eslint no-console:0 */
/* eslint no-alert:0 */
import PropTypes from '../../_util/vue-types';
import Tree from '../index';
import '../assets/index.less';
import './basic.less';
var treeData = [{
key: '0-0',
title: 'parent 1',
children: [{ key: '0-0-0', title: 'parent 1-1', children: [{ key: '0-0-0-0', title: 'parent 1-1-0' }] }, {
key: '0-0-1',
title: 'parent 1-2',
children: [{ key: '0-0-1-0', title: 'parent 1-2-0', disableCheckbox: true }, { key: '0-0-1-1', title: 'parent 1-2-1' }]
}]
}];
export default {
props: {
keys: PropTypes.array.def(['0-0-0-0'])
},
data: function data() {
var keys = this.keys;
return {
defaultExpandedKeys: keys,
defaultSelectedKeys: keys,
defaultCheckedKeys: keys
};
},
methods: {
onExpand: function onExpand(expandedKeys) {
console.log('onExpand', expandedKeys, arguments);
},
onSelect: function onSelect(selectedKeys, info) {
console.log('selected', selectedKeys, info);
this.selKey = info.node.$options.propsData.eventKey;
},
onCheck: function onCheck(checkedKeys, info) {
console.log('onCheck', checkedKeys, info);
},
onEdit: function onEdit() {
var _this = this;
setTimeout(function () {
console.log('current key: ', _this.selKey);
}, 0);
},
onDel: function onDel(e) {
if (!window.confirm('sure to delete?')) {
return;
}
e.stopPropagation();
},
toggleChildren: function toggleChildren() {
this.showMore = !this.showMore;
}
},
render: function render() {
var h = arguments[0];
var customLabel = // eslint-disable-line
h(
'span',
{ 'class': 'cus-label' },
[h('span', ['operations: ']), h(
'span',
{ style: { color: 'blue' }, on: {
'click': this.onEdit
}
},
['Edit']
), '\xA0', h(
'label',
{
on: {
'click': function click(e) {
return e.stopPropagation();
}
}
},
[h('input', {
attrs: { type: 'checkbox' }
}), ' checked']
), '\xA0', h(
'span',
{ style: { color: '#EB0000' }, on: {
'click': this.onDel
}
},
['Delete']
)]
);
return h(
'div',
{ style: { margin: '0 20px' } },
[h('h2', ['simple']), h('h2', ['Check on Click TreeNode']), h(Tree, {
'class': 'myCls',
attrs: { showLine: true,
checkable: true,
selectable: false,
defaultExpandAll: true,
defaultSelectedKeys: this.defaultSelectedKeys,
defaultCheckedKeys: this.defaultCheckedKeys,
treeData: treeData
},
on: {
'expand': this.onExpand,
'select': this.onSelect,
'check': this.onCheck
}
})]
);
}
};