fix: 修改bug

This commit is contained in:
100011797 2023-07-06 15:59:49 +08:00
parent 590a82b156
commit 76f22d8503
4 changed files with 79 additions and 33 deletions

View File

@ -11,7 +11,7 @@
</j-badge>
<template #overlay>
<div>
<NoticeInfo @action="handleRead" />
<NoticeInfo :tabs="tabs" @action="handleRead" />
</div>
</template>
</j-dropdown>
@ -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<any>([]);
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()
})
</script>

View File

@ -4,8 +4,9 @@
v-model:activeKey="activeKey"
:destroyInactiveTabPane="true"
@change="onChange"
v-if="tabs.length"
>
<j-tab-pane v-for="item in tab" :key="item.key">
<j-tab-pane v-for="item in tabs" :key="item.key">
<template #tab>
<NoticeTab
:refresh="refreshObj[item.key]"
@ -23,18 +24,32 @@
@refresh="onRefresh(item.key)"
/>
</template>
<div v-if="list.length < 12" style="color: #666666; text-align: center; padding: 8px;">这是最后一条数据了</div>
<div
v-if="list.length < 12"
style="
color: #666666;
text-align: center;
padding: 8px;
"
>
这是最后一条数据了
</div>
</j-scrollbar>
<div class="no-data" v-else>
<j-empty />
</div>
<div class="btns">
<j-button type="link" @click="onMore(item.key)">查看更多</j-button>
<j-button type="link" @click="onMore(item.key)"
>查看更多</j-button
>
</div>
</div>
</j-spin>
</j-tab-pane>
</j-tabs>
<div class="no-data" v-else>
<j-empty />
</div>
</div>
</template>
@ -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');
});

View File

@ -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')

View File

@ -169,6 +169,10 @@ watchEffect(() => {
}
});
onMounted(() => {
user.getUserInfo();
})
onUnmounted(() => {
user.tabKey = 'HomeView'
user.other.tabKey = ''