CommonTable.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="common-table">
  3. <div class="table__content_label">
  4. <div class="label-t" v-for="(item, index) in columns" :key="`svvhbcth-${index}`" :style="{ flexBasis }">{{
  5. item.name }}</div>
  6. </div>
  7. <div ref="scrollRef" class="table__content_list">
  8. <div class="table__content_list_row" v-for="(item, index) in tableData" :key="`svvhbct-${index}`">
  9. <div v-for="(t, i) in columns" :key="`svvhbctr-${i}`" :style="{ flexBasis }" class="table__content__list_item">
  10. <slot :name="t.prop" :scope="item">
  11. <span v-if="t.prop == 'status' || t.prop == 'remark' || t.prop == 'grade'" class="icon-pie">
  12. <span class="icon-item"></span>
  13. </span>
  14. <span :style="{ color: t.prop == 'grade' ? 'rgba(79, 255, 173)' : '' }">{{ get(item, t.prop) }}</span>
  15. </slot>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import { computed, ref } from 'vue';
  23. import { useAutoScroll } from '/@/hooks/core/useAutoScroll';
  24. import _ from 'lodash';
  25. let props = defineProps({
  26. columns: {
  27. type: Array as any
  28. },
  29. autoScroll: {
  30. type: Boolean,
  31. default: false
  32. },
  33. tableData: {
  34. type: Array as any
  35. },
  36. defaultValue: {
  37. type: String,
  38. default: '-'
  39. }
  40. })
  41. const scrollRef = ref(null);
  42. if (props.autoScroll) {
  43. useAutoScroll(scrollRef);
  44. }
  45. const flexBasis = computed(() => {
  46. return Math.fround(100 / props.columns.length) + '%';
  47. });
  48. function get(o, p) {
  49. const d = _.get(o, p);
  50. return _.isNil(d) ? props.defaultValue : d === '' ? props.defaultValue : d;
  51. }
  52. </script>
  53. <style lang="less" scoped>
  54. @import '/@/design/theme.less';
  55. .common-table {
  56. --image-content-label: url('/@/assets/images/home-container/configurable/hsq/1-5.png');
  57. --image-content-text: url('/@/assets/images/company/content-text.png');
  58. --image-list-head: url('/@/assets/images/home-container/configurable/firehome/list-head.png');
  59. --image-content-label-d: url(/@/assets/images/home-container/configurable/minehome/content-label.png);
  60. --image-content-body-d: url('/@/assets/images/home-container/configurable/minehome/content-body.png');
  61. display: flex;
  62. flex-direction: column;
  63. align-items: center;
  64. position: relative;
  65. width: 100%;
  66. height: 100%;
  67. padding: 10px;
  68. box-sizing: border-box;
  69. .gallery-content {
  70. position: absolute;
  71. &:nth-child(1) {
  72. left: 22px;
  73. top: 4px;
  74. }
  75. &:nth-child(2) {
  76. display: flex;
  77. flex-direction: column;
  78. align-items: flex-end;
  79. right: 24px;
  80. top: 4px;
  81. }
  82. &:nth-child(3) {
  83. left: 22px;
  84. top: 72px;
  85. }
  86. &:nth-child(4) {
  87. display: flex;
  88. flex-direction: column;
  89. align-items: flex-end;
  90. right: 24px;
  91. top: 72px;
  92. }
  93. &:nth-child(5) {
  94. left: 50%;
  95. top: 50%;
  96. transform: translate(-50%, -50%);
  97. }
  98. .gallery-content-text {
  99. margin-bottom: 2px;
  100. }
  101. .gallery-content-text-r {
  102. margin-bottom: 2px;
  103. }
  104. .gallery-content-text1 {
  105. font-size: 24px;
  106. font-family: 'douyuFont';
  107. }
  108. .gallery-content-value,
  109. .gallery-content-value-r {
  110. font-family: 'douyuFont';
  111. color: #fff;
  112. }
  113. }
  114. .table__content_label {
  115. width: 400px;
  116. height: 32px;
  117. display: flex;
  118. justify-content: space-around;
  119. align-items: center;
  120. background-image: var(--image-content-label);
  121. background-size: 100% 100%;
  122. background-repeat: no-repeat;
  123. color: #3df6ff;
  124. .label-t {
  125. text-align: center;
  126. font-size: 14px;
  127. }
  128. }
  129. .table__content_list {
  130. height: calc(100% - 32px);
  131. width: 400px;
  132. display: flex;
  133. flex-direction: column;
  134. padding: 5px 0;
  135. box-sizing: border-box;
  136. overflow-y: auto;
  137. .table__content_list_row {
  138. width: 100%;
  139. display: flex;
  140. justify-content: space-around;
  141. align-items: center;
  142. color: #fff;
  143. margin-bottom: 5px;
  144. background-size: 100% auto;
  145. background-repeat: no-repeat;
  146. background-position: center bottom;
  147. background-image: var(--image-content-text);
  148. span {
  149. display: inline-block;
  150. text-align: center;
  151. }
  152. }
  153. }
  154. .table__content__list_item{
  155. text-align: center;
  156. padding-left: 8px;
  157. }
  158. .icon-pie {
  159. position: relative;
  160. width: 12px;
  161. height: 12px;
  162. border-radius: 50%;
  163. background-color: rgba(79, 255, 173, .3);
  164. margin-right: 5px;
  165. }
  166. .icon-item {
  167. position: absolute;
  168. left: 50%;
  169. top: 50%;
  170. transform: translate(-50%, -50%);
  171. width: 6px;
  172. height: 6px;
  173. border-radius: 50%;
  174. background-color: rgba(79, 255, 173);
  175. }
  176. }
  177. </style>