StatisticsTable.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <scroll-view class="content" scroll-y @scrolltolower="loadMore">
  3. <!-- 数据汇总 -->
  4. <view class="summary-section x-bc">
  5. <view class="summary-header">
  6. <view class="summary-indicator"></view>
  7. <text class="summary-title">{{ summaryTitle||'' }}</text>
  8. </view>
  9. <view class="summary-stats">
  10. <view class="stat-item" v-for="stat in summaryStats" :key="stat.label">
  11. <text class="stat-label">{{ stat.label||'未定义' }}</text>
  12. <text class="stat-value">{{ stat.value||'' }}</text>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 数据表格 -->
  17. <view class="table-section">
  18. <view class="table-header">
  19. <view
  20. class="table-col"
  21. v-for="(column, index) in columns"
  22. :key="index"
  23. :style="{ width: column.width }"
  24. >
  25. {{ column.title ||''}}
  26. </view>
  27. </view>
  28. <view class="table-body">
  29. <view class="table-row" v-for="(item, index) in tableData" :key="index">
  30. <view
  31. class="table-col"
  32. v-for="(column, colIndex) in columns"
  33. :key="colIndex"
  34. :style="{ width: column.width }"
  35. >
  36. <!-- 直接显示数据,不使用插槽,避免同名插槽警告 -->
  37. <template v-if="column.key === 'statusText'">
  38. <text class="status-tag" :class="item.status">{{ item[column.key]||'' }}</text>
  39. </template>
  40. <template v-else>
  41. {{ item[column.key] ||''}}
  42. </template>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 底部提示 -->
  48. <!-- <view class="no-more" v-if="showNoMore">{{ noMoreText }}</view> -->
  49. </scroll-view>
  50. </template>
  51. <script>
  52. export default {
  53. name: 'StatisticsTable',
  54. props: {
  55. // 汇总标题
  56. summaryTitle: {
  57. type: String,
  58. default: '数据汇总'
  59. },
  60. // 汇总统计数据
  61. summaryStats: {
  62. type: Array,
  63. default: () => [
  64. { label: '任务数', value: 0 },
  65. { label: '总积分', value: 0 }
  66. ]
  67. },
  68. // 表格列配置
  69. columns: {
  70. type: Array,
  71. default: () => [
  72. ]
  73. },
  74. // 表格数据
  75. tableData: {
  76. type: Array,
  77. default: () => []
  78. },
  79. // 是否加载中
  80. loading: {
  81. type: Boolean,
  82. default: false
  83. }
  84. },
  85. methods: {
  86. loadMore() {
  87. if (!this.loading) {
  88. this.$emit('load-more')
  89. }
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .content {
  96. flex: 1;
  97. background: #fff;
  98. }
  99. .summary-section {
  100. background: #fff;
  101. padding: 32rpx 24rpx;
  102. .summary-header {
  103. display: flex;
  104. align-items: center;
  105. .summary-indicator {
  106. width: 6rpx;
  107. height: 32rpx;
  108. background: #388BFF;
  109. border-radius: 3rpx;
  110. margin-right: 16rpx;
  111. }
  112. .summary-title {
  113. font-size: 32rpx;
  114. font-weight: bold;
  115. color: #333;
  116. }
  117. }
  118. .summary-stats {
  119. display: flex;
  120. gap: 48rpx;
  121. .stat-item {
  122. display: flex;
  123. flex-direction: row;
  124. align-items: center;
  125. gap: 16rpx;
  126. .stat-label {
  127. font-size: 24rpx;
  128. color: #999;
  129. }
  130. .stat-value {
  131. font-size: 36rpx;
  132. font-weight: bold;
  133. color: #388BFF;
  134. }
  135. }
  136. }
  137. }
  138. .table-section {
  139. background: #fff;
  140. padding: 0 24rpx;
  141. .table-header {
  142. display: flex;
  143. background: #E3EFFF;
  144. padding: 24rpx 16rpx;
  145. .table-col {
  146. font-family: PingFang SC, PingFang SC;
  147. font-weight: 500;
  148. font-size: 26rpx;
  149. color: #333333;
  150. line-height: 40rpx;
  151. text-align: left;
  152. }
  153. }
  154. .table-body {
  155. .table-row {
  156. display: flex;
  157. padding: 24rpx 16rpx;
  158. &:nth-child(2n) {
  159. background: #F7F8FA;
  160. border-radius: 8rpx 8rpx 8rpx 8rpx;
  161. }
  162. .table-col {
  163. font-size: 26rpx;
  164. color: #333;
  165. display: flex;
  166. align-items: center;
  167. text-align: left;
  168. font-family: PingFang SC, PingFang SC;
  169. font-weight: 400;
  170. font-size: 26rpx;
  171. line-height: 40rpx;
  172. }
  173. }
  174. }
  175. }
  176. .no-more {
  177. text-align: center;
  178. padding: 48rpx 0;
  179. font-size: 24rpx;
  180. color: #999;
  181. }
  182. </style>