| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <template>
- <div class="panel alarm-info">
- <!-- Animated border beam -->
- <div class="border-beam"></div>
- <!-- Panel header -->
- <div class="panel-header">
- <div class="panel-header-icon">⚠️</div>
- <span class="panel-title">实验室实时风险预警</span>
- <div class="header-count" style="margin-left:auto">
- <span class="count-label">本月</span>
- <span class="count-value">{{ totalCount }}</span>
- <span class="count-label">次</span>
- </div>
- </div>
- <!-- Scrolling warning list -->
- <div class="warn-scroll-wrap">
- <div class="warn-scroll-inner">
- <div
- v-for="(item, idx) in scrollList"
- :key="idx"
- class="warn-item"
- >
- <div class="warn-item-head">
- <span class="warn-lab">🚨 {{ item.lab }}({{ item.room }})- {{ item.unit }}</span>
- <span class="warn-time">{{ item.time }}</span>
- </div>
- <div class="warn-detail">
- 异常指标:<span class="warn-metric-val">{{ item.metric }} {{ item.val }}</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { getRiskWarning } from '@/api/screen'
- const LEVEL_LABELS = { 1: '低风险', 2: '中风险', 3: '较高风险', 4: '高风险' }
- export default {
- name: 'AlarmInfo',
- data() {
- return {
- totalCount: 0,
- warningList: [],
- pollTimer: null
- }
- },
- computed: {
- /** Duplicate data for seamless CSS scroll loop */
- scrollList() {
- if(this.warningList[6]){
- return [...this.warningList, ...this.warningList]
- }else if(this.warningList[0]){
- return [...this.warningList]
- }else{
- return []
- }
- }
- },
- mounted() {
- this.fetchData()
- if(this.warningList[6]){
- this.pollTimer = setInterval(this.fetchData, 5 * 60 * 1000)
- }
- },
- beforeDestroy() {
- if (this.pollTimer) clearInterval(this.pollTimer)
- },
- methods: {
- async fetchData() {
- try {
- const res = await getRiskWarning()
- if (res.code === 200) {
- this.totalCount = res.data.monthAlarmCount
- this.warningList = (res.data.eventList || []).map(e => ({
- lab: e.subName,
- room: '',
- unit: '',
- metric: e.eventName,
- val: LEVEL_LABELS[e.riskPlanLevel] || '',
- time: e.eventStartTime ? e.eventStartTime.replace('T', ' ') : ''
- }))
- }
- } catch (e) {
- // 错误已由拦截器处理
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .alarm-info {
- position: relative;
- border-radius: 15px;
- overflow: hidden;
- background: $bg-panel;
- border: 1px solid $border;
- display: flex;
- flex-direction: column;
- height: 100%;
- &::before {
- content: '';
- position: absolute;
- inset: 0;
- pointer-events: none;
- border-radius: inherit;
- background: linear-gradient(135deg, rgba(30,144,255,0.05) 0%, transparent 50%, rgba(0,216,255,0.03) 100%);
- }
- }
- /* ===== Animated border beam ===== */
- .border-beam {
- position: absolute;
- inset: 0;
- pointer-events: none;
- border-radius: inherit;
- overflow: hidden;
- z-index: 2;
- &::before {
- content: '';
- position: absolute;
- top: 0;
- left: -100%;
- width: 40%;
- height: 3px;
- background: linear-gradient(90deg, transparent, rgba(30,144,255,0.9), rgba(0,216,255,0.7), transparent);
- animation: beamTop 5s linear infinite;
- }
- &::after {
- content: '';
- position: absolute;
- bottom: 0;
- right: -100%;
- width: 40%;
- height: 3px;
- background: linear-gradient(90deg, transparent, rgba(0,216,255,0.7), rgba(30,144,255,0.9), transparent);
- animation: beamBottom 5s linear infinite 2.5s;
- }
- }
- @keyframes beamTop { from { left: -40%; } to { left: 100%; } }
- @keyframes beamBottom { from { right: -40%; } to { right: 100%; } }
- /* ===== Panel header ===== */
- .panel-header {
- display: flex;
- align-items: center;
- gap: 25px;
- padding: 20px 30px 18px;
- border-bottom: 1px solid $border;
- background: linear-gradient(90deg, rgba(0,60,160,0.18), transparent);
- flex-shrink: 0;
- }
- .panel-header-icon {
- width: 65px;
- height: 65px;
- border-radius: 12px;
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32px;
- background: linear-gradient(135deg, rgba(30,144,255,0.25), rgba(0,216,255,0.15));
- border: 1px solid rgba(30,144,255,0.35);
- animation: iconGlow 3s ease-in-out infinite;
- }
- @keyframes iconGlow {
- 0%, 100% { box-shadow: 0 0 15px rgba(30,144,255,0.3); }
- 50% { box-shadow: 0 0 35px rgba(30,144,255,0.7), 0 0 12px rgba(0,216,255,0.3); }
- }
- .panel-title {
- font-size: 30px;
- font-weight: 600;
- letter-spacing: 2px;
- color: $cyan;
- }
- /* ===== Header count ===== */
- .header-count {
- display: flex;
- align-items: center;
- gap: 10px;
- flex-shrink: 0;
- }
- .count-label {
- font-size: 25px;
- color: $text-dim;
- }
- .count-value {
- font-size: 50px;
- font-weight: 700;
- color: #f59e0b;
- }
- /* ===== Warning scroll ===== */
- .warn-scroll-wrap {
- overflow: hidden;
- flex: 1;
- min-height: 0;
- padding: 15px 20px;
- }
- .warn-scroll-inner {
- animation: scrollUp 22s linear infinite;
- &:hover {
- animation-play-state: paused;
- }
- }
- @keyframes scrollUp {
- 0% { transform: translateY(0); }
- 100% { transform: translateY(-50%); }
- }
- /* ===== Warning item ===== */
- .warn-item {
- padding: 18px 20px;
- border-radius: 10px;
- margin-bottom: 12px;
- background: rgba(245,158,11,0.05);
- border: 1px solid rgba(245,158,11,0.2);
- }
- .warn-item-head {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- margin-bottom: 10px;
- gap: 15px;
- }
- .warn-lab {
- font-size: 28px;
- font-weight: 600;
- color: #fcd34d;
- flex: 1;
- }
- .warn-time {
- font-size: 25px;
- color: $text-dim;
- white-space: nowrap;
- }
- .warn-detail {
- font-size: 25px;
- color: $text-dim;
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .warn-metric-val {
- color: #fb923c;
- font-weight: 600;
- }
- </style>
|