2020-08-02 19:21:51 +08:00
|
|
|
<template>
|
|
|
|
<client-only>
|
|
|
|
<el-row>
|
2022-05-25 21:38:07 +08:00
|
|
|
<el-col v-if="hasUnReadNotification" style="text-align: right;padding: 20px;">
|
|
|
|
<el-link rel="nofollow" :underline="false"
|
|
|
|
@click="readAll()">
|
|
|
|
<i class="el-icon-check"></i> 一键标记已读
|
|
|
|
</el-link>
|
|
|
|
</el-col>
|
2020-08-02 19:21:51 +08:00
|
|
|
<el-col v-for="notification in notifications.notifications" :key="notification.idNotification">
|
|
|
|
<el-col v-if="notification.dataType == 0">
|
2020-08-04 22:44:17 +08:00
|
|
|
<el-col :xs="16" :sm="20" :xl="20">
|
2020-08-12 11:28:37 +08:00
|
|
|
<el-link rel="nofollow" :underline="false" @click="onRouter(notification)" style="font-size: 1.1em;"
|
2020-08-02 19:21:51 +08:00
|
|
|
v-html="notification.dataSummary"></el-link>
|
2020-08-04 21:50:59 +08:00
|
|
|
<el-col style="font-size: 12px;color: #7f828b;">{{ notification.createdTime }}</el-col>
|
2020-08-02 19:21:51 +08:00
|
|
|
</el-col>
|
2020-08-04 22:44:17 +08:00
|
|
|
<el-col :xs="8" :sm="4" :xl="4" class="text-right" style="padding-right: 1rem;">
|
2021-04-27 21:12:16 +08:00
|
|
|
<el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false"
|
|
|
|
@click="read(notification.idNotification)">
|
2020-08-04 22:44:17 +08:00
|
|
|
<i class="el-icon-check"></i> 标记已读
|
2020-08-02 19:21:51 +08:00
|
|
|
</el-link>
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
2020-09-29 21:41:06 +08:00
|
|
|
<el-col v-else-if="notification.dataType == '-1'">
|
|
|
|
<el-col :xs="16" :sm="20" :xl="20">
|
|
|
|
<el-link rel="nofollow" :underline="false" style="font-size: 1.1em;"
|
|
|
|
v-html="notification.dataSummary"></el-link>
|
|
|
|
<el-col style="font-size: 12px;color: #7f828b;">{{ notification.createdTime }}</el-col>
|
|
|
|
</el-col>
|
|
|
|
<el-col :xs="8" :sm="4" :xl="4" class="text-right" style="padding-right: 1rem;">
|
2021-04-27 21:12:16 +08:00
|
|
|
<el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false"
|
|
|
|
@click="read(notification.idNotification)">
|
2020-09-29 21:41:06 +08:00
|
|
|
<i class="el-icon-check"></i> 标记已读
|
|
|
|
</el-link>
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
2020-08-02 19:21:51 +08:00
|
|
|
<el-col v-else>
|
2020-09-29 21:41:06 +08:00
|
|
|
<el-col v-if="notification.author" :xs="4" :xl="2">
|
2020-08-04 21:50:59 +08:00
|
|
|
<el-avatar :src="notification.author.userAvatarURL"></el-avatar>
|
2020-08-02 19:21:51 +08:00
|
|
|
</el-col>
|
2020-08-04 21:50:59 +08:00
|
|
|
<el-col :xs="20" :xl="22">
|
|
|
|
<el-col :xs="16" :sm="20" :xl="20">
|
2020-08-12 11:28:37 +08:00
|
|
|
<el-link rel="nofollow" :underline="false" @click="onRouter(notification)" style="font-size: 1.1em;"
|
2020-08-04 21:50:59 +08:00
|
|
|
v-html="notification.dataTitle"></el-link>
|
|
|
|
<el-col style="font-size: 12px;color: #7f828b;">
|
|
|
|
{{ notification.createdTime }}
|
|
|
|
</el-col>
|
|
|
|
<el-col>
|
|
|
|
{{ notification.dataSummary }}
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
<el-col :xs="8" :sm="4" :xl="4" class="text-right" style="padding-right: 1rem;">
|
2020-08-12 11:28:37 +08:00
|
|
|
<el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false"
|
2020-08-04 21:50:59 +08:00
|
|
|
@click="read(notification.idNotification)">
|
|
|
|
<i class="el-icon-check" style="font-weight: bold;"></i> 标记已读
|
|
|
|
</el-link>
|
|
|
|
</el-col>
|
2020-08-02 19:21:51 +08:00
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
<el-col>
|
|
|
|
<el-divider></el-divider>
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
<el-col>
|
|
|
|
<div class="vertical-container text-center">
|
2020-10-20 22:28:21 +08:00
|
|
|
<el-pagination :hide-on-single-page="true" v-model="notifications.pagination"
|
2020-08-02 19:21:51 +08:00
|
|
|
layout="prev, pager, next"
|
2021-02-24 09:22:25 +08:00
|
|
|
:page-size="notifications.pagination.pageSize"
|
2020-08-02 19:21:51 +08:00
|
|
|
:current-page="notifications.pagination.currentPage"
|
|
|
|
:total="notifications.pagination.total"
|
2021-02-24 09:22:25 +08:00
|
|
|
prev-text="上一页"
|
|
|
|
next-text="下一页"
|
2020-08-02 19:21:51 +08:00
|
|
|
@current-change="currentChange">
|
|
|
|
</el-pagination>
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</client-only>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-04-27 21:12:16 +08:00
|
|
|
export default {
|
|
|
|
name: "NotificationList",
|
|
|
|
props: {
|
|
|
|
notifications: {
|
|
|
|
type: Object
|
|
|
|
}
|
|
|
|
},
|
2022-05-25 21:38:07 +08:00
|
|
|
computed: {
|
|
|
|
hasUnReadNotification: function () {
|
|
|
|
let nums = 0;
|
|
|
|
let notifications = this.notifications.notifications;
|
|
|
|
for (const index in notifications) {
|
|
|
|
if (notifications[index].hasRead === '0') {
|
|
|
|
nums++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nums > 0;
|
|
|
|
}
|
|
|
|
},
|
2021-04-27 21:12:16 +08:00
|
|
|
methods: {
|
|
|
|
currentChange(page) {
|
|
|
|
this.$emit('currentChange', page);
|
|
|
|
},
|
|
|
|
read(id) {
|
|
|
|
let _ts = this;
|
|
|
|
this.$axios.$put('/api/notification/read/' + id).then(function () {
|
|
|
|
_ts.$store.commit('notification/updateState', true)
|
|
|
|
_ts.$store.dispatch('notification/fetchList', {page: 1})
|
|
|
|
}).catch(error => console.log(error));
|
2020-08-02 19:21:51 +08:00
|
|
|
},
|
2022-05-25 21:38:07 +08:00
|
|
|
readAll() {
|
|
|
|
let _ts = this;
|
|
|
|
this.$axios.$put('/api/notification/read-all').then(function () {
|
|
|
|
_ts.$store.commit('notification/updateState', true)
|
|
|
|
_ts.$store.dispatch('notification/fetchList', {page: 1})
|
|
|
|
}).catch(error => console.log(error));
|
|
|
|
},
|
2021-04-27 21:12:16 +08:00
|
|
|
onRouter(notification) {
|
|
|
|
if (notification.hasRead === '0') {
|
|
|
|
this.read(notification.idNotification);
|
2020-08-02 19:21:51 +08:00
|
|
|
}
|
2021-04-27 21:12:16 +08:00
|
|
|
window.location.href = notification.dataUrl;
|
2020-08-02 19:21:51 +08:00
|
|
|
}
|
|
|
|
}
|
2021-04-27 21:12:16 +08:00
|
|
|
}
|
2020-08-02 19:21:51 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|