history.vue
8.53 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<template>
<div style="padding: 10px;background-color:#F2F3F5">
<div class="history">
<div style="height:58px;line-height:58px;">
<div style="color:#0006"> <span>消息中心</span> <span style="padding:0 5px;">></span> <span style="color:#000000e6">历史消息</span></div>
</div>
<div class="content">
<!-- 顶部搜索 -->
<div class="toolbar">
<el-form ref="formParams" :inline="true" :model="formParams">
<el-form-item label="标题">
<el-input v-model="formParams.noticeTitle" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="消息类型">
<el-select v-model="formParams.noticeType" placeholder="请选择消息类型" size="mini">
<el-option
v-for="(item, index) in tipsList"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="发送时间">
<el-date-picker
v-model="formParams.dates"
type="daterange"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
value-format="yyyy-MM-dd"
/>
</el-form-item>
<el-form-item label-width="0">
<el-button @click="search('formParams')" style="background-color: #3F9B6A;color: #fff">查询</el-button>
<el-button @click="clear('formParams')" class="buttonHover"
style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;" >重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 表格 -->
<div class="content_table">
<div class="table">
<el-table
:data="list"
:header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
>
<el-table-column prop="noticeTitle" label="标题" />
<el-table-column label="内容" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-html="scope.row.noticeContent" />
</template>
</el-table-column>
<el-table-column prop="noticeType" label="消息类型">
<template slot-scope="scope">
<span>{{ scope.row.noticeType===1?'系统通知':scope.row.noticeType===2?'公告':scope.row.noticeType===3?'站内信':'' }}</span>
</template>
</el-table-column>
<el-table-column prop="createTime" label="发送时间" />
<el-table-column label="操作">
<template slot-scope="scope">
<div @click="details(scope.row.noticeId)" class="tableBtn greens">详情</div>
<div @click="delMsg(scope.row.noticeId)" class="tableBtn greens">删除</div>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页 -->
<div class="fenye">
<el-pagination
:current-page="formParams.page"
:page-sizes="[10, 20, 50, 100]"
:page-size="10"
background
small
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</div>
</div>
<!-- 消息详情弹窗 -->
<el-dialog
title="消息详情"
:visible.sync="dialogVisible"
width="60%"
:before-close="handleClose"
modal
>
<div>
<h2 style="text-align:center;font-weight:bold;">{{ noticeDetails.noticeTitle }}</h2>
<span style="float: right;">{{ noticeDetails.createTime }}</span>
<el-divider />
<div v-html="noticeDetails.noticeContent" />
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import { noticeGetAll, noticeGetById, noticeDelete } from '@/api/notice'
export default {
data() {
return {
list: [],
total: 1,
formParams: {
noticeTitle: null,
noticeType: null,
dates: [],
page: 1,
pageSize: 10
},
tipsList: [{
id: 1,
name: '系统消息'
},
{
id: 2,
name: '公告'
},
{
id: 3,
name: '站内信'
}],
rules: {
noticeTitle: [
{ required: true, message: '请输入标题', trigger: 'blur' },
{ min: 1, message: '请输入标题', trigger: 'blur' }
],
noticeType: [
{ required: true, message: '请选择消息类型', trigger: 'change' }
]
},
dialogVisible: false,
noticeDetails: {
noticeTitle: '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊',
createTime: '2021-03-10 10:10',
noticeContent: `<h1 style="text-align: center;">Welcome to the TinyMCE demo!</h1><p style="text-align: center; font-size: 15px;"><img title="TinyMCE Logo" src="//www.tinymce.com/images/glyph-tinymce@2x.png" alt="TinyMCE Logo" width="110" height="97" /><ul>
<li>Our <a href="//www.tinymce.com/docs/">documentation</a> is a great resource for learning how to configure TinyMCE.</li><li>Have a specific question? Visit the <a href="https://community.tinymce.com/forum/">Community Forum</a>.</li><li>We also offer enterprise grade support as part of <a href="https://tinymce.com/pricing">TinyMCE premium subscriptions</a>.</li>
</ul>`
}
}
},
mounted() {
this.getAll()
},
methods: {
// 历史消息列表
async getAll() {
const res = await noticeGetAll(this.formParams)
this.list = res.data.list
this.total = res.data.total
},
// 消息详情
async details(id) {
const res = await noticeGetById({ noticeId: id })
this.noticeDetails = res.data
this.dialogVisible = true
},
// 删除消息提示
async delMsg(id) {
this.$confirm('此操作将永久删除该消息, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.del(id)
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
// 删除消息
async del(id) {
const res = await noticeDelete({ noticeId: id })
if (res.code === '') {
this.$message({
message: '删除成功',
type: 'success'
})
this.getAll()
}
},
// 查询
async search(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.total = 1
this.formParams.page = 1
this.getAll()
} else {
return false
}
})
},
// 重置表单
async clear(formName) {
this.$refs[formName].resetFields()
this.getAll()
},
// 更改页数
async handleSizeChange(val) {
this.formParams.pageSize = val
this.getAll()
},
// 翻页
async handleCurrentChange(val) {
this.formParams.page = val
this.getAll()
},
// 关闭消息详情
async handleClose() {
this.dialogVisible = false
}
}
}
</script>
<style lang='scss' scoped>
@import url("../../styles/elDialog.scss");
.history{
padding: 0 20px 20px 20px;
min-height: calc(100vh - 50px - 20px);
background-color: #Fff;
}
::v-deep .el-form-item__label{
font-weight: normal;
font-size: 14px;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
background-color: #3F9B6A;
}
.tableBtn {
display: inline-block;
margin-right: 10px;
}
.greens {
color: #3F9B6A ;
}
::v-deep .buttonHover:hover{
color:#3f9b6a !important;
border-color: #c5e1d2 !important;
background-color: #ecf5f0 !important;
outline: none;
}
::v-deep .el-pagination__total {
position: absolute;
left: 10px;
}
</style>
<style scoped>
.history /deep/ .el-table .cell.el-tooltip img {
max-height: 100px;
}
</style>
<style>
.el-tooltip__popper {
max-width: 50%;
}
</style>