pageComponent.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. min-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: #20a0ff!important;
  97. border: none;
  98. }
  99. .el-icon-arrow-left:before {
  100. content: "\f100";
  101. font-family: FontAwesome;
  102. }
  103. .el-icon-arrow-right:before {
  104. content: "\f101";
  105. font-family: FontAwesome;
  106. }
  107. .el-pagination button.disabled {
  108. color: #337ab7;
  109. background-color: #fff;
  110. cursor: not-allowed;
  111. }
  112. .pagination {
  113. display: inline-block;
  114. padding-left: 0;
  115. margin: 20px 0;
  116. border-radius: 4px;
  117. }
  118. .pagination>li {
  119. display: inline;
  120. }
  121. input.page-number {
  122. vertical-align: inherit;
  123. display: inline-block;
  124. width: 40px;
  125. height: 31px;
  126. padding: 6px 6px;
  127. font-size: 14px;
  128. line-height: 1.42857143;
  129. color: #9B9792;
  130. text-align: center;
  131. background-color: #F6F5F4;
  132. background-image: none;
  133. border: 1px solid #ccc;
  134. border-top-left-radius: 4px;
  135. border-bottom-left-radius: 4px;
  136. box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
  137. transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
  138. }
  139. .page-a {
  140. background: #2496f1 !important;
  141. color: #fff !important;
  142. float: right!important;
  143. }
  144. .page-a {
  145. color: #fff;
  146. border-color: #2496f1;
  147. padding: 6px 6px!important;
  148. font-size: 14px!important;
  149. border-top-right-radius: 4px!important;
  150. border-bottom-right-radius: 4px!important;
  151. text-decoration: none;
  152. height: 31px;
  153. }
  154. .page-wrap{
  155. float: right;
  156. margin: 30px 15px;
  157. }
  158. .page-wrap ul, .page-wrap div {
  159. display: inline-block;
  160. margin: 0;
  161. }
  162. input.page-number {
  163. -moz-appearance:textfield;
  164. }
  165. input.page-number::-webkit-inner-spin-button,
  166. input.page-number::-webkit-outer-spin-button {
  167. -webkit-appearance: none;
  168. margin: 0;
  169. }
  170. </style>