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
<template>
<el-table
size="small"
:data="tableData"
:row-key="handleRowKeyMethod"
:span-method="handleSpanMethod"
:toggleRowSelection="toggleRowSelection"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
@row-click="handleRowClick"
:row-class-name="tableRowClassName"
:empty-text="emptyText"
border
height="600"
style="width: 100%"
>
<el-table-column
v-for="column in columns"
:key="column.prop"
:type="column.type"
:index="handleIndexMethod"
:selectable="handleSelectableMethod"
:prop="column.prop"
:label="column.label"
:width="column.width"
:sortable="column.sortable"
:show-overflow-tooltip="column.tooltip"
:align="column.align || 'center'"
:formatter="column.formatter"
:reserve-selection="column.reserveSelection"
:subColumns="column.subColumns"
>
<el-table-column
v-for="sunColumn in column.subColumns"
:key="sunColumn.prop"
:type="sunColumn.type"
:prop="sunColumn.prop"
:label="sunColumn.label"
:width="sunColumn.width"
:sortable="sunColumn.sortable"
:align="sunColumn.align || 'center'"
:formatter="sunColumn.formatter"
/>
</el-table-column>
</el-table>
</template>
<script>
export default {
props: {
handleRowKeyMethod: {
type: Function,
required: false,
default: (row) => {
return row.id;
},
},
handleSelectableMethod: {
type: Function,
required: false,
default: () => {},
},
handleIndexMethod: {
type: Function,
required: false,
default: () => {},
},
handleSpanMethod: {
type: Function,
required: false,
default: () => {},
},
handleSelectionChange: {
type: Function,
required: false,
default: () => {},
},
handleRowClick: {
type: Function,
required: false,
default: () => {},
},
handleSortChange: {
type: Function,
required: false,
default: () => {},
},
tableRowClassName: {
type: Function,
required: false,
default: () => {},
},
loading: {
type: Boolean,
required: false,
default: true,
},
tableData: {
type: Array,
required: false,
default: () => [],
},
columns: {
type: Array,
required: false,
default: () => [],
},
},
computed: {
emptyText() {
return !this.loading && !this.tableData.length ? "暂无数据" : "加载中...";
},
},
methods: {},
data() {
return {};
},
};
</script>