Blame view

yudao-ui-admin/src/layout/components/Message/index.vue 2.34 KB
ae3ee95c   YunaiV   站内信模块:整体功能实现
1
2
3
4
5
6
7
8
9
10
  <template>
    <div>
      <el-popover placement="bottom" width="600" trigger="click">
        <!-- icon 展示 -->
        <el-badge slot="reference" :is-dot="unreadCount > 0" type="danger">
           <svg-icon icon-class="message" @click="getList"/>
        </el-badge>
  
        <!-- 弹出列表 -->
        <el-table v-loading="loading" :data="list">
1943e71e   YunaiV   站内信模块:完善注释
11
          <el-table-column width="120" property="templateNickname" label="发送人" />
91dd4a32   YunaiV   站内信模块:vue3 站内信弹板
12
          <el-table-column width="180" property="createTime" label="发送时间">
0bd0bbd5   xingyu   fix: slot-scope 已...
13
            <template v-slot="scope">
ae3ee95c   YunaiV   站内信模块:整体功能实现
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="类型" align="center" prop="templateType" width="100">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" />
            </template>
          </el-table-column>
          <el-table-column property="templateContent" label="内容" />
        </el-table>
  
        <!-- 更多 -->
        <div style="text-align: right; margin-top: 10px">
          <el-button type="primary" size="mini" @click="goMyList">查看全部</el-button>
        </div>
      </el-popover>
    </div>
  </template>
  
  <script>
  import {getUnreadNotifyMessageCount, getUnreadNotifyMessageList} from "@/api/system/notify/message";
  
  export default {
    name: 'NotifyMessage',
    data() {
      return {
        // 遮罩层
        loading: false,
        // 列表
        list: [],
        // 未读数量,
        unreadCount: 0,
      }
    },
    created() {
      // 首次加载小红点
      this.getUnreadCount()
      // 轮询刷新小红点
91dd4a32   YunaiV   站内信模块:vue3 站内信弹板
52
      setInterval(() => {
ae3ee95c   YunaiV   站内信模块:整体功能实现
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
        this.getUnreadCount()
      },1000 * 60 * 2)
    },
    methods: {
      getList: function() {
        this.loading = true;
        getUnreadNotifyMessageList().then(response => {
          this.list = response.data;
          this.loading = false;
          // 强制设置 unreadCount 为 0,避免小红点因为轮询太慢,不消除
          this.unreadCount = 0
        });
      },
      getUnreadCount: function() {
        getUnreadNotifyMessageCount().then(response => {
          this.unreadCount = response.data;
        })
      },
      goMyList: function() {
        this.$router.push({
          name: 'MyNotifyMessage'
        });
      }
    }
  }
  </script>
  <style>
  .el-badge__content.is-fixed {
    top: 10px; /* 保证徽章的位置 */
  }
  </style>