push.vue
4.11 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
<template>
<div style="padding: 10px;background-color:#F2F3F5">
<div class="push">
<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" :rules="rules">
<el-form-item label="标题" prop="noticeTitle">
<el-input v-model="formParams.noticeTitle" maxlength="18" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="消息类型" prop="noticeType">
<el-select v-model="formParams.noticeType" placeholder="请选择消息类型" >
<el-option
v-for="(item, index) in typeList"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="接收用户" prop="receive">
<el-select v-model="formParams.receive" placeholder="请选择接收用户" >
<el-option
v-for="(item, index) in userList"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
</div>
<!-- 富文本编辑器 -->
<div>
<tinymce ref="tinymceContent" v-model="formParams.noticeContent" :height="400" />
</div>
<div style="margin-top:20px;">
<el-button @click="send('formParams')" style="background-color: #3F9B6A;color: #fff">发送</el-button>
</div>
</div>
</div>
</div>
</template>
<script>
import Tinymce from '@/components/Tinymce'
import { noticeSave } from '@/api/notice'
export default {
components: { Tinymce },
data() {
return {
typeList: [{
id: 2,
name: '公告'
},
{
id: 3,
name: '站内信'
}],
userList: [{
id: 1,
name: '全部用户'
},
{
id: 2,
name: '商家'
},
{
id: 3,
name: '普通用户'
}],
formParams: {
noticeTitle: null,
noticeType: null,
noticeContent: null,
receive: null
},
rules: {
noticeTitle: [
{ required: true, message: '请输入标题', trigger: 'blur' },
{ min: 1, message: '请输入标题', trigger: 'blur' }
],
noticeType: [
{ required: true, message: '请选择消息类型', trigger: 'change' }
]
}
}
},
methods: {
async send(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
if (this.formParams.noticeContent === null) {
this.$message({
message: '请输入内容',
type: 'warning'
})
} else {
this.save()
}
} else {
return false
}
})
},
async save() {
const res = await noticeSave(this.formParams)
if (res.code === '') {
this.$message({
message: '消息发送成功',
type: 'success'
})
this.$refs['formParams'].resetFields()
this.$refs.tinymceContent.setContent('')
}
}
}
}
</script>
<style lang="scss" scoped>
.push{
padding: 0 20px 20px 20px;
min-height: calc(100vh - 50px - 20px);
background-color:#fff;
}
.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>