table.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="table-wrap">
  3. <view class="table-head">
  4. <view v-for="(item, index) in tableHead" :key="index" class="th">
  5. {{ item }}
  6. </view>
  7. </view>
  8. <view v-for="(item,index) in list" :key="index" class="table-body">
  9. <view class="tb">
  10. {{ item.name }}
  11. </view>
  12. <view class="tb" v-for="(item1,index1) in item.params" :key="index1" :style="{color: fontColor(item1)}">
  13. <template v-if="item1.status !== undefined && item1.data === undefined">
  14. <view :class="item1.status === 'true' || item1.status === 1 ? 'success' : 'error'"></view>
  15. </template>
  16. <template v-else>{{ item1.data ? item1.data : item1 }}</template>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. }
  26. },
  27. props: ['list', 'tableHead'],
  28. onLoad() {
  29. },
  30. methods: {
  31. fontColor(data) {
  32. if (data.data && data.status) {
  33. return '#00FF00'
  34. } else if (data.data && !data.status) {
  35. return '#FF0000'
  36. } else {
  37. return '#000000'
  38. }
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped lang="scss">
  44. .table-wrap {
  45. .table-head {
  46. display: flex;
  47. align-items: center;
  48. height: 92rpx;
  49. .th {
  50. flex: 1;
  51. font-weight: 700;
  52. font-size: 28rpx;
  53. color: #7A7A7A;
  54. text-align: center;
  55. }
  56. }
  57. .table-body {
  58. display: flex;
  59. align-items: center;
  60. border-top: 1px dashed #E5E5E5;
  61. .tb:first-child {
  62. font-size: 28rpx;
  63. color: #A1A1A1;
  64. }
  65. .tb {
  66. display: flex;
  67. justify-content: center;
  68. font-size: 28rpx;
  69. color: #000000;
  70. flex: 1;
  71. text-align: center;
  72. padding: 23rpx 0;
  73. height: 100%;
  74. .success {
  75. width: 38rpx;
  76. height: 38rpx;
  77. background: #00BD00;
  78. border-radius: 6rpx;
  79. }
  80. .error {
  81. width: 38rpx;
  82. height: 38rpx;
  83. background: #D6000F;
  84. border-radius: 6rpx;
  85. }
  86. }
  87. }
  88. }
  89. </style>