|
@@ -1,36 +1,15 @@
|
|
<template>
|
|
<template>
|
|
- <div :class="prefixCls">
|
|
|
|
- <Popover v-model:visible="popoverVisible" title="" trigger="click" :overlayClassName="`${prefixCls}__overlay`">
|
|
|
|
- <Badge :count="count" :overflowCount="9" :offset="[-4, 10]" :numberStyle="numberStyle">
|
|
|
|
- <BellOutlined />
|
|
|
|
- </Badge>
|
|
|
|
- <template #content>
|
|
|
|
- <Tabs>
|
|
|
|
- <template v-for="item in listData" :key="item.key">
|
|
|
|
- <TabPane>
|
|
|
|
- <template #tab>
|
|
|
|
- {{ item.name }}
|
|
|
|
- <span v-if="item.list.length !== 0">({{ item.count }})</span>
|
|
|
|
- </template>
|
|
|
|
- <!-- 绑定title-click事件的通知列表中标题是“可点击”的-->
|
|
|
|
- <NoticeList :list="item.list" @title-click="onNoticeClick" />
|
|
|
|
- </TabPane>
|
|
|
|
- </template>
|
|
|
|
- </Tabs>
|
|
|
|
- <a-row class="bottom-buttons">
|
|
|
|
- <a-col :span="count === 0 ? 0 : 12">
|
|
|
|
- <a-button @click="onEmptyNotify" type="dashed" block>清空消息</a-button>
|
|
|
|
- </a-col>
|
|
|
|
- <a-col :span="count === 0 ? 24 : 12">
|
|
|
|
- <a-button @click="popoverVisible = false" type="dashed" block>
|
|
|
|
- <router-link to="/monitor/mynews">查看更多</router-link>
|
|
|
|
- </a-button>
|
|
|
|
- </a-col>
|
|
|
|
- </a-row>
|
|
|
|
- </template>
|
|
|
|
- </Popover>
|
|
|
|
|
|
+ <div class="msg-clock" :class="prefixCls">
|
|
|
|
+ <Badge :count="count" :overflowCount="9" :offset="[-4, 2]" :numberStyle="numberStyle" @click="clickBadge">
|
|
|
|
+ <BellOutlined />
|
|
|
|
+ </Badge>
|
|
|
|
+
|
|
<DynamicNotice ref="dynamicNoticeRef" v-bind="dynamicNoticeProps" />
|
|
<DynamicNotice ref="dynamicNoticeRef" v-bind="dynamicNoticeProps" />
|
|
<DetailModal @register="registerDetail" />
|
|
<DetailModal @register="registerDetail" />
|
|
|
|
+
|
|
|
|
+ <sys-message-modal @register="registerMessageModal" @refresh="reloadCount"></sys-message-modal>
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
@@ -49,7 +28,12 @@
|
|
import { connectWebSocket, onWebSocket } from '/@/hooks/web/useWebSocket';
|
|
import { connectWebSocket, onWebSocket } from '/@/hooks/web/useWebSocket';
|
|
import { readAllMsg } from '/@/views/monitor/mynews/mynews.api';
|
|
import { readAllMsg } from '/@/views/monitor/mynews/mynews.api';
|
|
import { getToken } from '/@/utils/auth';
|
|
import { getToken } from '/@/utils/auth';
|
|
|
|
+ import md5 from 'crypto-js/md5';
|
|
|
|
+
|
|
|
|
+ import SysMessageModal from '/@/views/system/message/components/SysMessageModal.vue'
|
|
|
|
+
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
|
|
+ inheritAttrs: false,
|
|
components: {
|
|
components: {
|
|
Popover,
|
|
Popover,
|
|
BellOutlined,
|
|
BellOutlined,
|
|
@@ -59,6 +43,7 @@
|
|
NoticeList,
|
|
NoticeList,
|
|
DetailModal,
|
|
DetailModal,
|
|
DynamicNotice,
|
|
DynamicNotice,
|
|
|
|
+ SysMessageModal,
|
|
},
|
|
},
|
|
setup() {
|
|
setup() {
|
|
const { prefixCls } = useDesign('header-notify');
|
|
const { prefixCls } = useDesign('header-notify');
|
|
@@ -67,17 +52,7 @@
|
|
const glob = useGlobSetting();
|
|
const glob = useGlobSetting();
|
|
const dynamicNoticeProps = reactive({ path: '', formData: {} });
|
|
const dynamicNoticeProps = reactive({ path: '', formData: {} });
|
|
const [registerDetail, detailModal] = useModal();
|
|
const [registerDetail, detailModal] = useModal();
|
|
- const popoverVisible = ref<boolean>(false);
|
|
|
|
const listData = ref(tabListData);
|
|
const listData = ref(tabListData);
|
|
- listData.value[0].list = [];
|
|
|
|
- listData.value[1].list = [];
|
|
|
|
- listData.value[0].count = 0;
|
|
|
|
- listData.value[1].count = 0;
|
|
|
|
-
|
|
|
|
- onMounted(() => {
|
|
|
|
- initWebSocket();
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
const count = computed(() => {
|
|
const count = computed(() => {
|
|
let count = 0;
|
|
let count = 0;
|
|
for (let i = 0; i < listData.value.length; i++) {
|
|
for (let i = 0; i < listData.value.length; i++) {
|
|
@@ -85,7 +60,23 @@
|
|
}
|
|
}
|
|
return count;
|
|
return count;
|
|
});
|
|
});
|
|
|
|
+ const chatRef = ref();
|
|
|
|
+
|
|
|
|
+ const [registerMessageModal, { openModal: openMessageModal }] = useModal();
|
|
|
|
+ function clickBadge(){
|
|
|
|
+ //消息列表弹窗前去除角标
|
|
|
|
+ for (let i = 0; i < listData.value.length; i++) {
|
|
|
|
+ listData.value[i].count = 0;
|
|
|
|
+ }
|
|
|
|
+ openMessageModal(true, {})
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const popoverVisible = ref<boolean>(false);
|
|
|
|
+ onMounted(() => {
|
|
|
|
+ initWebSocket();
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ const messageCount = ref<number>(0)
|
|
function mapAnnouncement(item) {
|
|
function mapAnnouncement(item) {
|
|
return {
|
|
return {
|
|
...item,
|
|
...item,
|
|
@@ -105,6 +96,13 @@
|
|
listData.value[1].list = sysMsgList.map(mapAnnouncement);
|
|
listData.value[1].list = sysMsgList.map(mapAnnouncement);
|
|
listData.value[0].count = anntMsgTotal;
|
|
listData.value[0].count = anntMsgTotal;
|
|
listData.value[1].count = sysMsgTotal;
|
|
listData.value[1].count = sysMsgTotal;
|
|
|
|
+ //update-begin-author:taoyan date:2022-8-30 for: 消息数量改变触发chat组件事件
|
|
|
|
+ let msgCount = anntMsgTotal+sysMsgTotal;
|
|
|
|
+ //update-begin-author:wangshuai date:2022-09-02 for: 消息未读数为0也需要传递,因为聊天需要计算总数
|
|
|
|
+ chatRef.value.updateMessageCount(msgCount);
|
|
|
|
+ messageCount.value = msgCount
|
|
|
|
+ //update-end-author:wangshuai date:2022-09-02 for: 消息未读数为0也需要传递,因为聊天需要计算总数
|
|
|
|
+ //update-end-author:taoyan date:2022-8-30 for: 消息数量改变触发chat组件事件
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.warn('系统消息通知异常:', e);
|
|
console.warn('系统消息通知异常:', e);
|
|
}
|
|
}
|
|
@@ -134,8 +132,10 @@
|
|
|
|
|
|
// 初始化 WebSocket
|
|
// 初始化 WebSocket
|
|
function initWebSocket() {
|
|
function initWebSocket() {
|
|
- let userId = unref(userStore.getUserInfo).id;
|
|
|
|
let token = getToken();
|
|
let token = getToken();
|
|
|
|
+ //将登录token生成一个短的标识
|
|
|
|
+ let wsClientId = md5(token);
|
|
|
|
+ let userId = unref(userStore.getUserInfo).id + "_" + wsClientId;
|
|
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
|
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
|
let url = glob.domainUrl?.replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId;
|
|
let url = glob.domainUrl?.replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId;
|
|
connectWebSocket(url);
|
|
connectWebSocket(url);
|
|
@@ -146,9 +146,9 @@
|
|
if (data.cmd === 'topic' || data.cmd === 'user') {
|
|
if (data.cmd === 'topic' || data.cmd === 'user') {
|
|
//update-begin-author:taoyan date:2022-7-13 for: VUEN-1674【严重bug】系统通知,为什么必须刷新右上角才提示
|
|
//update-begin-author:taoyan date:2022-7-13 for: VUEN-1674【严重bug】系统通知,为什么必须刷新右上角才提示
|
|
//后台保存数据太慢 前端延迟刷新消息
|
|
//后台保存数据太慢 前端延迟刷新消息
|
|
- setTimeout(() => {
|
|
|
|
|
|
+ setTimeout(()=>{
|
|
loadData();
|
|
loadData();
|
|
- }, 1000);
|
|
|
|
|
|
+ }, 1000)
|
|
//update-end-author:taoyan date:2022-7-13 for: VUEN-1674【严重bug】系统通知,为什么必须刷新右上角才提示
|
|
//update-end-author:taoyan date:2022-7-13 for: VUEN-1674【严重bug】系统通知,为什么必须刷新右上角才提示
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -158,17 +158,37 @@
|
|
popoverVisible.value = false;
|
|
popoverVisible.value = false;
|
|
readAllMsg({}, loadData);
|
|
readAllMsg({}, loadData);
|
|
}
|
|
}
|
|
|
|
+ async function reloadCount(id){
|
|
|
|
+ try {
|
|
|
|
+ await editCementSend(id);
|
|
|
|
+ await loadData();
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.error(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取消息未读数
|
|
|
|
+ */
|
|
|
|
+ function getSystemUnreadNum() {
|
|
|
|
+ chatRef.value.updateMessageCount(messageCount.value);
|
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
return {
|
|
prefixCls,
|
|
prefixCls,
|
|
listData,
|
|
listData,
|
|
count,
|
|
count,
|
|
|
|
+ clickBadge,
|
|
|
|
+ registerMessageModal,
|
|
|
|
+ reloadCount,
|
|
onNoticeClick,
|
|
onNoticeClick,
|
|
onEmptyNotify,
|
|
onEmptyNotify,
|
|
numberStyle: {},
|
|
numberStyle: {},
|
|
popoverVisible,
|
|
popoverVisible,
|
|
registerDetail,
|
|
registerDetail,
|
|
dynamicNoticeProps,
|
|
dynamicNoticeProps,
|
|
|
|
+ chatRef,
|
|
|
|
+ getSystemUnreadNum
|
|
};
|
|
};
|
|
},
|
|
},
|
|
});
|
|
});
|
|
@@ -187,7 +207,7 @@
|
|
padding: 0;
|
|
padding: 0;
|
|
}
|
|
}
|
|
|
|
|
|
- .ant-tabs-bar {
|
|
|
|
|
|
+ .ant-tabs-nav {
|
|
margin-bottom: 12px;
|
|
margin-bottom: 12px;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -268,4 +288,12 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /** VUEN-2222 鼠标放上去,怎么不是手势*/
|
|
|
|
+ .msg-clock{
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ &:hover{
|
|
|
|
+ background-color: #f6f6f6;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|