From 76f22d8503c5aa9453ae4af5651409da9c97ae6f Mon Sep 17 00:00:00 2001
From: 100011797 <2642441182@qq.com>
Date: Thu, 6 Jul 2023 15:59:49 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Layout/components/Notice.vue | 50 ++++++++++++++++-
.../Layout/components/NoticeInfo.vue | 56 +++++++++----------
src/views/account/Center/bind/index.vue | 2 +-
src/views/account/Center/index.vue | 4 ++
4 files changed, 79 insertions(+), 33 deletions(-)
diff --git a/src/components/Layout/components/Notice.vue b/src/components/Layout/components/Notice.vue
index a803abdc..d1685f21 100644
--- a/src/components/Layout/components/Notice.vue
+++ b/src/components/Layout/components/Notice.vue
@@ -11,7 +11,7 @@
-
+
@@ -27,6 +27,7 @@ import { changeStatus_api } from '@/api/account/notificationRecord';
import { useUserInfo } from '@/store/userInfo';
import { useMenuStore } from '@/store/menu';
+import { getAllNotice } from '@/api/account/center';
const updateCount = computed(() => useUserInfo().alarmUpdateCount);
const menuStory = useMenuStore();
@@ -100,6 +101,7 @@ const read = (type: string, data: any) => {
// 查询未读数量
const getList = () => {
+ if(tabs.value.length <= 0) return;
loading.value = true;
const params = {
sorts: [{
@@ -137,9 +139,51 @@ const handleRead = () => {
watch(updateCount, () => getList());
+const tab = [
+ {
+ key: 'alarm',
+ tab: '告警',
+ type: [
+ 'alarm-product',
+ 'alarm-device',
+ 'alarm-other',
+ 'alarm-org',
+ 'alarm',
+ ],
+ },
+ {
+ key: 'system-monitor',
+ tab: '系统监控',
+ type: ['system-event'],
+ },
+ {
+ key: 'system-business',
+ tab: '业务监控',
+ type: ['device-transparent-codec'],
+ },
+];
+
+const tabs = ref([]);
+
+const queryTypeList = async () => {
+ const resp: any = await getAllNotice();
+ if (resp.status === 200) {
+ const provider = resp.result.map((i: any) => i.provider) || [];
+ const arr = tab.filter((item: any) => {
+ const _arr = [...provider, item.type]
+ return new Set(_arr).size < _arr.length
+ });
+
+ tabs.value = arr;
+ if(arr.length > 0) {
+ subscribeNotice();
+ getList();
+ }
+ }
+};
+
onMounted(() => {
- subscribeNotice();
- getList();
+ queryTypeList()
})
diff --git a/src/components/Layout/components/NoticeInfo.vue b/src/components/Layout/components/NoticeInfo.vue
index 645edb6f..41fb3a44 100644
--- a/src/components/Layout/components/NoticeInfo.vue
+++ b/src/components/Layout/components/NoticeInfo.vue
@@ -4,8 +4,9 @@
v-model:activeKey="activeKey"
:destroyInactiveTabPane="true"
@change="onChange"
+ v-if="tabs.length"
>
-
+
- 这是最后一条数据了
+
+ 这是最后一条数据了
+
- 查看更多
+ 查看更多
+
+
+
@@ -50,30 +65,6 @@ const emits = defineEmits(['action']);
type DataType = 'alarm' | 'system-monitor' | 'system-business';
-const tab = [
- {
- key: 'alarm',
- tab: '告警',
- type: [
- 'alarm-product',
- 'alarm-device',
- 'alarm-other',
- 'alarm-org',
- 'alarm',
- ],
- },
- {
- key: 'system-monitor',
- tab: '系统监控',
- type: ['system-event'],
- },
- {
- key: 'system-business',
- tab: '业务监控',
- type: ['device-transparent-codec'],
- },
-];
-
const refreshObj = ref({
alarm: true,
'system-monitor': true,
@@ -89,6 +80,13 @@ const route = useRoute();
const userInfo = useUserInfo();
+const props = defineProps({
+ tabs: {
+ type: Array,
+ default: () => []
+ }
+})
+
const getData = (type: string[]) => {
loading.value = true;
const params = {
@@ -121,11 +119,11 @@ const getData = (type: string[]) => {
};
const onChange = (_key: string) => {
- const type = tab.find((item) => item.key === _key)?.type || [];
+ const type = props.tabs.find((item: any) => item.key === _key)?.type || [];
getData(type);
};
-onMounted(() => {
+onMounted(async () => {
onChange('alarm');
});
diff --git a/src/views/account/Center/bind/index.vue b/src/views/account/Center/bind/index.vue
index 07f16835..62c3e87c 100644
--- a/src/views/account/Center/bind/index.vue
+++ b/src/views/account/Center/bind/index.vue
@@ -25,7 +25,7 @@
shape="square"
style="margin-bottom: 16px;"
:src="
- bindUser?.avatar ||
+ bindUser.result?.avatar ||
iconMap.get(
bindUser?.applicationProvider,
) || getImage('/apply/internal-standalone.png')
diff --git a/src/views/account/Center/index.vue b/src/views/account/Center/index.vue
index 3cf92fb1..f76ba905 100644
--- a/src/views/account/Center/index.vue
+++ b/src/views/account/Center/index.vue
@@ -169,6 +169,10 @@ watchEffect(() => {
}
});
+onMounted(() => {
+ user.getUserInfo();
+})
+
onUnmounted(() => {
user.tabKey = 'HomeView'
user.other.tabKey = ''