diff --git a/src/api/system/notice.js b/src/api/system/notice.js
index 308fd071..fe944a0e 100644
--- a/src/api/system/notice.js
+++ b/src/api/system/notice.js
@@ -9,7 +9,18 @@ export function listNotice(query) {
})
}
-
+/**
+ * 获取用户自己通知或公告列表
+ * @param query
+ * @returns
+ */
+export function getUserNoticeList(query) {
+ return request({
+ url: '/system/notice/getUserNoticeList',
+ method: 'get',
+ params: query
+ })
+}
// 查询用户公告列表
export function getTopNoticeListByUserId(query) {
@@ -73,3 +84,13 @@ export function delNotice(noticeId) {
method: 'delete'
})
}
+
+/**
+ * 清除记录
+ */
+export function clearNotice(noticeId) {
+ return request({
+ url: '/system/notice/clearNotice/' + noticeId,
+ method: 'post'
+ })
+}
diff --git a/src/layout/components/TopNotice/index.vue b/src/layout/components/TopNotice/index.vue
index dab0f3b1..fd5bd4ed 100644
--- a/src/layout/components/TopNotice/index.vue
+++ b/src/layout/components/TopNotice/index.vue
@@ -8,7 +8,8 @@
popper-class="xd-notice-pop">
-
清空通知
+
清空通知
-
查看更多
+
查看更多
@@ -76,7 +77,7 @@
import {Notification} from "element-ui";
import Speech from 'speak-tts'
-import {getTopNoticeListByUserId,addReadTimes,getPublicNoticeList} from "@/api/system/notice";
+import {getTopNoticeListByUserId,addReadTimes,getPublicNoticeList,clearNotice} from "@/api/system/notice";
export default {
name: 'TopNotice',
data() {
@@ -86,6 +87,7 @@ export default {
active: 'alertTab',
isPlay:false,
alertList:[],
+ noReadNoticeCount:0,
noticeList: [],
xdNoticSdk:null,
@@ -95,11 +97,9 @@ export default {
computed: {
// 所有消息数量
allNum() {
- return this.alertList.length;
+ return this.noReadNoticeCount;
},
- newNotice(){
- return 0;
- }
+
},
mounted() {
window.addEventListener("click", this.setCanPlayTone);
@@ -153,8 +153,12 @@ export default {
onMessage(evtStr){
let that=this;
+
+ if(evtStr==null||evtStr==undefined){
+ return;
+ }
+
let evt= JSON.parse(evtStr);
- console.log("===>onMessage==>",evt)
if(evt==null||evt==undefined){
return;
}
@@ -197,6 +201,7 @@ export default {
// 获取通知信息
getTopNoticeListByUserId().then(response => {
this.alertList=response.rows;
+ this.calcNoReadNoticeCount();
});
// 获取公告信息
@@ -206,6 +211,17 @@ export default {
},
+ calcNoReadNoticeCount(){
+ this.noReadNoticeCount = 0;
+ this.alertList.forEach(item=>{
+
+ if(item.blRead == 0) {
+ this.noReadNoticeCount=this.noReadNoticeCount+1;
+ }
+
+ });
+ },
+
showNotice(item){
console.log("==showNotice===>xxx===>",item);
this.setAddReadTimes(item.noticeId);
@@ -256,8 +272,12 @@ export default {
/* 清空消息 */
clear(type) {
- if (type === 'notice') {
- this.notice = [];
+ if (type === 'alert') {
+ let noticeIds=this.alertList.map(item=>item.id).join(',');
+ clearNotice(noticeIds).then(response => {
+ console.log("清除成功");
+ this.alertList = [];
+ });
}
},
/* 查看更多 */