md
This commit is contained in:
parent
cdd405bb82
commit
666131a42c
@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
popper-class="xd-notice-pop">
|
||||
<div slot="reference" >
|
||||
<div>
|
||||
<el-badge :value="allNum" :hidden="!newNotice">
|
||||
<!-- :hidden="!newNotice" -->
|
||||
<el-badge :value="allNum" >
|
||||
<i class="el-icon-bell"></i>
|
||||
</el-badge>
|
||||
</div>
|
||||
@ -38,9 +39,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="alertList.length" class="ele-cell xd-notice-actions">
|
||||
<div class="xd-item-content" @click="clear('notice')">清空通知</div>
|
||||
<div class="xd-item-content" @click="clear('alert')">清空通知</div>
|
||||
<el-divider direction="vertical" class="line-color-light"/>
|
||||
<div class="xd-item-content" @click="more('notice')">查看更多</div>
|
||||
<div class="xd-item-content" @click="more('alert')">查看更多</div>
|
||||
</div>
|
||||
<el-empty v-if="!alertList.length" description="没有最新消息" />
|
||||
</el-tab-pane>
|
||||
@ -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 = [];
|
||||
});
|
||||
}
|
||||
},
|
||||
/* 查看更多 */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user