deviceList.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="_deviceList">
  3. <HeadlineTag value="设备列表" style="flex-shrink: 0;"></HeadlineTag>
  4. <div class="point_box" style="margin-top: 10px;">
  5. <el-input v-model="value" placeholder="按巡查点名称搜索" />
  6. </div>
  7. <div class="_deviceList_mains" ref="mainsRef" @mouseenter="pauseCarousel" @mouseleave="resumeCarousel">
  8. <div :style="{ transform: `translateY(${scrollY}px)` }">
  9. <div class="_deviceList_mains_item" v-for="(item, index) in eventList" :key="index">
  10. <el-text class="w-150px mb-2 " truncated style="color: white;flex: .4;display: flex;align-items: center;">
  11. <el-icon color="#168cdb" size="16">
  12. <el-icon><Headset /></el-icon>
  13. </el-icon>
  14. <span class="_table_row1">{{ item.name }}</span>
  15. </el-text>
  16. <el-text class="w-150px mb-2" :class="item.state=='播放'?'_success':''" truncated style="color: #fff;flex: .2;">
  17. {{ item.state }}
  18. </el-text>
  19. <el-text class="w-150px mb-2" :class="item.flag=='在线'?'':'_warning'" truncated style="flex: .2;color: #fff;">
  20. {{ item.flag }}
  21. </el-text>
  22. <el-icon color="#168cdb" style="flex: .2;">
  23. <el-icon><Aim /></el-icon>
  24. </el-icon>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { ref, onMounted, onUnmounted } from "vue";
  32. import HeadlineTag from '@/components/HeadlineTag'
  33. import { Headset, Aim } from '@element-plus/icons-vue'
  34. const value = ref('')
  35. const eventList = ref([
  36. { name: '终端1', state: '播放', flag: '在线' },
  37. { name: '终端2', state: '空闲', flag: '离线' },
  38. { name: '终端3', state: '播放', flag: '在线' },
  39. { name: '终端4', state: '空闲', flag: '离线' },
  40. { name: '终端5', state: '播放', flag: '在线' },
  41. { name: '终端6', state: '空闲', flag: '离线' },
  42. { name: '终端7', state: '播放', flag: '在线' },
  43. { name: '终端8', state: '空闲', flag: '离线' },
  44. { name: '终端9', state: '播放', flag: '在线' },
  45. { name: '终端10', state: '空闲', flag: '离线' },
  46. { name: '终端11', state: '播放', flag: '在线' },
  47. { name: '终端12', state: '空闲', flag: '离线' },
  48. { name: '终端13', state: '播放', flag: '在线' },
  49. { name: '终端14', state: '空闲', flag: '离线' },
  50. { name: '终端15', state: '播放', flag: '在线' },
  51. { name: '终端16', state: '空闲', flag: '离线' },
  52. { name: '终端17', state: '播放', flag: '在线' },
  53. { name: '终端18', state: '空闲', flag: '离线' },
  54. { name: '终端19', state: '播放', flag: '在线' },
  55. { name: '终端20', state: '空闲', flag: '离线' },
  56. { name: '终端21', state: '播放', flag: '在线' },
  57. { name: '终端22', state: '空闲', flag: '离线' },
  58. { name: '终端23', state: '播放', flag: '在线' },
  59. { name: '终端24', state: '空闲', flag: '离线' }
  60. ])
  61. const mainsRef = ref(null)
  62. const scrollY = ref(0)
  63. let intervalId = null
  64. const scrollSpeed = 1 // 滚动速度
  65. const startCarousel = () => {
  66. intervalId = setInterval(() => {
  67. const itemHeight = mainsRef.value?.querySelector('._deviceList_mains_item')?.offsetHeight;
  68. if (!itemHeight) return;
  69. scrollY.value -= scrollSpeed;
  70. // 检查第一个元素是否完全离开视口
  71. if (Math.abs(scrollY.value) >= itemHeight) {
  72. // 将第一个元素移到列表末尾
  73. const firstItem = eventList.value.shift();
  74. if (firstItem) {
  75. eventList.value.push(firstItem);
  76. }
  77. // 调整滚动位置
  78. scrollY.value += itemHeight;
  79. }
  80. }, 20);
  81. };
  82. const pauseCarousel = () => {
  83. clearInterval(intervalId);
  84. };
  85. const resumeCarousel = () => {
  86. startCarousel();
  87. };
  88. onMounted(() => {
  89. startCarousel();
  90. });
  91. onUnmounted(() => {
  92. clearInterval(intervalId);
  93. });
  94. </script>
  95. <style lang="scss" scoped>
  96. ._success {
  97. color: #168cdb !important;
  98. }
  99. ._warning {
  100. color: rgb(244, 67, 54) !important;
  101. }
  102. ._table_row1{
  103. margin-left: 10px;
  104. text-emphasis: none;
  105. /* 新增样式让文本超出显示省略号 */
  106. white-space: nowrap;
  107. overflow: hidden;
  108. text-overflow: ellipsis;
  109. }
  110. ._deviceList{
  111. overflow: hidden;
  112. display: flex;
  113. flex-direction: column;
  114. &_mains{
  115. margin:10px 30px;
  116. overflow: hidden; // 隐藏溢出内容
  117. cursor: pointer;
  118. font-size: 12px;
  119. &_item{
  120. display: flex;
  121. justify-content: space-between;
  122. padding: 10px;
  123. }
  124. &_item:nth-child(even){
  125. background: rgba($color: #168cdb, $alpha: .05);
  126. }
  127. &_item:hover{
  128. cursor: pointer;
  129. background-image: linear-gradient(to right, #168cdb, transparent);
  130. }
  131. }
  132. }
  133. </style>
  134. <style lang="scss" scoped>
  135. .point_box{
  136. margin:10px 30px;
  137. }
  138. .point_box :deep(.el-input__wrapper) {
  139. background-color: transparent !important;
  140. box-shadow: 0 0 0 1px rgb(58, 86, 117) inset !important;
  141. }
  142. .point_box :deep(.el-input__wrapper.is-focus) {
  143. box-shadow: 0 0 0 1px #409EFF inset !important;
  144. }
  145. .point_box :deep(.el-input__inner) {
  146. color: #ffffff !important;
  147. }
  148. </style>