AlarmInfo.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="panel alarm-info">
  3. <!-- Animated border beam -->
  4. <div class="border-beam"></div>
  5. <!-- Panel header -->
  6. <div class="panel-header">
  7. <div class="panel-header-icon">&#x26A0;&#xFE0F;</div>
  8. <span class="panel-title">实验室实时风险预警</span>
  9. <div class="header-count" style="margin-left:auto">
  10. <span class="count-label">本月</span>
  11. <span class="count-value">{{ totalCount }}</span>
  12. <span class="count-label">次</span>
  13. </div>
  14. </div>
  15. <!-- Scrolling warning list -->
  16. <div class="warn-scroll-wrap">
  17. <div class="warn-scroll-inner">
  18. <div
  19. v-for="(item, idx) in scrollList"
  20. :key="idx"
  21. class="warn-item"
  22. >
  23. <div class="warn-item-head">
  24. <span class="warn-lab">&#x1F6A8; {{ item.lab }}({{ item.room }})- {{ item.unit }}</span>
  25. <span class="warn-time">{{ item.time }}</span>
  26. </div>
  27. <div class="warn-detail">
  28. 异常指标:<span class="warn-metric-val">{{ item.metric }} {{ item.val }}</span>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { getRiskWarning } from '@/api/screen'
  37. const LEVEL_LABELS = { 1: '低风险', 2: '中风险', 3: '较高风险', 4: '高风险' }
  38. export default {
  39. name: 'AlarmInfo',
  40. data() {
  41. return {
  42. totalCount: 0,
  43. warningList: [],
  44. pollTimer: null
  45. }
  46. },
  47. computed: {
  48. /** Duplicate data for seamless CSS scroll loop */
  49. scrollList() {
  50. if(this.warningList[6]){
  51. return [...this.warningList, ...this.warningList]
  52. }else if(this.warningList[0]){
  53. return [...this.warningList]
  54. }else{
  55. return []
  56. }
  57. }
  58. },
  59. mounted() {
  60. this.fetchData()
  61. if(this.warningList[6]){
  62. this.pollTimer = setInterval(this.fetchData, 5 * 60 * 1000)
  63. }
  64. },
  65. beforeDestroy() {
  66. if (this.pollTimer) clearInterval(this.pollTimer)
  67. },
  68. methods: {
  69. async fetchData() {
  70. try {
  71. const res = await getRiskWarning()
  72. if (res.code === 200) {
  73. this.totalCount = res.data.monthAlarmCount
  74. this.warningList = (res.data.eventList || []).map(e => ({
  75. lab: e.subName,
  76. room: '',
  77. unit: '',
  78. metric: e.eventName,
  79. val: LEVEL_LABELS[e.riskPlanLevel] || '',
  80. time: e.eventStartTime ? e.eventStartTime.replace('T', ' ') : ''
  81. }))
  82. }
  83. } catch (e) {
  84. // 错误已由拦截器处理
  85. }
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .alarm-info {
  92. position: relative;
  93. border-radius: 15px;
  94. overflow: hidden;
  95. background: $bg-panel;
  96. border: 1px solid $border;
  97. display: flex;
  98. flex-direction: column;
  99. height: 100%;
  100. &::before {
  101. content: '';
  102. position: absolute;
  103. inset: 0;
  104. pointer-events: none;
  105. border-radius: inherit;
  106. background: linear-gradient(135deg, rgba(30,144,255,0.05) 0%, transparent 50%, rgba(0,216,255,0.03) 100%);
  107. }
  108. }
  109. /* ===== Animated border beam ===== */
  110. .border-beam {
  111. position: absolute;
  112. inset: 0;
  113. pointer-events: none;
  114. border-radius: inherit;
  115. overflow: hidden;
  116. z-index: 2;
  117. &::before {
  118. content: '';
  119. position: absolute;
  120. top: 0;
  121. left: -100%;
  122. width: 40%;
  123. height: 3px;
  124. background: linear-gradient(90deg, transparent, rgba(30,144,255,0.9), rgba(0,216,255,0.7), transparent);
  125. animation: beamTop 5s linear infinite;
  126. }
  127. &::after {
  128. content: '';
  129. position: absolute;
  130. bottom: 0;
  131. right: -100%;
  132. width: 40%;
  133. height: 3px;
  134. background: linear-gradient(90deg, transparent, rgba(0,216,255,0.7), rgba(30,144,255,0.9), transparent);
  135. animation: beamBottom 5s linear infinite 2.5s;
  136. }
  137. }
  138. @keyframes beamTop { from { left: -40%; } to { left: 100%; } }
  139. @keyframes beamBottom { from { right: -40%; } to { right: 100%; } }
  140. /* ===== Panel header ===== */
  141. .panel-header {
  142. display: flex;
  143. align-items: center;
  144. gap: 25px;
  145. padding: 20px 30px 18px;
  146. border-bottom: 1px solid $border;
  147. background: linear-gradient(90deg, rgba(0,60,160,0.18), transparent);
  148. flex-shrink: 0;
  149. }
  150. .panel-header-icon {
  151. width: 65px;
  152. height: 65px;
  153. border-radius: 12px;
  154. flex-shrink: 0;
  155. display: flex;
  156. align-items: center;
  157. justify-content: center;
  158. font-size: 32px;
  159. background: linear-gradient(135deg, rgba(30,144,255,0.25), rgba(0,216,255,0.15));
  160. border: 1px solid rgba(30,144,255,0.35);
  161. animation: iconGlow 3s ease-in-out infinite;
  162. }
  163. @keyframes iconGlow {
  164. 0%, 100% { box-shadow: 0 0 15px rgba(30,144,255,0.3); }
  165. 50% { box-shadow: 0 0 35px rgba(30,144,255,0.7), 0 0 12px rgba(0,216,255,0.3); }
  166. }
  167. .panel-title {
  168. font-size: 30px;
  169. font-weight: 600;
  170. letter-spacing: 2px;
  171. color: $cyan;
  172. }
  173. /* ===== Header count ===== */
  174. .header-count {
  175. display: flex;
  176. align-items: center;
  177. gap: 10px;
  178. flex-shrink: 0;
  179. }
  180. .count-label {
  181. font-size: 25px;
  182. color: $text-dim;
  183. }
  184. .count-value {
  185. font-size: 50px;
  186. font-weight: 700;
  187. color: #f59e0b;
  188. }
  189. /* ===== Warning scroll ===== */
  190. .warn-scroll-wrap {
  191. overflow: hidden;
  192. flex: 1;
  193. min-height: 0;
  194. padding: 15px 20px;
  195. }
  196. .warn-scroll-inner {
  197. animation: scrollUp 22s linear infinite;
  198. &:hover {
  199. animation-play-state: paused;
  200. }
  201. }
  202. @keyframes scrollUp {
  203. 0% { transform: translateY(0); }
  204. 100% { transform: translateY(-50%); }
  205. }
  206. /* ===== Warning item ===== */
  207. .warn-item {
  208. padding: 18px 20px;
  209. border-radius: 10px;
  210. margin-bottom: 12px;
  211. background: rgba(245,158,11,0.05);
  212. border: 1px solid rgba(245,158,11,0.2);
  213. }
  214. .warn-item-head {
  215. display: flex;
  216. justify-content: space-between;
  217. align-items: flex-start;
  218. margin-bottom: 10px;
  219. gap: 15px;
  220. }
  221. .warn-lab {
  222. font-size: 28px;
  223. font-weight: 600;
  224. color: #fcd34d;
  225. flex: 1;
  226. }
  227. .warn-time {
  228. font-size: 25px;
  229. color: $text-dim;
  230. white-space: nowrap;
  231. }
  232. .warn-detail {
  233. font-size: 25px;
  234. color: $text-dim;
  235. display: flex;
  236. align-items: center;
  237. gap: 10px;
  238. }
  239. .warn-metric-val {
  240. color: #fb923c;
  241. font-weight: 600;
  242. }
  243. </style>