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
119
120
121
122
123
124
125
126
127
128
129
130
131
/* eslint-disable no-console,func-names,react/no-multi-comp */
import Table from '../index';
import '../assets/index.less';
import Menu from '../../menu';
var Item = Menu.Item;
var Divider = Menu.Divider;
import DropDown from '../../dropdown';
var data = [];
for (var i = 0; i < 10; i++) {
data.push({
key: i,
a: 'a' + i,
b: 'b' + i,
c: 'c' + i
});
}
export default {
data: function data() {
this.filters = [];
return {
visible: false
};
},
methods: {
handleVisibleChange: function handleVisibleChange(visible) {
this.visible = visible;
},
handleSelect: function handleSelect(selected) {
this.filters.push(selected);
},
handleDeselect: function handleDeselect(key) {
var index = this.filters.indexOf(key);
if (index !== -1) {
this.filters.splice(index, 1);
}
},
confirmFilter: function confirmFilter() {
console.log(this.filters.join(','));
this.visible = false;
}
},
render: function render() {
var h = arguments[0];
var menu = h(
Menu,
{
style: { width: '200px' },
attrs: { multiple: true,
selectable: true
},
on: {
'select': this.handleSelect,
'deselect': this.handleDeselect
}
},
[h(
Item,
{ key: '1' },
['one']
), h(
Item,
{ key: '2' },
['two']
), h(
Item,
{ key: '3' },
['three']
), h(Divider), h(
Item,
{
attrs: { disabled: true }
},
[h(
'button',
{
style: {
cursor: 'pointer',
color: '#000',
pointerEvents: 'visible'
},
on: {
'click': this.confirmFilter
}
},
['\u786E\u5B9A']
)]
)]
);
var columns = [{
title: h('div', ['title1', h(
DropDown,
{
attrs: {
trigger: ['click'],
visible: this.visible
},
on: {
'visibleChange': this.handleVisibleChange
}
},
[h(
'template',
{ slot: 'overlay' },
[menu]
), h(
'a',
{
attrs: { href: '#' }
},
['filter']
)]
)]),
key: 'a',
dataIndex: 'a',
width: 100
}, { title: 'title2', key: 'b', dataIndex: 'b', width: 100 }, { title: 'title3', key: 'c', dataIndex: 'c', width: 200 }];
return h('div', [h('h2', ['use dropdown']), h(Table, {
attrs: { columns: columns, data: data, rowKey: function rowKey(record) {
return record.key;
} }
})]);
}
};