-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathu-table.vue
92 lines (82 loc) · 1.78 KB
/
u-table.vue
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
<template>
<table class="u-table" :class="{ auto }">
<thead>
<tr>
<th v-for="(column, index) in columns" :style="column.style" :key="index">
<span type="7">{{ column.label }}</span>
</th>
</tr>
</thead>
<tbody>
<tr
v-for="(row, index) in list"
:key="index"
@click="rowItemClick(row, index, $event)"
class="ai-table-content ai-table-row"
>
<slot :row="row" :rowIndex="index" />
</tr>
</tbody>
</table>
</template>
<script>
export default {
name: 'u-table',
props: {
list: { type: Array, default: () => [] },
auto: { type: Boolean, default: true }
},
data() {
return {
columns: []
}
},
methods: {
rowItemClick(row, index, ev) {
this.$emit('row-click', row, index, ev)
}
}
}
</script>
<style lang="scss" scoped>
.u-table {
&.auto {
width: 100%;
} // 自适应
&[size='s'] {
th,
td {
padding: 8px 0;
}
}
th,
td {
padding: 20px 0; // 上下空出间隙
// 表格左空出间隙
&:first-child {
padding-left: 22px;
}
// 表格右空出间隙
&:last-child {
padding-right: 22px;
}
}
// 表头
thead {
tr {
height: 54px;
background-color: #f7f7fa;
th {
white-space: nowrap;
}
}
}
tbody {
border-radius: 4px;
background-color: #ffffff;
tr {
border-bottom: 1px solid #e1e3e6;
}
}
}
</style>