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
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';
/* eslint react/no-multi-comp:0, no-console:0 */
import BaseMixin from '../../_util/BaseMixin';
import '../assets/index.less';
import TreeSelect from '../src/index';
import { getNewTreeData, generateTreeNodes } from './util';
export default {
mixins: [BaseMixin],
data: function data() {
return {
treeData: [{ label: 'pNode 01', value: '0-0', key: '0-0' }, { label: 'pNode 02', value: '0-1', key: '0-1' }, { label: 'pNode 03', value: '0-2', key: '0-2', isLeaf: true }],
// value: '0-0',
value: { value: '0-0-0-value', label: '0-0-0-label' }
};
},
methods: {
onChange: function onChange(value) {
console.log(value);
this.setState({
value: value
});
},
onLoadData: function onLoadData(treeNode) {
var _this = this;
console.log(treeNode);
return new Promise(function (resolve) {
setTimeout(function () {
var treeData = [].concat(_toConsumableArray(_this.treeData));
getNewTreeData(treeData, treeNode.eventKey, generateTreeNodes(treeNode), 2);
_this.setState({ treeData: treeData });
resolve();
}, 500);
});
}
},
render: function render() {
var h = arguments[0];
return h(
'div',
{ style: { padding: '10px 30px' } },
[h('h2', ['dynamic render']), h(TreeSelect, {
style: { width: '300px' },
attrs: { treeData: this.treeData,
labelInValue: true,
value: this.value,
loadData: this.onLoadData,
__propsSymbol__: Symbol()
},
on: {
'change': this.onChange
}
})]
);
}
};