tablePage.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="cont-table">
  3. <!-- :image="nonedataImg" -->
  4. <el-empty description=" " v-if="table.data.length == 0" />
  5. <el-table
  6. :data="table.data"
  7. v-else
  8. style="width: 100%"
  9. :show-overflow-tooltip="true"
  10. header-row-class-name="datatable"
  11. row-class-name="datarow"
  12. fit
  13. >
  14. <el-table-column v-if="indexed" label="序号" width="70px">
  15. <template slot-scope="scope">{{ scope.$index + 1 }}</template>
  16. </el-table-column>
  17. <el-table-column
  18. v-for="(item, index) in cloumn"
  19. :prop="item.prop"
  20. :label="item.label"
  21. :key="index"
  22. show-overflow-tooltip
  23. :width="item.width || null"
  24. :fixed="item.fixed"
  25. >
  26. <template #default="scope">
  27. <slot
  28. v-if="item.slot"
  29. :name="item.slot ? item.slot : ''"
  30. v-bind="scope"
  31. ></slot>
  32. <span v-else>{{ scope.row[item.prop] || "-" }}</span>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <div class="tabs-pagation" v-if="table.data.length">
  37. <div class="font" v-if="showTotal">共{{ table.total }}条记录</div>
  38. <!-- <el-pagination class="tabone-pagination" background layout="prev, pager, next" :current-page="pageNum"
  39. :pager-count="5" :page-size="5" :total="table.total" @current-change="changePage" /> -->
  40. <el-pagination
  41. :current-page="pageNum"
  42. :page-size="pageSize"
  43. :small="false"
  44. :disabled="false"
  45. :background="true"
  46. :layout="layout"
  47. :page-sizes="[10, 15, 20, 30, 50]"
  48. :total="table.total"
  49. @size-change="handleSizeChange"
  50. @current-change="changePage"
  51. />
  52. </div>
  53. </div>
  54. </template>
  55. <script >
  56. export default {
  57. components: {},
  58. props: {
  59. indexed: {
  60. type: Boolean,
  61. default: true,
  62. },
  63. cloumn: {
  64. type: Array,
  65. default: [],
  66. },
  67. table: {
  68. type: Object,
  69. },
  70. showTotal: {
  71. type: Boolean,
  72. default: true,
  73. },
  74. layout: {
  75. type: String,
  76. default: "total, sizes, prev, pager, next, jumper",
  77. },
  78. },
  79. data() {
  80. return {
  81. pageNum: 1,
  82. pageSize: 10,
  83. };
  84. },
  85. mounted() {},
  86. methods: {
  87. // 搜索
  88. searchFun() {
  89. this.$emit("search", {
  90. pageIndex: this.pageNum,
  91. size: this.pageSize,
  92. });
  93. },
  94. // 修改当前页数
  95. changePage(v) {
  96. this.pageNum = v;
  97. this.searchFun();
  98. },
  99. handleSizeChange(v) {
  100. this.pageSize = v;
  101. this.searchFun();
  102. },
  103. },
  104. beforeDestroy() {},
  105. watch: {},
  106. };
  107. // searchFun()
  108. </script>
  109. <style lang="scss" scoped>
  110. .el-table {
  111. height: calc(100% - 50px);
  112. }
  113. .tabs-pagation {
  114. position: absolute;
  115. right: 30px;
  116. }
  117. </style>
  118. <style lang="scss" >
  119. .cont-table {
  120. .el-pager li {
  121. background-color: transparent !important;
  122. // border: 1px solid #3ea6fe;
  123. border-radius: 5px;
  124. }
  125. .el-pager li.active {
  126. color: #3ea6fe !important;
  127. }
  128. .el-pagination button {
  129. color: #dbdbdb;
  130. }
  131. .el-pagination .btn-prev,
  132. .el-pagination .btn-next {
  133. background-color: transparent;
  134. // border: 1px solid #ebebeb;
  135. border-radius: 5px;
  136. line-height: 28px;
  137. }
  138. .el-pagination .btn-prev {
  139. padding-right: 5px;
  140. }
  141. .el-pagination .btn-prev:hover {
  142. color: #1890ff;
  143. }
  144. }
  145. // @import url(./tabs.scss);
  146. </style>