page.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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: #0d5ffe;
  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: #0d5ffe;
  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. border: 1px solid #c9c9c9;
  75. padding-left: 8px;
  76. }
  77. .el-pagination .btn-prev {
  78. border-top-left-radius: 4px;
  79. border-bottom-left-radius: 4px;
  80. border: 1px solid #c9c9c9;
  81. border-right:0;
  82. padding-right: 8px;
  83. }
  84. .el-pager li{
  85. color: #0d5ffe;
  86. text-decoration: none;
  87. background-color: #fff;
  88. border: 1px solid #c9c9c9;
  89. font-size: 10px;
  90. min-width: 33px;
  91. height: 30px;
  92. border-right: none;
  93. }
  94. .el-pager li:not(.active):hover, .el-pagination button:hover {
  95. z-index: 3;
  96. color: #fff;
  97. background-color: #0d5ffe;
  98. border-color: #c9c9c9;
  99. }
  100. .el-pager li.active {
  101. background: #0d5ffe!important;
  102. color:#fff;
  103. }
  104. .el-icon-arrow-left:before {
  105. content: "\f100";
  106. font-family: FontAwesome;
  107. }
  108. .el-icon-arrow-right:before {
  109. content: "\f101";
  110. font-family: FontAwesome;
  111. }
  112. .el-pagination button.disabled {
  113. color: #0d5ffe;
  114. background-color: #F6F5F4;
  115. cursor: not-allowed;
  116. }
  117. .pagination {
  118. display: inline-block;
  119. padding-left: 0;
  120. margin: 20px 0;
  121. border-radius: 4px;
  122. }
  123. .pagination>li {
  124. display: inline;
  125. }
  126. input.page-number {
  127. vertical-align: inherit;
  128. display: inline-block;
  129. width: 40px;
  130. height: 31px;
  131. padding: 6px 6px;
  132. font-size: 14px;
  133. line-height: 1.42857143;
  134. color: #9B9792;
  135. text-align: center;
  136. background-color: #F6F5F4;
  137. background-image: none;
  138. border: 1px solid #c9c9c9;
  139. border-top-left-radius: 4px;
  140. border-bottom-left-radius: 4px;
  141. box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
  142. transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
  143. }
  144. .page-a {
  145. background: #0d5ffe !important;
  146. color: #fff !important;
  147. float: right!important;
  148. }
  149. .page-a {
  150. color: #fff;
  151. border-color: #0d5ffe;
  152. padding: 6px 6px!important;
  153. font-size: 14px!important;
  154. border-top-right-radius: 4px!important;
  155. border-bottom-right-radius: 4px!important;
  156. text-decoration: none;
  157. height: 31px;
  158. }
  159. .page-wrap{
  160. float: right;
  161. margin: 30px 0;
  162. }
  163. .page-wrap ul, .page-wrap div {
  164. display: inline-block;
  165. margin: 0;
  166. }
  167. input.page-number {
  168. -moz-appearance:textfield;
  169. }
  170. input.page-number::-webkit-inner-spin-button,
  171. input.page-number::-webkit-outer-spin-button {
  172. -webkit-appearance: none;
  173. margin: 0;
  174. }
  175. </style>