feat: 右上角活动告警数
This commit is contained in:
@@ -4,6 +4,35 @@ import { parseObjLineToHump } from '@/utils/parse-utils';
|
||||
import { parseDateToStr } from '@/utils/date-utils';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
|
||||
/**
|
||||
* 获取活动告警数
|
||||
* @returns object
|
||||
*/
|
||||
export async function getActiveAlarmTotal() {
|
||||
let totalSQL = `select count(*) as total from alarm where alarm_status='1'`;
|
||||
|
||||
// 发起请求
|
||||
const result = await request({
|
||||
url: `/api/rest/databaseManagement/v1/select/omc_db/alarm`,
|
||||
method: 'get',
|
||||
params: {
|
||||
SQL: totalSQL,
|
||||
},
|
||||
});
|
||||
|
||||
// 解析数据
|
||||
if (result.code === RESULT_CODE_SUCCESS) {
|
||||
const itemData = result.data.data;
|
||||
if (Array.isArray(itemData)) {
|
||||
const v = itemData[0]['alarm'];
|
||||
if (Array.isArray(v)) {
|
||||
result.data = v[0]['total'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
* @param query 查询参数
|
||||
@@ -14,7 +43,7 @@ export async function listAct(query: Record<string, any>, filterSQl: string) {
|
||||
let rowsSQL = `select * from alarm where alarm_status='1' ${filterSQl}`;
|
||||
// 查询
|
||||
let querySQL = '';
|
||||
|
||||
debugger;
|
||||
if (query.alarmCode) {
|
||||
querySQL += ` and alarm_code = '${query.alarmCode}' `;
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import {
|
||||
import RightContent from './components/RightContent.vue';
|
||||
import Tabs from './components/Tabs.vue';
|
||||
import { scriptUrl } from '@/assets/js/icon_font_8d5l8fzk5b87iudi';
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import { computed, reactive, watch } from 'vue';
|
||||
import useLayoutStore from '@/store/modules/layout';
|
||||
import useRouterStore from '@/store/modules/router';
|
||||
import useTabsStore from '@/store/modules/tabs';
|
||||
import useAlarmStore from '@/store/modules/alarm';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { MENU_PATH_INLINE } from '@/constants/menu-constants';
|
||||
const { proConfig, waterMarkContent } = useLayoutStore();
|
||||
@@ -120,6 +121,7 @@ tabsStore.clear();
|
||||
//
|
||||
onMounted(() => {
|
||||
fnGetServerTime();
|
||||
useAlarmStore().fnGetActiveAlarmInfo()
|
||||
});
|
||||
|
||||
// ==== 服务器时间显示 start
|
||||
@@ -164,6 +166,7 @@ document.addEventListener('visibilitychange', function () {
|
||||
if (document.visibilityState == 'visible') {
|
||||
//切换到该页面时执行
|
||||
fnGetServerTime();
|
||||
useAlarmStore().fnGetActiveAlarmInfo()
|
||||
}
|
||||
});
|
||||
// ==== 服务器时间显示 end
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useRouter } from 'vue-router';
|
||||
import { toggle, isFullscreen } from '@/utils/fullscreen-utils';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import useAlarmStore from '@/store/modules/alarm';
|
||||
const { t, changeLocale } = useI18n();
|
||||
const userStore = useUserStore();
|
||||
const router = useRouter();
|
||||
@@ -31,45 +32,14 @@ function fnChangeLocale(e: any) {
|
||||
|
||||
<template>
|
||||
<a-space :size="12" align="center">
|
||||
<a-popover
|
||||
overlayClassName="head-notice"
|
||||
placement="bottomRight"
|
||||
:trigger="['click']"
|
||||
>
|
||||
<a-button type="text">
|
||||
<template #icon>
|
||||
<a-badge :count="123" :overflow-count="99">
|
||||
<BellOutlined :style="{ fontSize: '20px' }" />
|
||||
</a-badge>
|
||||
</template>
|
||||
</a-button>
|
||||
<template #content :style="{ padding: 0 }">
|
||||
<a-tabs centered :tabBarStyle="{ width: '336px' }">
|
||||
<a-tab-pane key="1" tab="通知(41)">
|
||||
Content of Tab 通知
|
||||
<a-button type="link" block>查看更多</a-button>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="2" tab="消息(231)">
|
||||
Content of Tab 消息
|
||||
<a-button type="link" block>查看更多</a-button>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="3" tab="待办(1)">
|
||||
Content of Tab 待办
|
||||
<a-button type="link" block>查看更多</a-button>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
<a-button type="text">
|
||||
<template #icon>
|
||||
<a-badge :count="useAlarmStore().activeAlarmTotal" :overflow-count="99" status="warning">
|
||||
<BellOutlined />
|
||||
</a-badge>
|
||||
</template>
|
||||
</a-popover>
|
||||
|
||||
<!-- <a-tooltip>
|
||||
<template #title>开源仓库</template>
|
||||
<a-button type="text" href="https://gitee.com/TsMask" target="_blank">
|
||||
<template #icon>
|
||||
<GithubOutlined :style="{ fontSize: '20px' }" />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-tooltip> -->
|
||||
|
||||
</a-button>
|
||||
|
||||
<a-tooltip>
|
||||
<template #title>全屏显示</template>
|
||||
<a-button type="text" @click="toggle">
|
||||
|
||||
28
src/store/modules/alarm.ts
Normal file
28
src/store/modules/alarm.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { getActiveAlarmTotal } from '@/api/faultManage/actAlarm';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
/**告警数据信息类型 */
|
||||
type Alarm = {
|
||||
/**活动告警数据值 */
|
||||
activeAlarmTotal: number;
|
||||
};
|
||||
|
||||
const useAlarmStore = defineStore('alarm', {
|
||||
state: (): Alarm => ({
|
||||
activeAlarmTotal: 0,
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// 获取活动告警数
|
||||
async fnGetActiveAlarmInfo() {
|
||||
const res = await getActiveAlarmTotal();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
this.activeAlarmTotal = res.data;
|
||||
}
|
||||
return res;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default useAlarmStore;
|
||||
Reference in New Issue
Block a user