table.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="table_box">
  3. <div class="table_title">{{ title }}</div>
  4. <div class="table_more">
  5. <el-button type="primary" link> 更多 </el-button>
  6. </div>
  7. <el-table
  8. :data="tableData"
  9. style="width: 100%; background-color: #00000032"
  10. height="calc(100% - 60px)"
  11. >
  12. <el-table-column prop="serviceName" label="服务名称" width="300" />
  13. <el-table-column prop="serviceType" label="类别" width="300" />
  14. <el-table-column prop="callCount" label="调用次数" width="480" />
  15. <el-table-column prop="successRate" label="成功率" width="180" />
  16. <el-table-column prop="avgResponseTime" label="平均响应" />
  17. </el-table>
  18. <div class="table_pagination">
  19. <el-pagination
  20. v-model:current-page="currentPage"
  21. v-model:page-size="pageSize"
  22. :page-sizes="[100, 200, 300, 400]"
  23. background
  24. layout="total, sizes, prev, pager, next, jumper"
  25. :total="400"
  26. @size-change="handleSizeChange"
  27. @current-change="handleCurrentChange"
  28. />
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. export default {
  34. name: "Table",
  35. props: {
  36. title: {
  37. type: String,
  38. default: "图表标题",
  39. },
  40. tableData: {
  41. type: Array,
  42. default: () => [],
  43. },
  44. },
  45. data() {
  46. return {
  47. pageSize: 100,
  48. currentPage: 1,
  49. };
  50. },
  51. methods: {
  52. handleSizeChange(val) {
  53. this.pageSize = val;
  54. },
  55. handleCurrentChange(val) {
  56. this.currentPage = val;
  57. },
  58. },
  59. };
  60. </script>
  61. <style lang="less" scoped>
  62. .table_box {
  63. width: 100%;
  64. height: 100%;
  65. padding: 20px;
  66. box-sizing: border-box;
  67. position: relative;
  68. }
  69. .table_title {
  70. font-size: 16px;
  71. }
  72. .table_more {
  73. position: absolute;
  74. top: 20px;
  75. right: 20px;
  76. font-size: 14px;
  77. color: #1890ff;
  78. }
  79. .table_pagination {
  80. position: absolute;
  81. bottom: 20px;
  82. right: 20px;
  83. }
  84. </style>