CustomTable-green.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="table__content">
  3. <div class="table__content_label" :class="`table__content_label_${type}`">
  4. <div class="label-t" v-for="(item, index) in columns" :key="`svvhbcth-${index}`" :style="{ flexBasis }">{{ item.name }}</div>
  5. </div>
  6. <div class="table__content_list" :class="`table__content_list_${type}`">
  7. <div class="table__content_list_row" v-for="(item, index) in data" :key="`svvhbct-${index}`">
  8. <div v-for="(t, i) in columns" :key="`svvhbctr-${i}`" :style="{ flexBasis }" :class="`table__content__list_item_${type}`">
  9. <slot :name="t.prop" :scope="item">
  10. <span>{{ get(item, t.prop) }}</span>
  11. </slot>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script lang="ts" setup>
  18. import { computed, defineProps } from 'vue';
  19. import _ from 'lodash';
  20. let props = withDefaults(
  21. defineProps<{
  22. /** B | C */
  23. type: string;
  24. /** 列表表头配置,每个prop都有其对应的slot来提供定制化功能 */
  25. columns: { prop: string; name: string }[];
  26. data: any[];
  27. defaultValue: string;
  28. }>(),
  29. {
  30. type: 'B',
  31. columns: () => [],
  32. data: () => [],
  33. defaultValue: '-',
  34. }
  35. );
  36. const flexBasis = computed(() => {
  37. return Math.fround(100 / props.columns.length) + '%';
  38. });
  39. function get(o, p) {
  40. const d = _.get(o, p);
  41. return _.isNil(d) ? props.defaultValue : d === '' ? props.defaultValue : d;
  42. }
  43. </script>
  44. <style lang="less" scoped>
  45. @import '/@/design/theme.less';
  46. @import '@/design/theme.less';
  47. @font-face {
  48. font-family: 'douyuFont';
  49. src: url('/@/assets/font/douyuFont.otf');
  50. }
  51. @{theme-deepblue} {
  52. .table__content {
  53. --image-content-label: url(/@/assets/images/themify/deepblue/company/content-label.png);
  54. --image-content-text: url('/@/assets/images/themify/deepblue/company/content-text.png');
  55. --image-list-head: url('/@/assets/images/themify/deepblue/home-container/configurable/firehome/list-head.png');
  56. }
  57. }
  58. .table__content {
  59. --image-content-label: url(/@/assets/images/company/content-label.png);
  60. --image-content-text: url('/@/assets/images/company/content-text.png');
  61. --image-list-head: url('/@/assets/images/home-container/configurable/firehome/list-head.png');
  62. height: 100%;
  63. box-sizing: border-box;
  64. display: flex;
  65. flex-direction: column;
  66. align-items: center;
  67. padding: 5px 0;
  68. .table__content_label {
  69. width: 390px;
  70. height: 32px;
  71. display: flex;
  72. justify-content: space-around;
  73. align-items: center;
  74. .label-t {
  75. text-align: center;
  76. font-size: 14px;
  77. }
  78. }
  79. .table__content_label_A {
  80. background-image: var(--image-content-label);
  81. background-size: 100% 100%;
  82. background-repeat: no-repeat;
  83. color: #31b9ef;
  84. }
  85. .table__content_label_B {
  86. background-image: linear-gradient(to top, #04698c, #04698c00);
  87. background-size: 100% 100%;
  88. background-repeat: no-repeat;
  89. color: #31b9ef;
  90. }
  91. .table__content_label_C {
  92. background-position: center 100%;
  93. background-size: 100% 25px;
  94. background-repeat: no-repeat;
  95. background-image: var(--image-content-text);
  96. height: 40px;
  97. .label-t {
  98. background-repeat: no-repeat;
  99. background-size: 80% auto;
  100. background-position: center;
  101. background-image: var(--image-list-head);
  102. }
  103. }
  104. .table__content_list {
  105. height: calc(100% - 32px);
  106. width: 390px;
  107. display: flex;
  108. flex-direction: column;
  109. padding: 5px 0;
  110. box-sizing: border-box;
  111. overflow-y: auto;
  112. .table__content_list_row {
  113. width: 100%;
  114. display: flex;
  115. justify-content: space-around;
  116. align-items: center;
  117. color: #fff;
  118. margin-bottom: 5px;
  119. span {
  120. display: inline-block;
  121. text-align: center;
  122. }
  123. }
  124. }
  125. .table__content_list_A {
  126. .table__content_list_row {
  127. background-size: 100% auto;
  128. background-repeat: no-repeat;
  129. background-position: center bottom;
  130. background-image: var(--image-content-text);
  131. }
  132. }
  133. .table__content_list_C {
  134. .table__content_list_row {
  135. min-height: 50px;
  136. background-size: 100% auto;
  137. background-repeat: no-repeat;
  138. background-position: center bottom;
  139. background-image: var(--image-content-text);
  140. }
  141. }
  142. }
  143. </style>