zhanghua
2024-11-22 33f7c189aee851636f57cd0de88812332944f185
1
2
3
4
5
6
7
8
9
10
11
12
13
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
52
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
    <div v-loading="state.loading" class="layout-navbars-breadcrumb-user-news">
        <div class="head-box">
            <div class="head-box-title">通知公告</div>
            <div class="head-box-btn" @click="readAll">全部已读</div>
        </div>
        <div v-loading="state.loading" class="content-box">
            <template v-if="newsList.length > 0">
                <div
                    v-for="(v, k) in newsList"
                    :key="k"
                    class="content-box-item"
                    @click="onNewsClick(k)"
                >
                    <div class="item-conten">
                        <div>{{ v.message }}</div>
                        <div class="content-box-msg"></div>
                        <div class="content-box-time">{{ v.time }}</div>
                    </div>
                    <!-- 已读/未读 -->
                    <span
                        v-if="v.read"
                        class="el-tag el-tag--success el-tag--mini read"
                        >已读</span
                    >
                    <span v-else class="el-tag el-tag--danger el-tag--mini read"
                        >未读</span
                    >
                </div>
            </template>
            <el-empty v-else :description="'消息为空'"></el-empty>
        </div>
    </div>
</template>
 
<script >
// import { storeToRefs } from 'pinia';
// import useNoticeStore from '@/store/modules/notice';
 
export default {
    data() {
        return {
            state: {
                loading: false
            },
            newsList: []
        }
    },
    methods: {
        /**
         * 初始化数据
         * @returns
         */
        getTableData() {
            this.state.loading = true;
            // this.newsList.value = noticeStore.state.value.notices;
            this.state.loading = false;
        },
        //点击消息,写入已读
        onNewsClick(item) {
            this.newsList.value[item].read = true;
            //并且写入pinia
            this.noticeStore.state.value.notices = newsList.value;
        },
        readAll() {
 
        },
        // 前往通知中心点击
        onGoToGiteeClick() {
            window.open('https://gitee.com/dromara/RuoYi-Vue-Plus/tree/5.X/');
        }
    },
    mounted: function () {
        this.$nextTick(() => {
            this.getTableData();
        });
    }
}
</script>
 
<style scoped lang="scss">
.layout-navbars-breadcrumb-user-news {
    .head-box {
        display: flex;
        border-bottom: 1px solid var(--el-border-color-lighter);
        box-sizing: border-box;
        color: var(--el-text-color-primary);
        justify-content: space-between;
        height: 35px;
        align-items: center;
 
        .head-box-btn {
            color: var(--el-color-primary);
            font-size: 13px;
            cursor: pointer;
            opacity: 0.8;
 
            &:hover {
                opacity: 1;
            }
        }
    }
 
    .content-box {
        height: 300px;
        overflow: auto;
        font-size: 13px;
 
        .content-box-item {
            padding-top: 12px;
            display: flex;
 
            &:last-of-type {
                padding-bottom: 12px;
            }
 
            .content-box-msg {
                color: var(--el-text-color-secondary);
                margin-top: 5px;
                margin-bottom: 5px;
            }
 
            .content-box-time {
                color: var(--el-text-color-secondary);
            }
 
            .item-conten {
                width: 100%;
                display: flex;
                flex-direction: column;
            }
        }
    }
 
    .foot-box {
        height: 35px;
        color: var(--el-color-primary);
        font-size: 13px;
        cursor: pointer;
        opacity: 0.8;
        display: flex;
        align-items: center;
        justify-content: center;
        border-top: 1px solid var(--el-border-color-lighter);
 
        &:hover {
            opacity: 1;
        }
    }
 
    ::v-deep .el-empty__description p {
        font-size: 13px;
    }
}
</style>