nebula/components/common/notification/list.vue

105 lines
4.1 KiB
Vue
Raw Normal View History

2020-08-02 19:21:51 +08:00
<template>
<client-only>
<el-row>
<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">
<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;">
<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>
<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;">
<el-link rel="nofollow" v-if="notification.hasRead === '0'" :underline="false" @click="read(notification.idNotification)">
<i class="el-icon-check"></i> 标记已读
</el-link>
</el-col>
</el-col>
2020-08-02 19:21:51 +08:00
<el-col v-else>
<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">
<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;">
<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>
export default {
name: "NotificationList",
props: {
notifications: {
type: Object
}
},
methods: {
currentChange(page) {
this.$emit('currentChange', page);
},
read(id) {
let _ts = this;
2020-08-04 21:50:59 +08:00
this.$axios.$put('/api/notification/read/' + id).then(function () {
2021-03-15 21:16:01 +08:00
_ts.$store.commit('notification/updateState', true)
2020-08-02 19:21:51 +08:00
_ts.currentChange(1);
2020-08-03 21:29:44 +08:00
}).catch(error => console.log(error));
2020-08-02 19:21:51 +08:00
},
onRouter(notification) {
2020-08-04 21:50:59 +08:00
if (notification.hasRead === '0') {
this.read(notification.idNotification);
2020-08-02 19:21:51 +08:00
}
2020-08-04 21:50:59 +08:00
window.location.href = notification.dataUrl;
2020-08-02 19:21:51 +08:00
}
}
}
</script>
<style scoped>
</style>