noticeList.vue
2.88 KB
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
<template>
<div class = "noticeList">
<setting v-on:settingchanged="reload"></setting>
<ul>
<li class = "item">
<a><div class = "title">아무 제목이나 써보았습니다.</div></a>
<div class = "noticeInfo">
<span class = "site sw" >SW융합</span>
<span class = "date">2020-20-03</span>
</div>
</li>
<li class = "item" v-for="notice in noticeList" :key="notice">
<a v-bind:href="notice.link" target="_blank"><div class = "title">{{notice.title}}</div></a>
<div class = "noticeInfo">
<span class = "site khu" v-if="notice.site == '경희대학교 공지사항'">경희대</span>
<span class = "site sw" v-else-if="notice.site == '소프트웨어 융합대학 공지사항'">SW융합</span>
<span class = "site janghak" v-else-if="notice.site == '경희대학교 장학센터'">장학센터</span>
<span class = "date">{{notice.date}}</span>
</div>
</li>
</ul>
</div>
</template>
<script>
import axios from 'axios'
import setting from './setting'
export default {
el: '.noticeList',
components: {
'setting': setting
},
data () {
return {
noticeList: [],
sql: 'select title,link,date_format(date,"%Y-%m-%d") as date,site from noticeList order by date desc',
basic: 'select title,link,date_format(date,"%Y-%m-%d") as date,site from noticeList'
}
},
created () {
this.fetchNoticeList()
},
methods: {
fetchNoticeList () {
axios
.post('/api/fetchNoticeList', {
sql: this.sql
})
.then((noticeList) => {
this.noticeList = noticeList.data
})
},
reload (setting) {
var sql = this.basic
sql += ' where 0'
setting.forEach(function (item) {
if (item.seen === true) {
sql += ' or site = ' + '\'' + item.official + '\''
}
})
this.sql = sql + ' order by date desc'
this.fetchNoticeList()
}
}
}
</script>
<style>
.noticeList{
width: 1010px;
background: rgb(249,249,249);
}
ul{
display: flex;
flex-direction: column;
align-items: center;
margin: 0 auto 10px auto;
}
li{
margin-bottom:2px;
}
.item{
background: white;
height: 32px;
display: flex;
position: relative;
padding: 6px 15px 18px;
width: 960px;
border-radius:5px;
}
.title{
font-size:15px;
}
a{
color: #34495e;
}
a:visited{
color: grey;
}
.noticeInfo{
position: absolute;
bottom:12px;
font-size:12px;
}
.date{
color: grey;
}
.site{
color: white;
font-size:10px;
padding: 2px 10px;
}
.khu{
background-color: #C0392B;
}
.sw{
background-color: #3498DB;
}
.janghak{
background-color: #632300;
}
</style>