CustomTable.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="table__content" :class="`table__content_${type}`">
  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
  9. v-for="(t, i) in columns"
  10. :key="`svvhbctr-${i}`"
  11. :style="{ flexBasis }"
  12. :class="`table__content__list_item_${type} ${t.path ? 'cursor-pointer' : ''}`"
  13. @click="redirectTo(getFormattedText(item, t.path))"
  14. >
  15. <slot :name="t.prop" :scope="item">
  16. <span>{{ getter(item, t.prop) }}</span>
  17. </slot>
  18. </div>
  19. </div>
  20. <Empty v-if="!data.length" class="table__content_empty" :image="simpleImage"></Empty>
  21. </div>
  22. </div>
  23. </template>
  24. <script lang="ts" setup>
  25. import { computed } from 'vue';
  26. import { get, isNil } from 'lodash-es';
  27. import { getFormattedText, redirectTo } from '../hooks/helper';
  28. import { Empty } from 'ant-design-vue';
  29. const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
  30. let props = withDefaults(
  31. defineProps<{
  32. /** B | C */
  33. type: string;
  34. /** 列表表头配置,每个prop都有其对应的slot来提供定制化功能 */
  35. columns: { prop: string; name: string; path?: string }[];
  36. data: any[];
  37. defaultValue?: string;
  38. }>(),
  39. {
  40. type: 'B',
  41. autoScroll: false,
  42. columns: () => [],
  43. data: () => [],
  44. defaultValue: '-',
  45. }
  46. );
  47. const flexBasis = computed(() => {
  48. return Math.fround(100 / props.columns.length) + '%';
  49. });
  50. function getter(o, p) {
  51. const d = get(o, p);
  52. return isNil(d) ? props.defaultValue : d === '' ? props.defaultValue : d;
  53. }
  54. </script>
  55. <style lang="less" scoped>
  56. @import '/@/design/theme.less';
  57. @font-face {
  58. font-family: 'douyuFont';
  59. src: url('/@/assets/font/douyuFont.otf');
  60. }
  61. .table__content {
  62. --image-content-label-A: url('/@/assets/images/sealedGoaf/configurable/table/table-label-A.png');
  63. --image-content-E: url('/@/assets/images/sealedGoaf/configurable/gallery/bg-C-3.png');
  64. height: 100%;
  65. box-sizing: border-box;
  66. display: flex;
  67. flex-direction: column;
  68. align-items: center;
  69. padding: 5px 0;
  70. .table__content_empty {
  71. padding: 20px;
  72. font-size: 20px;
  73. }
  74. .table__content_label {
  75. width: 400px;
  76. height: 32px;
  77. display: flex;
  78. justify-content: space-around;
  79. align-items: center;
  80. .label-t {
  81. text-align: center;
  82. font-size: 14px;
  83. }
  84. }
  85. .table__content_list {
  86. height: calc(100% - 32px);
  87. width: 400px;
  88. display: flex;
  89. flex-direction: column;
  90. padding: 5px 0;
  91. box-sizing: border-box;
  92. overflow-y: auto;
  93. .table__content_list_row {
  94. width: 100%;
  95. display: flex;
  96. justify-content: space-around;
  97. align-items: center;
  98. color: #fff;
  99. margin-bottom: 5px;
  100. span {
  101. display: inline-block;
  102. text-align: center;
  103. }
  104. }
  105. }
  106. .table__content_label_A {
  107. background-image: var(--image-content-label-A);
  108. background-size: 100% 100%;
  109. background-repeat: no-repeat;
  110. color: #000000;
  111. width: 100%;
  112. padding-left: 10px;
  113. }
  114. .table__content_list_A {
  115. width: 100%;
  116. padding-left: 10px;
  117. font-weight: bold;
  118. font-size: 28px;
  119. }
  120. /* 第一个子元素:黑色 */
  121. .table__content_list_row .table__content__list_item_A:nth-child(1) {
  122. font-size: 14px;
  123. text-align: left;
  124. color: #000000;
  125. }
  126. /* 第二个子元素:蓝色 */
  127. .table__content_list_row .table__content__list_item_A:nth-child(2) {
  128. color: #0052cc;
  129. }
  130. /* 第三个子元素:黄色 */
  131. .table__content_list_row .table__content__list_item_A:nth-child(3) {
  132. color: #b39f01;
  133. }
  134. /* 第四个子元素:橙色 */
  135. .table__content_list_row .table__content__list_item_A:nth-child(4) {
  136. color: #e6a23d;
  137. }
  138. /* 第五个子元素:红色 */
  139. .table__content_list_row .table__content__list_item_A:nth-child(5) {
  140. color: #c45656;
  141. }
  142. .table__content_label_B {
  143. background-image: var(--image-content-label-A);
  144. background-size: 100% 100%;
  145. background-repeat: no-repeat;
  146. color: #000000;
  147. width: 100%;
  148. padding-left: 10px;
  149. }
  150. .table__content_list_B {
  151. width: 100%;
  152. padding-left: 10px;
  153. font-weight: bold;
  154. font-size: 28px;
  155. }
  156. /* 第一个子元素:黑色 */
  157. .table__content_list_row .table__content__list_item_B:nth-child(1) {
  158. font-size: 14px;
  159. text-align: left;
  160. color: #000000;
  161. }
  162. /* 第二个子元素:蓝色 */
  163. .table__content_list_row .table__content__list_item_B:nth-child(2) {
  164. color: #0052cc;
  165. }
  166. /* 第三个子元素:绿色 */
  167. .table__content_list_row .table__content__list_item_B:nth-child(3) {
  168. color: #4caf50;
  169. }
  170. /* 第四个子元素:橙色 */
  171. .table__content_list_row .table__content__list_item_B:nth-child(4) {
  172. color: #c97800;
  173. }
  174. /* 第五个子元素:红色 */
  175. .table__content_list_row .table__content__list_item_B:nth-child(5) {
  176. color: #c45656;
  177. }
  178. }
  179. .table__content_label_C {
  180. background-image: var(--image-content-label-A);
  181. background-size: 100% 100%;
  182. background-repeat: no-repeat;
  183. color: #000000;
  184. width: 100% !important;
  185. }
  186. .table__content_list_C {
  187. width: 100% !important;
  188. font-weight: bold;
  189. font-size: 15px;
  190. color: #000000;
  191. .table__content_list_row {
  192. color: #000000 !important;
  193. margin-bottom: 10px !important;
  194. }
  195. }
  196. // /* 第一个子元素:红色 */
  197. .table__content_list_row .table__content__list_item_C:nth-child(1) {
  198. color: #ff0000;
  199. }
  200. .table__content_label_D {
  201. background-image: var(--image-content-label-A);
  202. background-size: 100% 100%;
  203. background-repeat: no-repeat;
  204. color: #000000;
  205. width: 100% !important;
  206. }
  207. .table__content_list_D {
  208. width: 100% !important;
  209. font-weight: bold;
  210. font-size: 15px;
  211. color: #000000;
  212. text-align: center;
  213. }
  214. .table__content_list_row {
  215. color: #000000 !important;
  216. }
  217. .table__content_list_row .table__content__list_item_D:nth-child(1) {
  218. width: 50px;
  219. }
  220. .table__content_list_row .table__content__list_item_D:nth-child(3) {
  221. color: #2b6ff0;
  222. }
  223. .table__content_list_row .table__content__list_item_D:nth-child(4) {
  224. color: #107f30;
  225. }
  226. //
  227. .table__content_E {
  228. background-image: var(--image-content-E);
  229. background-size: 100% 100%;
  230. background-repeat: no-repeat;
  231. }
  232. .table__content_label_E {
  233. background-image: var(--image-content-label-A);
  234. background-size: 100% 100%;
  235. background-repeat: no-repeat;
  236. color: #000000;
  237. width: 100% !important;
  238. z-index: 10;
  239. }
  240. .table__content_list_E {
  241. width: 100% !important;
  242. font-weight: bold;
  243. font-size: 15px;
  244. color: #000000;
  245. text-align: center;
  246. z-index: 10;
  247. }
  248. .table__content_list_row {
  249. color: #000000 !important;
  250. }
  251. </style>