tablePage.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 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. >
  25. <template #default="scope">
  26. <slot
  27. v-if="item.slot"
  28. :name="item.slot ? item.slot : ''"
  29. v-bind="scope"
  30. ></slot>
  31. <span v-else>{{ scope.row[item.prop] || "-" }}</span>
  32. </template>
  33. </el-table-column>
  34. </el-table>
  35. <div class="tabs-pagation" v-if="table.data.length">
  36. <div class="font">共{{ table.total }}条记录</div>
  37. <!-- <el-pagination class="tabone-pagination" background layout="prev, pager, next" :current-page="pageNum"
  38. :pager-count="5" :page-size="5" :total="table.total" @current-change="changePage" /> -->
  39. <el-pagination
  40. :current-page="pageNum"
  41. :page-size="pageSize"
  42. :small="false"
  43. :disabled="false"
  44. :background="true"
  45. layout="prev, pager, next, jumper,sizes"
  46. :page-sizes="[10, 15, 20, 30, 50]"
  47. :total="table.total"
  48. @size-change="handleSizeChange"
  49. @current-change="changePage"
  50. />
  51. </div>
  52. </div>
  53. </template>
  54. <script >
  55. export default {
  56. components: {},
  57. props: {
  58. cloumn: {
  59. type: Array,
  60. default: [],
  61. },
  62. table: {
  63. type: Object,
  64. },
  65. },
  66. data() {
  67. return {
  68. pageNum: 1,
  69. pageSize: 10,
  70. };
  71. },
  72. mounted() {},
  73. methods: {
  74. // 搜索
  75. searchFun() {
  76. this.$emit("search", {
  77. pageIndex: this.pageNum,
  78. size: this.pageSize,
  79. });
  80. },
  81. // 修改当前页数
  82. changePage(v) {
  83. this.pageNum = v;
  84. this.searchFun();
  85. },
  86. handleSizeChange(v) {
  87. this.pageSize = v;
  88. this.searchFun();
  89. },
  90. },
  91. beforeDestroy() {},
  92. watch: {},
  93. };
  94. // searchFun()
  95. </script>
  96. <style lang="scss" scoped>
  97. .el-table {
  98. height: calc(100% - 50px);
  99. }
  100. .tabs-pagation {
  101. position: absolute;
  102. right: 30px;
  103. }
  104. //@import url(../assets/styles/tabs.scss);
  105. </style>