StatisticsTable.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. { title: '任务类型', key: 'taskType', width: '20%' },
  80. { title: '积分', key: 'points', width: '15%' },
  81. { title: '申请人员', key: 'applicant', width: '20%' },
  82. { title: '任务状态', key: 'statusText', width: '20%', slot: true },
  83. { title: '接收时间', key: 'receiveTime', width: '25%' }
  84. ]
  85. },
  86. // 表格数据
  87. tableData: {
  88. type: Array,
  89. default: () => []
  90. },
  91. // 是否显示没有更多了
  92. // showNoMore: {
  93. // type: Boolean,
  94. // default: true
  95. // },
  96. // 没有更多的提示文字
  97. // noMoreText: {
  98. // type: String,
  99. // default: '没有更多了~'
  100. // },
  101. // 是否加载中
  102. loading: {
  103. type: Boolean,
  104. default: false
  105. }
  106. },
  107. methods: {
  108. loadMore() {
  109. if (!this.loading) {
  110. this.$emit('load-more')
  111. }
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .content {
  118. flex: 1;
  119. background: #fff;
  120. }
  121. .summary-section {
  122. background: #fff;
  123. padding: 32rpx 24rpx;
  124. .summary-header {
  125. display: flex;
  126. align-items: center;
  127. .summary-indicator {
  128. width: 6rpx;
  129. height: 32rpx;
  130. background: #388BFF;
  131. border-radius: 3rpx;
  132. margin-right: 16rpx;
  133. }
  134. .summary-title {
  135. font-size: 32rpx;
  136. font-weight: bold;
  137. color: #333;
  138. }
  139. }
  140. .summary-stats {
  141. display: flex;
  142. gap: 48rpx;
  143. .stat-item {
  144. display: flex;
  145. flex-direction: row;
  146. align-items: center;
  147. gap: 16rpx;
  148. .stat-label {
  149. font-size: 24rpx;
  150. color: #999;
  151. }
  152. .stat-value {
  153. font-size: 36rpx;
  154. font-weight: bold;
  155. color: #388BFF;
  156. }
  157. }
  158. }
  159. }
  160. .table-section {
  161. background: #fff;
  162. padding: 0 24rpx;
  163. .table-header {
  164. display: flex;
  165. background: #E3EFFF;
  166. padding: 24rpx 16rpx;
  167. .table-col {
  168. font-family: PingFang SC, PingFang SC;
  169. font-weight: 500;
  170. font-size: 26rpx;
  171. color: #333333;
  172. line-height: 40rpx;
  173. text-align: left;
  174. }
  175. }
  176. .table-body {
  177. .table-row {
  178. display: flex;
  179. padding: 24rpx 16rpx;
  180. &:nth-child(2n) {
  181. background: #F7F8FA;
  182. border-radius: 8rpx 8rpx 8rpx 8rpx;
  183. }
  184. .table-col {
  185. font-size: 26rpx;
  186. color: #333;
  187. display: flex;
  188. align-items: center;
  189. text-align: left;
  190. font-family: PingFang SC, PingFang SC;
  191. font-weight: 400;
  192. font-size: 26rpx;
  193. line-height: 40rpx;
  194. }
  195. }
  196. }
  197. }
  198. .no-more {
  199. text-align: center;
  200. padding: 48rpx 0;
  201. font-size: 24rpx;
  202. color: #999;
  203. }
  204. </style>