pageComponent.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="page-wrap" v-if="total/1.0/pageSize>1">
  3. <el-pagination
  4. :current-page.sync="currentPage"
  5. :page-size="pageSize"
  6. layout="prev, pager, next"
  7. :total="total"
  8. @current-change="handleCurrentChange"
  9. v-if="total/pageSize>=1"/>
  10. <ul class="pagination" style="float:right;margin-left:20px;">
  11. <li>
  12. <input type="number" class="page-number" @keyup.13="changePage" v-model="nowPage">
  13. </li>
  14. <li>
  15. <a class="page-a" @click="changePage">GO</a>
  16. </li>
  17. </ul>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. data () {
  23. return {
  24. nowPage: 1,
  25. currentPage: 1
  26. }
  27. },
  28. watch: {
  29. current: function () {
  30. this.nowPage = Number(this.current)
  31. this.currentPage = this.nowPage
  32. }
  33. },
  34. props: ['current', 'total', 'pageSize'],
  35. methods: {
  36. handleCurrentChange: function (changedPage) {
  37. if (this.nowPage !== this.currentPage) {
  38. this.$emit('childEvent', changedPage)
  39. }
  40. },
  41. changePage: function () {
  42. let totalPage = Math.ceil(this.total / this.pageSize)
  43. if (this.nowPage > totalPage) {
  44. this.nowPage = totalPage
  45. } else if (this.nowPage < 1) {
  46. this.nowPage = 1
  47. }
  48. this.$emit('childEvent', this.nowPage)
  49. }
  50. }
  51. }
  52. </script>
  53. <style>
  54. .page-wrap a {
  55. color: #2d8cf0;
  56. background: 0 0;
  57. text-decoration: none;
  58. outline: 0;
  59. cursor: pointer;
  60. transition: color .2s ease;
  61. }
  62. .el-pagination {
  63. padding: 0;
  64. }
  65. .el-pagination .btn-next, .el-pagination .btn-prev {
  66. color: #337ab7;
  67. width: 33px;
  68. height: 30px;
  69. }
  70. .el-pagination .btn-next {
  71. border-top-right-radius: 4px;
  72. border-bottom-right-radius: 4px;
  73. }
  74. .el-pagination .btn-prev {
  75. border-top-left-radius: 4px;
  76. border-bottom-left-radius: 4px;
  77. }
  78. .el-pager li{
  79. color: #337ab7;
  80. text-decoration: none;
  81. background-color: #fff;
  82. border: 1px solid #ddd;
  83. font-size: 10px;
  84. width: 33px;
  85. height: 30px;
  86. border-right: none;
  87. }
  88. .el-pager li:not(.active):hover, .el-pagination button:hover {
  89. z-index: 3;
  90. color: #23527c;
  91. background-color: #eee;
  92. border-color: #ddd;
  93. }
  94. .el-pager li.active {
  95. background: #5078cb!important;
  96. }
  97. .el-icon-arrow-left:before {
  98. content: "\f100";
  99. font-family: FontAwesome;
  100. }
  101. .el-icon-arrow-right:before {
  102. content: "\f101";
  103. font-family: FontAwesome;
  104. }
  105. .el-pagination button.disabled {
  106. color: #337ab7;
  107. background-color: #fff;
  108. cursor: not-allowed;
  109. }
  110. .pagination {
  111. display: inline-block;
  112. padding-left: 0;
  113. margin: 20px 0;
  114. border-radius: 4px;
  115. }
  116. .pagination>li {
  117. display: inline;
  118. }
  119. input.page-number {
  120. vertical-align: inherit;
  121. display: inline-block;
  122. width: 40px;
  123. height: 31px;
  124. padding: 6px 6px;
  125. font-size: 14px;
  126. line-height: 1.42857143;
  127. color: #9B9792;
  128. text-align: center;
  129. background-color: #F6F5F4;
  130. background-image: none;
  131. border: 1px solid #ccc;
  132. border-top-left-radius: 4px;
  133. border-bottom-left-radius: 4px;
  134. box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
  135. transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
  136. }
  137. .page-a {
  138. background: #5078cb !important;
  139. color: #fff !important;
  140. float: right!important;
  141. }
  142. .page-a {
  143. color: #fff;
  144. border-color: #4574e8;
  145. padding: 6px 6px!important;
  146. font-size: 14px!important;
  147. border-top-right-radius: 4px!important;
  148. border-bottom-right-radius: 4px!important;
  149. text-decoration: none;
  150. height: 31px;
  151. }
  152. .page-wrap{
  153. float: right;
  154. margin: 30px 0;
  155. }
  156. .page-wrap ul, .page-wrap div {
  157. display: inline-block;
  158. margin: 0;
  159. }
  160. input.page-number {
  161. -moz-appearance:textfield;
  162. }
  163. input.page-number::-webkit-inner-spin-button,
  164. input.page-number::-webkit-outer-spin-button {
  165. -webkit-appearance: none;
  166. margin: 0;
  167. }
  168. </style>