table.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="table_box">
  3. <div class="table_title">{{ title }}</div>
  4. <el-table
  5. :data="tableData"
  6. style="width: 100%; background-color: rgba(255, 255, 255, 0.1)"
  7. height="320px"
  8. :header-cell-style="headerCellStyle"
  9. :row-style="rowStyle"
  10. :cell-style="cellStyle"
  11. stripe
  12. border
  13. >
  14. <!-- 添加序号列 -->
  15. <el-table-column type="index" label="序号" width="100" align="center" />
  16. <el-table-column prop="path_comment" label="服务名称" />
  17. <el-table-column prop="type" label="类别" width="600" />
  18. <el-table-column prop="count" label="调用次数" width="280" />
  19. </el-table>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: "Table",
  25. props: {
  26. title: {
  27. type: String,
  28. default: "图表标题",
  29. },
  30. tableData: {
  31. type: Array,
  32. default: () => [],
  33. },
  34. },
  35. data() {
  36. return {
  37. pageSize: 100,
  38. currentPage: 1,
  39. };
  40. },
  41. computed: {
  42. headerCellStyle() {
  43. return {
  44. // backgroundColor: "rgba(24, 144, 255, 0.25)",
  45. color: "#fff",
  46. fontWeight: "bold",
  47. // borderBottom: "2px solid rgba(24, 144, 255, 0.3)",
  48. padding: "12px 8px",
  49. };
  50. },
  51. rowStyle() {
  52. return {
  53. // 调整行背景色为更浅的黑色,增加透明度
  54. backgroundColor: "rgba(0, 0, 0, 0.05)",
  55. borderBottom: "1px solid rgba(255, 255, 255, 0.05)",
  56. transition: "all 0.3s ease",
  57. };
  58. },
  59. cellStyle() {
  60. return {
  61. color: "#e0e0e0",
  62. padding: "12px 8px",
  63. borderRight: "1px solid rgba(255, 255, 255, 0.05)",
  64. };
  65. },
  66. },
  67. methods: {
  68. handleSizeChange(val) {
  69. this.pageSize = val;
  70. },
  71. handleCurrentChange(val) {
  72. this.currentPage = val;
  73. },
  74. },
  75. };
  76. </script>
  77. <style lang="less" scoped>
  78. .table_box {
  79. width: 100%;
  80. height: 100%;
  81. padding: 20px;
  82. box-sizing: border-box;
  83. position: relative;
  84. border-radius: 8px;
  85. }
  86. .table_title {
  87. font-size: 18px;
  88. color: #ffffff;
  89. font-weight: bold;
  90. margin-bottom: 15px;
  91. padding-bottom: 8px;
  92. }
  93. // 美化表格行悬停效果
  94. :deep(.el-table__body tr:hover > td) {
  95. background-color: rgba(24, 144, 255, 0.1) !important;
  96. }
  97. // 美化表格边框
  98. :deep(.el-table__inner-wrapper) {
  99. border-radius: 6px;
  100. overflow: hidden;
  101. }
  102. :deep(.el-table__cell) {
  103. border-right: 1px solid rgba(255, 255, 255, 0.05);
  104. }
  105. :deep(.el-table__row) {
  106. border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  107. }
  108. // 调整奇偶行背景色,使其更明亮
  109. :deep(.el-table--striped .el-table__body tr.el-table__row--striped) {
  110. background-color: rgba(255, 255, 255, 0.02) !important;
  111. }
  112. // 调整表格主体背景色
  113. :deep(.el-table__body) {
  114. background-color: rgba(0, 0, 0, 0.05);
  115. }
  116. :deep(.el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell) {
  117. background-color: rgba(255, 255, 255, 0.02);
  118. }
  119. </style>