myTable.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <uni-table :loading="loading" stripe emptyText="暂无更多数据">
  3. <uni-tr>
  4. <uni-th align="center">
  5. <image src="../../static/tip.svg" style="width: 35rpx;height: 35rpx;"></image>
  6. </uni-th>
  7. <uni-th v-for="(item, index) in column" :key="index" align="center">{{item.title}}</uni-th>
  8. </uni-tr>
  9. <uni-tr v-for="(item, index) in tableData" :key="index">
  10. <uni-td align="center">
  11. <view :style="{
  12. 'width': '20rpx',
  13. 'height': '20rpx',
  14. 'background-color': 'green',
  15. 'border-radius': '50%',
  16. 'display': 'inline-block'
  17. }"
  18. ></view>
  19. </uni-td>
  20. <template v-for="(it, i) in column" :key="i">
  21. <uni-td align="center" v-for="(val,key,idx) in item" :key="idx" v-show="it.key === key">
  22. <text v-if="it.formatter">{{ it.formatter(item[it.key]) }}</text>
  23. <text v-else>{{ item[it.key] }}</text>
  24. </uni-td>
  25. </template>
  26. <uni-td align="center" width="180">
  27. <view class="uni-group">
  28. <slot name="action" :row="item" :blUrl="props.blUrl"></slot>
  29. </view>
  30. </uni-td>
  31. </uni-tr>
  32. </uni-table>
  33. <view class="uni-pagination-box">
  34. <uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="change" />
  35. </view>
  36. </template>
  37. <script setup>
  38. import {ref} from "vue"
  39. const emits = defineEmits(['pageChange'])
  40. const props = defineProps({
  41. column:{
  42. type: Array,
  43. default: []
  44. },
  45. tableData:{
  46. type: Array,
  47. default: []
  48. },
  49. pageCurrent:{
  50. type: Number,
  51. default: 1
  52. },
  53. pageSize:{
  54. type: Number,
  55. default: 10
  56. },
  57. total:{
  58. type: Number,
  59. default: 0
  60. },
  61. loading:{
  62. type: Boolean,
  63. default: false
  64. },
  65. blUrl:{
  66. type: String,
  67. default: ''
  68. }
  69. })
  70. function change(e){
  71. emits('pageChange', e.current)
  72. }
  73. </script>
  74. <style lang="scss" scope>
  75. .uni-group {
  76. display: flex;
  77. flex-direction: row;
  78. justify-content: space-around;
  79. align-items: center;
  80. }
  81. .uni-pagination-box{
  82. padding: 20rpx;
  83. .uni-pagination{
  84. justify-content: end;
  85. }
  86. }
  87. ::v-deep .uni-table{
  88. min-width: 800rpx !important;
  89. }
  90. </style>