|
|
|
@ -63,27 +63,53 @@ export default { |
|
|
|
]) |
|
|
|
]) |
|
|
|
this.$store.commit('SET_MESSAGE_NUM', Number(countRes.data || 0)) |
|
|
|
this.$store.commit('SET_MESSAGE_NUM', Number(countRes.data || 0)) |
|
|
|
const page = listRes.data || listRes |
|
|
|
const page = listRes.data || listRes |
|
|
|
const list = page.list || page.rows || [] |
|
|
|
const list = page.list || page.rows || page.records || [] |
|
|
|
this.messageList = list.filter(item => String(item.isRead) !== '1') |
|
|
|
this.messageList = list.filter(item => String(item.isRead) !== '1') |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
this.$store.commit('SET_MESSAGE_NUM', 0) |
|
|
|
this.$store.commit('SET_MESSAGE_NUM', 0) |
|
|
|
this.messageList = [] |
|
|
|
this.messageList = [] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** 点击消息:查看详情(即已读)并刷新 */ |
|
|
|
/** 点击消息:标记已读并按消息类型跳转到对应单据(未知类型回退为详情弹窗) */ |
|
|
|
openMessage(item) { |
|
|
|
openMessage(item) { |
|
|
|
if (!item) return |
|
|
|
if (!item) return |
|
|
|
if (String(item.isRead) === '1') return |
|
|
|
if (String(item.isRead) === '1') return |
|
|
|
getMessageDetail(item.id) |
|
|
|
getMessageDetail(item.id) |
|
|
|
.then(response => { |
|
|
|
.then(response => { |
|
|
|
const detail = response.data || item |
|
|
|
const detail = response.data || item |
|
|
|
this.$alert(detail.content || '', detail.title || '消息详情', { confirmButtonText: '知道了' }) |
|
|
|
|
|
|
|
this.refresh() |
|
|
|
this.refresh() |
|
|
|
|
|
|
|
const target = this.resolveTarget(detail) |
|
|
|
|
|
|
|
if (target) { |
|
|
|
|
|
|
|
if (this.$refs.dropdownRef && this.$refs.dropdownRef.hide) this.$refs.dropdownRef.hide() |
|
|
|
|
|
|
|
this.$router.push(target) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.$alert(detail.content || '', detail.title || '消息详情', { confirmButtonText: '知道了' }) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
.catch(() => { |
|
|
|
this.$modal.msgError('消息详情加载失败') |
|
|
|
this.$modal.msgError('消息详情加载失败') |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 按 msgType/bizType+bizId 解析跳转目标: |
|
|
|
|
|
|
|
* 隐患类/积分到账 → 隐患详情(积分来自该隐患);申诉结果 → 申诉台账;未知类型返回 null 保持弹窗。 |
|
|
|
|
|
|
|
* 后端实际返回大写枚举(APPROVAL_RESULT / POINTS_AWARD / APPEAL_RESULT)并附带 bizType(如 hazard_report)。 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
resolveTarget(message) { |
|
|
|
|
|
|
|
const bizId = message && message.bizId ? String(message.bizId) : '' |
|
|
|
|
|
|
|
const msgType = String((message && message.msgType) || '').toUpperCase() |
|
|
|
|
|
|
|
const bizType = String((message && message.bizType) || '').toLowerCase() |
|
|
|
|
|
|
|
if (msgType === 'APPEAL_RESULT' || bizType.includes('appeal')) { |
|
|
|
|
|
|
|
return { path: '/points/appeal' } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (msgType === 'APPROVAL_RESULT' || msgType === 'POINTS_AWARD' || msgType === 'HAZARD_AUDIT' || bizType === 'hazard_report') { |
|
|
|
|
|
|
|
if (!bizId) return null |
|
|
|
|
|
|
|
const target = { path: '/hazard/audit/detail' } |
|
|
|
|
|
|
|
target.query = { id: bizId } |
|
|
|
|
|
|
|
return target |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
}, |
|
|
|
/** 全部已读 */ |
|
|
|
/** 全部已读 */ |
|
|
|
readAll() { |
|
|
|
readAll() { |
|
|
|
readAllMessages() |
|
|
|
readAllMessages() |
|
|
|
|