first commit
This commit is contained in:
94
pgweb/src/store/modules/message.js
Normal file
94
pgweb/src/store/modules/message.js
Normal file
@@ -0,0 +1,94 @@
|
||||
export default {
|
||||
state: {
|
||||
// message: {
|
||||
// // 待办事项
|
||||
// info: {
|
||||
// list: [],
|
||||
// unReadNum: 0
|
||||
// },
|
||||
// // 进度提醒
|
||||
// notice: {
|
||||
// list: [],
|
||||
// unReadNum: 0
|
||||
// },
|
||||
// // 预警消息
|
||||
// warning: {
|
||||
// list: [],
|
||||
// unReadNum: 0
|
||||
// }
|
||||
// },
|
||||
message: [],
|
||||
messageUnReadNum: 0 // 未读总数
|
||||
},
|
||||
getters: {
|
||||
messageList: state => state.message,
|
||||
messageUnReadNum: state => state.messageUnReadNum // 未读数量
|
||||
// infoUnReadNum: state => state.message.info.unReadNum, // 待办事项未读数量
|
||||
// noticeUnReadNum: state => state.message.notice.unReadNum, // 进度提醒未读数量
|
||||
// warningUnReadNum: state => state.message.warning.unReadNum // 预警消息未读数量
|
||||
},
|
||||
mutations: {
|
||||
/**
|
||||
* 新增一条消息
|
||||
* @param {*} state
|
||||
* @param {*} message
|
||||
*/
|
||||
addNewMsg (state, message) {
|
||||
const msg = state.message.find(item => {
|
||||
return item.id === message.id
|
||||
})
|
||||
if (!msg) {
|
||||
state.message.unshift(message)
|
||||
// state.message.unReadNum += 1
|
||||
state.messageUnReadNum += 1
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 新增全部未读消息
|
||||
* @param {} state
|
||||
* @param {*} messageList
|
||||
*/
|
||||
addAllMessage (state, messageList) {
|
||||
state.message = messageList.list
|
||||
state.messageUnReadNum = messageList.issee_num
|
||||
},
|
||||
/**
|
||||
* 滚动加载更多消息
|
||||
* @param {*} state
|
||||
* @param {*} message
|
||||
*/
|
||||
addMoreMsg (state, message) {
|
||||
state.message.push(...message)
|
||||
},
|
||||
/**
|
||||
* 已读
|
||||
* @param {*} state
|
||||
* @param {*} message
|
||||
*/
|
||||
setUnRead (state, message) {
|
||||
const msg = state.message.findIndex(item => {
|
||||
return item.id === message.id
|
||||
})
|
||||
if (msg !== -1) {
|
||||
state.message[msg].issee = 1
|
||||
if (state.messageUnReadNum > 0) {
|
||||
state.messageUnReadNum -= 1
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 全部已读
|
||||
* @param {*} state
|
||||
*/
|
||||
setAllRead (state) {
|
||||
if (state.message.length > 0) {
|
||||
let msgList = state.message
|
||||
state.message = msgList.map(msg => {
|
||||
msg.issee = 1
|
||||
return msg
|
||||
})
|
||||
}
|
||||
state.messageUnReadNum = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user