table.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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: rgba(255, 255, 255, 0.1)"
  10. height="320px"
  11. :header-cell-style="headerCellStyle"
  12. :row-style="rowStyle"
  13. :cell-style="cellStyle"
  14. stripe
  15. border
  16. >
  17. <!-- 添加序号列 -->
  18. <el-table-column type="index" label="" width="100" align="center" />
  19. <el-table-column prop="c_path_comment" label="服务名称" />
  20. <el-table-column prop="service_type" label="类别" width="600" />
  21. <el-table-column prop="c_count" label="调用次数" width="280" />
  22. </el-table>
  23. <!-- <div class="table_pagination">
  24. <el-pagination
  25. v-model:current-page="currentPage"
  26. v-model:page-size="pageSize"
  27. :page-sizes="[100, 200, 300, 400]"
  28. background
  29. layout="total, sizes, prev, pager, next, jumper"
  30. :total="400"
  31. @size-change="handleSizeChange"
  32. @current-change="handleCurrentChange"
  33. />
  34. </div> -->
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. name: "Table",
  40. props: {
  41. title: {
  42. type: String,
  43. default: "图表标题",
  44. },
  45. tableData: {
  46. type: Array,
  47. default: () => [],
  48. },
  49. },
  50. data() {
  51. return {
  52. pageSize: 100,
  53. currentPage: 1,
  54. };
  55. },
  56. computed: {
  57. headerCellStyle() {
  58. return {
  59. backgroundColor: "rgba(24, 144, 255, 0.25)",
  60. color: "#0071e3",
  61. fontWeight: "bold",
  62. borderBottom: "2px solid rgba(24, 144, 255, 0.3)",
  63. padding: "12px 8px",
  64. };
  65. },
  66. rowStyle() {
  67. return {
  68. // 调整行背景色为更浅的黑色,增加透明度
  69. backgroundColor: "rgba(0, 0, 0, 0.05)",
  70. borderBottom: "1px solid rgba(255, 255, 255, 0.05)",
  71. transition: "all 0.3s ease",
  72. };
  73. },
  74. cellStyle() {
  75. return {
  76. color: "#e0e0e0",
  77. padding: "12px 8px",
  78. borderRight: "1px solid rgba(255, 255, 255, 0.05)",
  79. };
  80. },
  81. },
  82. methods: {
  83. handleSizeChange(val) {
  84. this.pageSize = val;
  85. },
  86. handleCurrentChange(val) {
  87. this.currentPage = val;
  88. },
  89. },
  90. };
  91. </script>
  92. <style lang="less" scoped>
  93. .table_box {
  94. width: 100%;
  95. height: 100%;
  96. padding: 20px;
  97. box-sizing: border-box;
  98. position: relative;
  99. // background-color: rgba(255, 255, 255, 0.1);
  100. border-radius: 8px;
  101. // box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  102. }
  103. .table_title {
  104. font-size: 18px;
  105. color: #ffffff;
  106. font-weight: bold;
  107. margin-bottom: 15px;
  108. padding-bottom: 8px;
  109. // border-bottom: 2px solid rgba(24, 144, 255, 0.2);
  110. }
  111. .table_more {
  112. position: absolute;
  113. top: 20px;
  114. right: 20px;
  115. font-size: 14px;
  116. color: #1890ff;
  117. .el-button {
  118. color: #0071e3;
  119. &:hover {
  120. color: #0056b3;
  121. }
  122. }
  123. }
  124. .table_pagination {
  125. position: absolute;
  126. bottom: 20px;
  127. right: 20px;
  128. .el-pagination {
  129. color: #e0e0e0;
  130. .btn-prev,
  131. .btn-next,
  132. .el-pager li {
  133. background-color: rgba(0, 0, 0, 0.3);
  134. color: #e0e0e0;
  135. border: 1px solid rgba(255, 255, 255, 0.1);
  136. &:hover {
  137. background-color: rgba(24, 144, 255, 0.2);
  138. color: #0071e3;
  139. border-color: rgba(24, 144, 255, 0.3);
  140. }
  141. }
  142. .el-pager li.active {
  143. background-color: rgba(24, 144, 255, 0.3);
  144. color: #0071e3;
  145. border-color: rgba(24, 144, 255, 0.5);
  146. }
  147. }
  148. }
  149. // 美化表格行悬停效果
  150. :deep(.el-table__body tr:hover > td) {
  151. background-color: rgba(24, 144, 255, 0.1) !important;
  152. }
  153. // 美化表格边框
  154. :deep(.el-table__inner-wrapper) {
  155. border-radius: 6px;
  156. overflow: hidden;
  157. }
  158. :deep(.el-table__cell) {
  159. border-right: 1px solid rgba(255, 255, 255, 0.05);
  160. }
  161. :deep(.el-table__row) {
  162. border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  163. }
  164. // 调整奇偶行背景色,使其更明亮
  165. :deep(.el-table--striped .el-table__body tr.el-table__row--striped) {
  166. background-color: rgba(255, 255, 255, 0.02) !important;
  167. }
  168. // 调整表格主体背景色
  169. :deep(.el-table__body) {
  170. background-color: rgba(0, 0, 0, 0.05);
  171. }
  172. :deep(.el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell) {
  173. background-color: rgba(255, 255, 255, 0.02);
  174. }
  175. </style>