|
@@ -0,0 +1,131 @@
|
|
|
+<template>
|
|
|
+ <el-popover
|
|
|
+ placement="bottom"
|
|
|
+ width="400"
|
|
|
+ trigger="click"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <div class="top">
|
|
|
+ 通知
|
|
|
+ <div class="tool">
|
|
|
+ <m-button type="primary" size="mini" text class="pa-0">查看全部信息</m-button>
|
|
|
+ <m-button type="primary" size="mini" text class="pa-0">全部标记为已读</m-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="message">
|
|
|
+ <div v-for="item in items" :key="item.id" class="message-box" :class="{ disabled: item.status === 0 }" @click="onTo(item)">
|
|
|
+ <div class="message-box-title">{{ item.title }}</div>
|
|
|
+ <div class="message-box-content">{{ item.content }}</div>
|
|
|
+ <div class="message-box-footer">
|
|
|
+ <div class="message-box-footer-time">{{ item.time }}</div>
|
|
|
+ <div v-if="item.status === 1" class="message-box-footer-actions">
|
|
|
+ <m-button text type="primary" size="mini" @click.stop="onSet(item)">标记为已读</m-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-divider v-if="items.length > 0 && items.length >= total">没有更多消息了</el-divider>
|
|
|
+ <el-empty v-if="items.length === 0" description="暂无通知"></el-empty>
|
|
|
+ </div>
|
|
|
+ <el-badge class="cursor-pointer" slot="reference" :value="badgeValue" :max="99" :hidden="badgeValue === 0">
|
|
|
+ <span class="el-icon-bell"></span>
|
|
|
+ </el-badge>
|
|
|
+ </el-popover>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ name: 'LayoutNotification',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ activeName: 'inform',
|
|
|
+ total: 0,
|
|
|
+ items: [
|
|
|
+ {
|
|
|
+ title: '您有新的审核提醒',
|
|
|
+ content: '通知内容1',
|
|
|
+ time: '2020-01-01 12:00:00',
|
|
|
+ status: 1,
|
|
|
+ id: '1'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '您有新的审核提醒',
|
|
|
+ content: '通知内容1',
|
|
|
+ time: '2020-01-01 12:00:00',
|
|
|
+ status: 1,
|
|
|
+ id: '2'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ badgeValue () {
|
|
|
+ return this.items.filter(item => item.status === 1).length
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onSet (item) {
|
|
|
+ item.status = 0
|
|
|
+ },
|
|
|
+ onTo (item) {
|
|
|
+ this.$message('开发中,敬请期待')
|
|
|
+ // console.log(2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.tool {
|
|
|
+ text-align: right;
|
|
|
+ font-size: 0;
|
|
|
+}
|
|
|
+.top {
|
|
|
+ padding: 10px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ font-size: 16px;
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+ color: $theme-color;
|
|
|
+}
|
|
|
+.message {
|
|
|
+ max-height: 600px;
|
|
|
+ overflow: auto;
|
|
|
+ &-box {
|
|
|
+ &.disabled {
|
|
|
+ opacity: .5;
|
|
|
+ }
|
|
|
+ &:hover {
|
|
|
+ background-color: #f5f7fa;
|
|
|
+ }
|
|
|
+ &:not(:last-child) {
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+ }
|
|
|
+ cursor: pointer;
|
|
|
+ padding: 10px;
|
|
|
+ &-title {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ &-content {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ &-footer {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ height: 30px;
|
|
|
+ &-time {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ &-actions {
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|