-
-
Notifications
You must be signed in to change notification settings - Fork 979
/
Copy pathTable.vue
62 lines (61 loc) · 1.28 KB
/
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
<template>
<CCard>
<CCardHeader>
<slot name="header">
<CIcon name="cil-grid"/> {{caption}}
</slot>
</CCardHeader>
<CCardBody>
<CDataTable
:hover="hover"
:striped="striped"
:bordered="bordered"
:small="small"
:fixed="fixed"
:items="items"
:fields="fields"
:items-per-page="small ? 10 : 5"
:dark="dark"
pagination
>
<template #status="{item}">
<td>
<CBadge :color="getBadge(item.status)">{{item.status}}</CBadge>
</td>
</template>
</CDataTable>
</CCardBody>
</CCard>
</template>
<script>
export default {
name: 'Table',
props: {
items: Array,
fields: {
type: Array,
default () {
return ['username', 'registered', 'role', 'status']
}
},
caption: {
type: String,
default: 'Table'
},
hover: Boolean,
striped: Boolean,
bordered: Boolean,
small: Boolean,
fixed: Boolean,
dark: Boolean
},
methods: {
getBadge (status) {
return status === 'Active' ? 'success'
: status === 'Inactive' ? 'secondary'
: status === 'Pending' ? 'warning'
: status === 'Banned' ? 'danger' : 'primary'
}
}
}
</script>