pageComponent.vue 3.9 KB

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