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
<template>
<div class="eContainer-table-block">
<el-table
ref="table"
:data="data"
style="width: 100%"
class="eContainer-table"
:header-cell-style="{
background: 'rgb(235, 235, 235)',
color: 'rgb(51, 51, 51)',
}"
:highlight-current-row="true"
:border="true"
max-height="380"
>
<c-table-column
v-for="(item, key) in columns"
:key="key"
:prop="item.prop"
:label="item.label"
:width="item.width"
sortable
>
<template v-slot="{ scope }">
<span>{{ scope.row[item.prop] }}</span>
</template>
</c-table-column>
<slot></slot>
</el-table>
<c-col :span="24">
<el-pagination
class="eContainer-pagination"
layout="prev, pager, next, jumper, ->, sizes, total"
:page-sizes="pageSizes"
:page-size="pageSize"
:current-page="pageNumber"
:total="total"
@size-change="sizeChange"
@current-change="currentChange"
></el-pagination>
</c-col>
</div>
</template>
<script>
import CodeTable from "~/config/CodeTable";
/**
* 后端分页的 Table 组件
*/
export default {
props: {
columns: {
type: Array,
default: () => {
return [];
},
},
data: {
type: Array,
default: () => {
return [];
},
},
pageNumber: {
type: Number,
default: 1,
},
pageSize: {
type: Number,
default: 1,
},
total: {
type: Number,
default: 0,
},
},
data() {
return {
pageSizes: [5, 10, 20, 30, 40, 50, 100],
codes: {
...CodeTable,
},
};
},
mounted() {},
methods: {
sizeChange(size) {
this.$emit("queryFunc", this.pageNumber, size);
},
currentChange(currentPage) {
this.$emit("queryFunc", currentPage, this.pageSize);
},
},
};
</script>
<style scoped>
</style>