index.vue
2.73 KB
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
120
121
122
123
124
125
<template>
<div class="glsx_table_box">
<el-table class="el_table" :data="list" border :size="size">
<el-table-column v-for="(item,index) in column" :key="index" :label="item.label" :prop="item.prop" :formatter="item.formatter" :align="item.align" :fixed="item.fixed" :width="item.width" show-overflow-tooltip></el-table-column>
<el-table-column label="操作" v-if="this.$scopedSlots.operate" width="120px">
<template slot-scope="scope">
<slot name="operate" :scope="scope.row"></slot>
</template>
</el-table-column>
</el-table>
<div class="pagination_list">
<el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size.sync="pageSizeNum" :page-sizes="pageSizes" :current-page.sync="currentPage" @current-change="getList" @size-change="changePageSize" />
</div>
</div>
</template>
<script>
/**
* list: 表格数据
* border:是否带边框
* size:表格尺寸
* column: 列数据
* layout:分页展示数据
* pageSizes: 默认展示多少页列表
* pageSize: 当前展示页条数
*/
export default {
name: "GlsxTable",
props: {
list: {
type: Array,
default: function () {
return [];
},
},
column: {
type: Array,
default: function () {
return [];
},
},
border: {
type: Boolean,
default: true,
},
size: {
type: String,
default: "small",
},
layout: {
type: String,
default: "sizes, total,prev, pager, next, jumper",
},
pageTotal: {
type: Number,
default: 0,
},
pageSizes: {
type: Array,
default: function () {
return [10, 20, 30, 40];
},
},
pageSize: {
type: Number,
default: 10,
},
},
data() {
return {
currentPage: 1,
pageSizeNum: 10,
};
},
created() {
this.pageSizeNum = this.pageSize;
//console.log(this.$scopedSlots);
},
mounted() {},
methods: {
/**
* 每页展示
*/
changePageSize: function (e) {
this.pageSizeNum = e;
this.$emit("change", { pageSize: e });
//this.getList();
},
// 获取列表
getList(current) {
this.$emit("change", { pageNumber: current, pageSize: this.pageSizeNum });
},
// 重置
rest(id, e) {
if (id) {
this[id] = e;
} else {
this.currentPage = 1;
this.pageSizeNum = 10;
}
},
},
};
</script>
<style lang="scss">
.el_table {
thead {
th {
//background: rgba(197, 197, 197, 0.1);
background: #f5f7fa;
}
}
}
</style>
<style lang="scss" scoped>
.glsx_table_box {
margin: 10px 0;
}
.pagination_list {
text-align: right;
padding: 10px 0;
}
</style>