tableRanking.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!-- 表格 -->
  2. <template>
  3. <view class="container">
  4. <view class="table" :style="{ padding: padding }">
  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. padding: {
  41. type: String,
  42. default: '15px'
  43. },
  44. tableTh: {
  45. type: Array,
  46. default: () => {
  47. return []
  48. }
  49. },
  50. tableData: {
  51. type: Object,
  52. default: () => {
  53. return {
  54. current: 1,
  55. total: 0,
  56. list: []
  57. }
  58. }
  59. }
  60. },
  61. methods: {
  62. pageChange(e) {
  63. this.$emit('pageChange', e.current)
  64. }
  65. }
  66. }
  67. </script>
  68. /**
  69. * tableTh
  70. * [{ width: '', field: '', key: '' }] width表示单列的宽度 field表示单列的表头名称 key表示单列字段名
  71. */
  72. <style lang="scss" scoped>
  73. @import '@/pages/dataOverview/statisticalReport/components/report.scss';
  74. </style>