-
Notifications
You must be signed in to change notification settings - Fork 264
/
table-tr.js
52 lines (51 loc) 路 1.31 KB
/
table-tr.js
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
import TableTd from './table-td';
import utils from '../../utils/utils';
export default {
name: 'hTableTr',
props: {
datas: [Object, Array],
index: Number
},
render(h) {
let tds = [];
if (this.$slots && this.$slots.default) {
tds.push(...this.$slots.default)
}
if (this.$parent.$slots.default) {
for (let td of this.$parent.$slots.default || []) {
if (td.data) {
let props = {};
if (td.componentOptions.propsData) {
Object.assign(props, td.componentOptions.propsData);
}
props.data = this.datas;
props.index = this.index;
let param = { props };
if (td.data.scopedSlots) {
param.scopedSlots = td.data.scopedSlots;
}
tds.push(h(TableTd, param));
}
}
} else if (!this.$parent.$scopedSlots.default && this.$parent.columns) {
for (let td of this.$parent.columns || []) {
let param = utils.copy({ props: td });
param.props.data = this.datas;
param.props.index = this.index;
tds.push(h(TableTd, param));
}
}
return h(
'tr', {
on: {
click: this.clickHandler
},
}, tds
)
},
methods: {
clickHandler(event) {
this.$emit('click', this.datas, event)
}
}
}