|
|
@@ -23,33 +23,6 @@
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
- <div class="page">
|
|
|
- <div
|
|
|
- class="fisrtPage"
|
|
|
- @click="jumpPage(1)"
|
|
|
- v-show="currentPage > 1"
|
|
|
- >首页</div>
|
|
|
- <div
|
|
|
- class="previousPage"
|
|
|
- @click="jumpPage(2)"
|
|
|
- v-show="currentPage > 1"
|
|
|
- >上一页</div>
|
|
|
- <div
|
|
|
- v-for="(item, index) in pageArr" :key="index"
|
|
|
- :class="{current_page: currentPage == item}"
|
|
|
- @click="chagePage(item)"
|
|
|
- >{{item}}</div>
|
|
|
- <div
|
|
|
- class="nextPage"
|
|
|
- @click="jumpPage(3)"
|
|
|
- v-show="currentPage < totalPage"
|
|
|
- >下一页</div>
|
|
|
- <div
|
|
|
- class="lastPage"
|
|
|
- @click="jumpPage(4)"
|
|
|
- v-show="currentPage < totalPage"
|
|
|
- >尾页</div>
|
|
|
- </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -116,70 +89,19 @@ export default {
|
|
|
pageSize: {
|
|
|
type: Number,
|
|
|
default: 20
|
|
|
- },
|
|
|
- // 表数据共有多少页
|
|
|
- totalPage: {
|
|
|
- type: Number,
|
|
|
- default: 0
|
|
|
- },
|
|
|
- // 当前在第几页
|
|
|
- currentPage: {
|
|
|
- type: Number,
|
|
|
- default: 1
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- console.log(this.totalPage);
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
}
|
|
|
- },
|
|
|
- computed: {
|
|
|
- // 生成表格的导航
|
|
|
- pageArr() {
|
|
|
- let arr = [];
|
|
|
- if(this.totalPage <= 10) { // 最多展示十个,总页面小于等于10,全部展示
|
|
|
- for(let i = 1; i <= this.totalPage; i++){
|
|
|
- arr.push(i);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 点击的是1~5, 展示1~10
|
|
|
- if (this.currentPage - 5 <= 0) {
|
|
|
- for(let i = 1; i <= 10; i++){
|
|
|
- arr.push(i);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 点击 大于5,同时后面的页面至少有五个五个,展示
|
|
|
- if (this.totalPage - this.currentPage > 4) {
|
|
|
- for(let i = this.currentPage - 4; i <= this.currentPage + 5; i++){
|
|
|
- arr.push(i);
|
|
|
- }
|
|
|
- } else { // 点击 大于五,同时后面的页面数不足五个
|
|
|
- for(let i = this.totalPage - 9; i <= this.totalPage; i++) {
|
|
|
- arr.push(i);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- console.log(arr);
|
|
|
- return arr;
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- chagePage: function(page) {
|
|
|
- this.$emit('change_page', page);
|
|
|
- },
|
|
|
- jumpPage:function(item) {
|
|
|
- this.$emit('jump_page', item);
|
|
|
- }
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
.table_template{
|
|
|
- margin: 5px;
|
|
|
text-align: center;
|
|
|
.table{
|
|
|
background-color: #fff;
|
|
|
@@ -194,37 +116,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .page{
|
|
|
- height: 30px;
|
|
|
- display: flex;
|
|
|
- border-left: 1px solid #ccc;
|
|
|
- div{
|
|
|
- width: 32px;
|
|
|
- background-color: #fff;
|
|
|
- line-height: 30px;
|
|
|
- border-bottom: 1px solid #ccc;
|
|
|
- border-right: 1px solid #ccc;
|
|
|
- &:hover{
|
|
|
- cursor: pointer;
|
|
|
- }
|
|
|
- }
|
|
|
- .current_page{
|
|
|
- color: #999;
|
|
|
- background-color: #f5f5f5;
|
|
|
- }
|
|
|
- .fisrtPage{
|
|
|
- width: 50px;
|
|
|
- }
|
|
|
- .previousPage{
|
|
|
- width: 60px;
|
|
|
- }
|
|
|
- .nextPage{
|
|
|
- width: 60px;
|
|
|
- }
|
|
|
- .lastPage{
|
|
|
- width: 50px;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
.table_gray{
|
|
|
background: #f5f5f5;
|