|
|
@@ -0,0 +1,195 @@
|
|
|
+<template>
|
|
|
+ <div class="alarm-list-container">
|
|
|
+ <div v-if="!listData || listData.length === 0" class="empty-text">
|
|
|
+ 暂无消息
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="alarm-item" v-for="(item, index) in listData" :key="item.id || index">
|
|
|
+ <div class="item-header">
|
|
|
+ <span class="title" :class="getTitleClass(item.type)">
|
|
|
+ {{ item.title }}
|
|
|
+ </span>
|
|
|
+ <span class="time" v-if="item.time">{{ item.time }}</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="item-body">
|
|
|
+ <span class="desc">{{ item.description }}</span>
|
|
|
+ <div class="actions">
|
|
|
+ <button class="btn btn-ignore" @click="handleIgnore(item, index)">忽略</button>
|
|
|
+ <button class="btn btn-view" @click="handleView(item, index)">查看</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ name: 'AlarmMessageList',
|
|
|
+ props: {
|
|
|
+ // 列表数据源
|
|
|
+ listData: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 根据告警级别返回对应的颜色 class
|
|
|
+ getTitleClass(type) {
|
|
|
+ const typeMap = {
|
|
|
+ 'error': 'text-red',
|
|
|
+ 'warning': 'text-yellow',
|
|
|
+ 'info': 'text-blue',
|
|
|
+ 'success': 'text-green'
|
|
|
+ };
|
|
|
+ return typeMap[type] || 'text-default';
|
|
|
+ },
|
|
|
+ // 触发忽略事件
|
|
|
+ handleIgnore(item, index) {
|
|
|
+ this.$emit('ignore', { item, index });
|
|
|
+ },
|
|
|
+ // 触发查看事件
|
|
|
+ handleView(item, index) {
|
|
|
+ this.$emit('view', { item, index });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.alarm-list-container {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+/* 隐藏滚动条但保留滚动功能 */
|
|
|
+.alarm-list-container::-webkit-scrollbar {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
+
|
|
|
+.empty-text {
|
|
|
+ text-align: center;
|
|
|
+ color: #64748b;
|
|
|
+ padding: 20px 0;
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 每条消息的容器 */
|
|
|
+.alarm-item {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ border-bottom: 1px solid rgba(208,222,238,0.15);
|
|
|
+ padding: 15px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.alarm-item:first-child {
|
|
|
+ padding-top: 13px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 去掉最后一条的下划线 */
|
|
|
+.alarm-item:last-child {
|
|
|
+ border-bottom: none;
|
|
|
+}
|
|
|
+
|
|
|
+/* 第一行:头部布局 */
|
|
|
+.item-header {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 4px;
|
|
|
+}
|
|
|
+
|
|
|
+.title {
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 状态颜色 */
|
|
|
+.text-red {
|
|
|
+ color: #FF3838;
|
|
|
+}
|
|
|
+
|
|
|
+.text-yellow {
|
|
|
+ color: #FFCE34;
|
|
|
+}
|
|
|
+
|
|
|
+.text-blue {
|
|
|
+ color: #32F6F8;
|
|
|
+}
|
|
|
+
|
|
|
+.text-green {
|
|
|
+ color: #10b981;
|
|
|
+}
|
|
|
+
|
|
|
+.text-default {
|
|
|
+ color: #ffffff;
|
|
|
+}
|
|
|
+
|
|
|
+.time {
|
|
|
+ font-size: 12px;
|
|
|
+ color: rgba(255, 255, 255, 0.65);
|
|
|
+ /* 次要文字颜色 */
|
|
|
+}
|
|
|
+
|
|
|
+/* 第二行:主体布局 */
|
|
|
+.item-body {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.desc {
|
|
|
+ font-size: 12px;
|
|
|
+ color: rgba(255, 255, 255, 0.65);
|
|
|
+ flex: 1;
|
|
|
+ padding-right: 15px;
|
|
|
+
|
|
|
+ /* 超出部分省略号显示 (防止文字过长折行破坏布局) */
|
|
|
+ white-space: nowrap;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+}
|
|
|
+
|
|
|
+.actions {
|
|
|
+ display: flex;
|
|
|
+ gap: 10px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ /* 防止按钮被长文本挤压变形 */
|
|
|
+}
|
|
|
+
|
|
|
+/* 通用按钮样式清除 */
|
|
|
+.btn {
|
|
|
+ background: transparent;
|
|
|
+ border: none;
|
|
|
+ outline: none;
|
|
|
+ cursor: pointer;
|
|
|
+ font-size: 14px;
|
|
|
+ padding: 5px 8px;
|
|
|
+ border-radius: 4px;
|
|
|
+ transition: all 0.2s;
|
|
|
+}
|
|
|
+
|
|
|
+/* 忽略按钮:低调的文字按钮 */
|
|
|
+.btn-ignore {
|
|
|
+ background-color: #0D2244;
|
|
|
+ color: #ffffff;
|
|
|
+}
|
|
|
+
|
|
|
+.btn-ignore:hover {
|
|
|
+ color: #ffffff;
|
|
|
+ background: rgba(255, 255, 255, 0.1);
|
|
|
+}
|
|
|
+
|
|
|
+/* 查看按钮:科技感蓝色渐变边框按钮 */
|
|
|
+.btn-view {
|
|
|
+ color: #ffffff;
|
|
|
+ background: linear-gradient(180deg, rgba(24, 144, 255, 0.1) 0%, rgba(24, 144, 255, 0.3) 100%);
|
|
|
+ box-shadow: inset 0 0 8px rgba(24, 144, 255, 0.2);
|
|
|
+}
|
|
|
+
|
|
|
+.btn-view:hover {
|
|
|
+ background: linear-gradient(180deg, rgba(24, 144, 255, 0.2) 0%, rgba(24, 144, 255, 0.5) 100%);
|
|
|
+ box-shadow: inset 0 0 12px rgba(24, 144, 255, 0.4);
|
|
|
+ border-color: #32F6F8;
|
|
|
+}
|
|
|
+</style>
|