tableRanking.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!-- 表格 -->
  2. <template>
  3. <view class="container">
  4. <view class="table">
  5. <view class="table-title" v-if="title">{{ title }}</view>
  6. <view class="table-box">
  7. <uni-table emptyText="暂无更多数据" :loading="loading">
  8. <!-- 表头行 -->
  9. <uni-tr>
  10. <uni-th class="table-box-th" align="center" v-for="(item, index) in tableTh" :key="index"
  11. :width="item.width || ''">{{ item.field }}
  12. </uni-th>
  13. </uni-tr>
  14. <!-- 表格数据行 -->
  15. <uni-tr v-for="(item, index) in tableData.list" :key="index">
  16. <uni-td class="table-box-td" align="center" v-for="(field, index) in tableTh" :key="index">
  17. {{ item[field.key] }}</uni-td>
  18. </uni-tr>
  19. </uni-table>
  20. </view>
  21. <view class="table-pagination" v-if="tableData.total > 0">
  22. <uni-pagination show-icon="true" :total="tableData.total" :current="tableData.current" @change="pageChange"></uni-pagination>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. props: {
  30. title: {
  31. type: String,
  32. default: ''
  33. },
  34. loading: {
  35. type: Boolean,
  36. default: () => {
  37. return false
  38. }
  39. },
  40. tableTh: {
  41. type: Array,
  42. default: () => {
  43. return []
  44. }
  45. },
  46. tableData: {
  47. type: Object,
  48. default: () => {
  49. return {
  50. current: 1,
  51. total: 0,
  52. list: []
  53. }
  54. }
  55. }
  56. },
  57. methods: {
  58. pageChange(e) {
  59. this.$emit('pageChange', e.current)
  60. }
  61. }
  62. }
  63. </script>
  64. /**
  65. * tableTh
  66. * [{ width: '', field: '', key: '' }] width表示单列的宽度 field表示单列的表头名称 key表示单列字段名
  67. */
  68. <style lang="scss" scoped>
  69. @import '@/pages/dataOverview/statisticalReport/components/report.scss';
  70. </style>