StatisticsTable.vue 4.8 KB

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