Browse Source

修改后台报警信息的提示信息

master
王梦远 2 weeks ago
parent
commit
530c8e4742
  1. 68
      src/layouts/default.vue
  2. 13
      src/stores/systemStore.ts

68
src/layouts/default.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { syncSendCmd } from 'apis/system'
import WifiConnSvg from 'assets/images/wifi-conn.svg' import WifiConnSvg from 'assets/images/wifi-conn.svg'
import WifiUnconnSvg from 'assets/images/wifi-unconn.svg' import WifiUnconnSvg from 'assets/images/wifi-unconn.svg'
import ErrorEventsModal from 'components/system/ErrorEventsModal.vue'
import NetReconnection from 'components/system/NetReconnection.vue' import NetReconnection from 'components/system/NetReconnection.vue'
import { delToken } from 'libs/token' import { delToken } from 'libs/token'
import { formatDateTime } from 'libs/utils' import { formatDateTime } from 'libs/utils'
@ -17,6 +17,8 @@ import { useHomeStore } from '@/stores/homeStore'
import { useLiquidStore } from '@/stores/liquidStore' import { useLiquidStore } from '@/stores/liquidStore'
import { useSealStore } from '@/stores/sealStore' import { useSealStore } from '@/stores/sealStore'
import { useSystemStore } from '@/stores/systemStore' import { useSystemStore } from '@/stores/systemStore'
import SystemLog = System.SystemLog
import { ElMessageBox } from 'element-plus'
// const routes = generateRoutes() // const routes = generateRoutes()
// const childrenRoutes = routes.find(r => r.path === '/')?.children || [] // const childrenRoutes = routes.find(r => r.path === '/')?.children || []
@ -166,7 +168,6 @@ const toggleLanguage = () => {
locale.value = locale.value === 'zh' ? 'en' : 'zh' locale.value = locale.value === 'zh' ? 'en' : 'zh'
localStorage.setItem('locale', locale.value) // localStorage.setItem('locale', locale.value) //
} }
const statusMap = { const statusMap = {
info: { info: {
type: 'info', type: 'info',
@ -185,6 +186,43 @@ const statusMap = {
name: '设备告警信息', name: '设备告警信息',
}, },
} }
const handleClose = async (item: SystemLog, key: number) => {
console.log('item === ', item)
const evenid = item.uuid
const params = {
className: 'AppCore',
fnName: 'appEventConfirm',
params: {
evenid,
},
}
await syncSendCmd(params)
systemStore.systemLogList.splice(key, 1)
}
const handleCloseAll = async () => {
await ElMessageBox.confirm(
'确认关闭所有?',
'Warning',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
},
)
for (let i = 0; i < systemStore.systemLogList.length; i++) {
const item = systemStore.systemLogList[i]
const evenid = item.uuid
const params = {
className: 'AppCore',
fnName: 'appEventConfirm',
params: {
evenid,
},
}
await syncSendCmd(params)
}
systemStore.systemLogList = []
}
</script> </script>
<template> <template>
@ -260,7 +298,7 @@ const statusMap = {
IP : {{ deviceInfo.ip }} IP : {{ deviceInfo.ip }}
</div> </div>
</el-col> </el-col>
<el-col :span="12" class="warning-border">
<el-col :span="12" :class="systemStore?.systemLogList.length > 0 ? 'warning-border' : ''">
<div class="footer-left"> <div class="footer-left">
<img src="../assets/images/run.svg" alt="" style="padding-right: 5px"> <img src="../assets/images/run.svg" alt="" style="padding-right: 5px">
<span v-if="!systemStore.systemLogList.length" class="text">设备运行状态</span> <span v-if="!systemStore.systemLogList.length" class="text">设备运行状态</span>
@ -277,10 +315,13 @@ const statusMap = {
</template> </template>
<template #default> <template #default>
<div class="log-box"> <div class="log-box">
<div class="tag-box">
<el-tag <el-tag
v-for="(item, key) in systemStore.systemLogList" v-for="(item, key) in systemStore.systemLogList"
:key :key
:type="statusMap[item?.status as keyof typeof statusMap].type" :type="statusMap[item?.status as keyof typeof statusMap].type"
closable
@close="handleClose(item, key)"
> >
<div style="display: flex; justify-content: space-between; width: 100%"> <div style="display: flex; justify-content: space-between; width: 100%">
<span> <span>
@ -291,6 +332,12 @@ const statusMap = {
</div> </div>
</el-tag> </el-tag>
</div> </div>
<div class="close-btn">
<el-button type="primary" @click="handleCloseAll">
关闭所有
</el-button>
</div>
</div>
</template> </template>
</el-popover> </el-popover>
</div> </div>
@ -303,7 +350,7 @@ const statusMap = {
</el-row> </el-row>
</el-footer> </el-footer>
<NetReconnection /> <NetReconnection />
<ErrorEventsModal />
<!-- <ErrorEventsModal /> -->
</el-container> </el-container>
</template> </template>
@ -408,6 +455,19 @@ const statusMap = {
width: 100%; width: 100%;
} }
} }
.close-btn{
display: flex;
justify-content: center;
align-items: flex-end;
margin-top: 12px;
}
.tag-box{
height: 350px;
overflow: auto;
}
}
:deep(.el-popover) {
padding: 10px!important;
} }
.aside { .aside {
overflow: hidden; overflow: hidden;

13
src/stores/systemStore.ts

@ -15,16 +15,10 @@ export const useSystemStore = defineStore(
systemLogList.value.unshift(log) systemLogList.value.unshift(log)
systemLogList.value = systemLogList.value.slice(0, 200) systemLogList.value = systemLogList.value.slice(0, 200)
} }
const uuids: Set<string> = new Set()
const insertLogs = (appEvents: System.appEvent[]) => { const insertLogs = (appEvents: System.appEvent[]) => {
appEvents.forEach((item) => { appEvents.forEach((item) => {
if (uuids.has(item.uuid)) {
return
}
if (uuids.size > 500) {
uuids.clear()
}
uuids.add(item.uuid)
const log = systemLogList.value.find(log => log.uuid === item.uuid)
if (!log) {
if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) { if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) {
// 传感器检测失败弹窗事件 // 传感器检测失败弹窗事件
item.errCheckPoints.forEach((errCheckPoint) => { item.errCheckPoints.forEach((errCheckPoint) => {
@ -52,12 +46,13 @@ export const useSystemStore = defineStore(
// 普通弹窗事件 // 普通弹窗事件
const log: System.SystemLog = { const log: System.SystemLog = {
name: item.message || '', name: item.message || '',
status: 'info',
status: 'check',
time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()),
uuid: item.uuid, uuid: item.uuid,
} }
insertLog(log) insertLog(log)
} }
}
}) })
} }
const loginForm = ref({ const loginForm = ref({

Loading…
Cancel
Save