StatisticsTable.vue 4.4 KB

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