uni-stat-table.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <uni-table :loading="loading" border stripe emptyText="暂无数据">
  3. <uni-tr>
  4. <template v-for="(mapper, index) in filedsMap">
  5. <uni-th v-if="mapper.title" :key="index" align="center">
  6. <!-- #ifdef MP -->
  7. {{mapper.title}}
  8. <!-- #endif -->
  9. <!-- #ifndef MP -->
  10. <uni-tooltip>
  11. {{mapper.title}}
  12. <uni-icons v-if="tooltip && mapper.tooltip" type="help" color="#666" />
  13. <template v-if="tooltip && mapper.tooltip" v-slot:content>
  14. <view class="uni-stat-tooltip-s">
  15. {{mapper.tooltip}}
  16. </view>
  17. </template>
  18. </uni-tooltip>
  19. <!-- #endif -->
  20. </uni-th>
  21. </template>
  22. </uni-tr>
  23. <uni-tr v-for="(item ,i) in data" :key="i">
  24. <template v-for="(mapper, index) in filedsMap">
  25. <uni-td v-if="mapper.title" :key="index" align="center">
  26. {{item[mapper.field] !== undefined ? item[mapper.field] : '-'}}
  27. </uni-td>
  28. </template>
  29. </uni-tr>
  30. </uni-table>
  31. </template>
  32. <script>
  33. export default {
  34. name: "uni-stat-table",
  35. data() {
  36. return {
  37. };
  38. },
  39. props: {
  40. data: {
  41. type: Array,
  42. default: () => {
  43. return []
  44. }
  45. },
  46. filedsMap: {
  47. type: Array,
  48. default: () => {
  49. return []
  50. }
  51. },
  52. loading: {
  53. type: Boolean,
  54. default: false
  55. },
  56. tooltip: {
  57. type: Boolean,
  58. default: false
  59. }
  60. }
  61. }
  62. </script>
  63. <style>
  64. .uni-stat-tooltip-s {
  65. width: 160px;
  66. white-space: normal;
  67. }
  68. </style>