Tabsmessage.vue 4.26 KB
Newer Older
左玲玲's avatar
左玲玲 committed
1 2 3 4
<!--
 * @Author: zuolingling zuolingling@jsnangao.com
 * @Date: 2023-08-17 15:37:50
 * @LastEditors: zuolingling zuolingling@jsnangao.com
左玲玲's avatar
左玲玲 committed
5
 * @LastEditTime: 2023-08-18 11:29:29
左玲玲's avatar
左玲玲 committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 * @FilePath: \vue3portal\src\pages\layouts\components\Tabsmessage.vue
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
-->
<template>
    <div class="home messages swh">
        <div class="tabs">
            <el-radio-group v-model="switchvalue" size="small" @change="handlchange">
                <el-radio-button label="1">
                    告警信息&nbsp;&nbsp;
                    <DigitalTransform :value="alarmnum" dislocation :interval="500"></DigitalTransform>
                </el-radio-button>
                <el-radio-button label="2">
                    业务信息&nbsp;&nbsp;
                    <DigitalTransform :value="msgnum" dislocation :interval="500"></DigitalTransform>
                </el-radio-button>
            </el-radio-group>
        </div>
        <div class="scrolltabs scrollbar">
左玲玲's avatar
左玲玲 committed
26 27
            <div class="colflex" style="gap:10px" v-if="switchvalue == '1' && alarmData?.length">
                <div v-for="it in alarmData" class="itemmsg">
左玲玲's avatar
左玲玲 committed
28
                    <div class="itemt oneText" :key="it.id">
左玲玲's avatar
左玲玲 committed
29
                        <span>{{ it.deviceName }}</span>
左玲玲's avatar
左玲玲 committed
30 31 32
                        <span :title="it.type">{{ it.type }}</span>
                    </div>
                    <div class="itemb rowflex">
左玲玲's avatar
左玲玲 committed
33
                        <div style="margin-right: 12px;">
左玲玲's avatar
左玲玲 committed
34 35 36 37 38
                            <el-tag size="small" :type="types[it.severityCode]?.type" class="mx-1" effect="dark">
                                {{ types[it.severityCode]?.name }}
                            </el-tag>
                        </div>
                        <div class="time">
左玲玲's avatar
左玲玲 committed
39
                            {{ it.alarmTime }}
左玲玲's avatar
左玲玲 committed
40 41 42 43
                        </div>
                    </div>
                </div>
            </div>
左玲玲's avatar
左玲玲 committed
44 45
            <div class="colflex" style="gap:10px" v-if="switchvalue == '2' && msgData?.length">
                <div v-for="it in msgData" class="itemmsg">
左玲玲's avatar
左玲玲 committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                    <div class="itemt oneText" :key="it.id">
                        <span>{{ it.eventTypeName }}</span>
                        <span :title="it.messageContent">{{ it.messageContent }}</span>
                    </div>
                    <div class="itemb rowflex">
                        <div class="time">
                            {{ it.sendTime }}
                        </div>
                    </div>
                </div>
            </div>
        </div>


    </div>
</template>

<script setup>
const types = {
    MAJOR: {
        name: "重要",
        type: "warning"
    },
    WARNING: {
        name: "普通",
        type: "info"
    },
    CRITICAL: {
        name: "紧急",
        type: "danger"
    }
}
import { postFetch } from "@/api/doFetch";
const switchvalue = ref('1'),
    alarmnum = ref(0),
    msgnum = ref(0);
const state = reactive({
左玲玲's avatar
左玲玲 committed
83 84
    alarmData: [],
    msgData: []
左玲玲's avatar
左玲玲 committed
85 86 87 88 89 90 91 92 93
});
const handlchange = (e) => {
    switchvalue.value = e;
}

onMounted(() => {
    getData("1");
    getData("2");
});
左玲玲's avatar
左玲玲 committed
94
const { alarmData, msgData } = toRefs(state);
左玲玲's avatar
左玲玲 committed
95 96 97 98 99 100 101

function getData(type) {
    postFetch({ url: "/message/userMessageList", params: { type } }).then(res => {
        if (res.code == "0000") {
            let data = res?.data?.page ?? {};
            if (type == "1") {
                alarmnum.value = data?.total;
左玲玲's avatar
左玲玲 committed
102
                alarmData.value = data?.records ?? [];
左玲玲's avatar
左玲玲 committed
103 104
            } else {
                msgnum.value = data?.total;
左玲玲's avatar
左玲玲 committed
105
                msgData.value = data?.records ?? [];
左玲玲's avatar
左玲玲 committed
106
            }
左玲玲's avatar
左玲玲 committed
107

左玲玲's avatar
左玲玲 committed
108 109 110 111 112 113

        }
    })
}

watch(() => switchvalue.value, (newValue, oldValue) => {
左玲玲's avatar
左玲玲 committed
114 115
    alarmData.value = [];
    msgData.value = [];
左玲玲's avatar
左玲玲 committed
116 117 118 119 120 121 122 123 124 125
    getData(newValue);
})
</script>

<style lang="less" scoped>
.messages {
    position: relative;

    .tabs {
        position: absolute;
左玲玲's avatar
左玲玲 committed
126 127
        top: -33px;
        left: -1px;
左玲玲's avatar
左玲玲 committed
128 129 130 131 132 133 134 135 136 137 138 139
    }

    .scrolltabs {
        width: 100%;
        height: calc(100% - 32px);
        padding: 12px;
        padding-top: 0;
        margin-top: 32px;
        overflow: hidden;
        overflow-y: auto;

    }
左玲玲's avatar
左玲玲 committed
140

左玲玲's avatar
左玲玲 committed
141 142 143 144
    .itemt {}

    .itemb {
        padding: 3px 8px;
左玲玲's avatar
左玲玲 committed
145

左玲玲's avatar
左玲玲 committed
146 147 148 149 150 151 152
        .time {
            color: rgb(151, 151, 151);
            font-size: 12px;
        }
    }
}
</style>