|
@@ -1,11 +1,11 @@
|
1
|
1
|
<template>
|
2
|
|
- <el-form ref="form" label-width="160px">
|
3
|
|
- <el-form-item label="所属项目">
|
4
|
|
- <el-select v-model="activityQuery.buildingId" placeholder="请选择">
|
|
2
|
+ <el-form ref="activityQuery" label-width="160px" :rules="rules" :model="activityQuery">
|
|
3
|
+ <el-form-item label="所属项目" prop="buildingId">
|
|
4
|
+ <el-select v-model="activityQuery.buildingId" placeholder="请选择">
|
5
|
5
|
<el-option v-for="(build,i) in buildings.list || []" :key="i" :label="build.buildingName" :value="build.buildingId"></el-option>
|
6
|
6
|
</el-select>
|
7
|
7
|
</el-form-item>
|
8
|
|
- <el-form-item label="主图:">
|
|
8
|
+ <el-form-item label="主图:" prop="buildingId">
|
9
|
9
|
<el-upload
|
10
|
10
|
:headers="uploadHeaders"
|
11
|
11
|
:action="upFileUrl"
|
|
@@ -15,37 +15,39 @@
|
15
|
15
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
16
|
16
|
</el-upload>
|
17
|
17
|
</el-form-item>
|
18
|
|
- <el-form-item label="活动标题">
|
|
18
|
+ <el-form-item label="活动标题" prop="title">
|
19
|
19
|
<el-input v-model="activityQuery.title"></el-input>
|
20
|
20
|
</el-form-item>
|
21
|
|
- <el-form-item label="活动时间">
|
22
|
|
- <el-date-picker v-model="activityQuery.startDate" type="date" placeholder="选择日期"/>
|
|
21
|
+ <el-form-item label="活动时间" prop="startDate">
|
|
22
|
+ <el-date-picker v-model="activityQuery.startDate" type="datetime" placeholder="选择日期"/>
|
23
|
23
|
<span>-</span>
|
24
|
|
- <el-date-picker v-model="activityQuery.endDate" type="date" placeholder="选择日期"/>
|
|
24
|
+ <el-date-picker v-model="activityQuery.endDate" type="datetime" placeholder="选择日期"/>
|
25
|
25
|
</el-form-item>
|
26
|
|
- <el-form-item label="活动地点">
|
|
26
|
+ <el-form-item label="活动地点" prop="address">
|
27
|
27
|
<el-input v-model="activityQuery.address"></el-input>
|
28
|
28
|
</el-form-item>
|
29
|
|
- <el-form-item label="活动人数">
|
30
|
|
- <el-input v-model="activityQuery.personNum"></el-input>
|
|
29
|
+ <el-form-item label="活动人数" prop="personNum">
|
|
30
|
+ <el-input v-model="activityQuery.personNum" type="number"></el-input>
|
31
|
31
|
</el-form-item>
|
32
|
32
|
<!-- <el-form-item label="链接地址">
|
33
|
33
|
<el-input v-model="dynamic.url"></el-input>
|
34
|
34
|
</el-form-item> -->
|
35
|
35
|
<el-form-item label="活动详情">
|
36
|
|
- <div id="websiteEditorElem" style="height: 400px"></div>
|
|
36
|
+ <div id="desc">
|
|
37
|
+ <rich-editor v-model="activityQuery.desc" style="height: 400px"/>
|
|
38
|
+ </div>
|
37
|
39
|
</el-form-item>
|
38
|
40
|
<el-form-item label="是否需要报名">
|
39
|
41
|
<el-radio v-model="activityQuery.isEnlist" label="1">是</el-radio>
|
40
|
42
|
<el-radio v-model="activityQuery.isEnlist" label="0">否</el-radio>
|
41
|
43
|
</el-form-item>
|
42
|
|
- <el-form-item label="活动时间" v-if="activityQuery.isEnlist == '1'">
|
43
|
|
- <el-date-picker v-model="activityQuery.enlistStart" type="date" placeholder="选择日期"/>
|
|
44
|
+ <el-form-item label="报名时间" v-if="activityQuery.isEnlist == '1'" prop="enlistStart">
|
|
45
|
+ <el-date-picker v-model="activityQuery.enlistStart" type="datetime" placeholder="选择日期"/>
|
44
|
46
|
<span>-</span>
|
45
|
|
- <el-date-picker v-model="activityQuery.enlistEnd" type="date" placeholder="选择日期"/>
|
|
47
|
+ <el-date-picker v-model="activityQuery.enlistEnd" type="datetime" placeholder="选择日期"/>
|
46
|
48
|
</el-form-item>
|
47
|
49
|
<el-form-item>
|
48
|
|
- <el-button type="primary" @click="onSubmit">保存</el-button>
|
|
50
|
+ <el-button type="primary" @click="onSubmit('activityQuery')">保存</el-button>
|
49
|
51
|
<el-button @click="onCancel">取消</el-button>
|
50
|
52
|
</el-form-item>
|
51
|
53
|
</el-form>
|
|
@@ -55,7 +57,7 @@
|
55
|
57
|
import { createNamespacedHelpers } from 'vuex'
|
56
|
58
|
import apis from '../../config/api'
|
57
|
59
|
import E from 'wangeditor'
|
58
|
|
-
|
|
60
|
+import dayjs from 'dayjs'
|
59
|
61
|
const { mapState: mapDynamicState, mapActions: mapDynamicActions, mapMutations: mapDynamicMutations } = createNamespacedHelpers('building')
|
60
|
62
|
const { mapState: mapActivityState, mapActions: mapActivityActions } = createNamespacedHelpers('activity')
|
61
|
63
|
const { mapState: mapBuildingState, mapActions: mapBuildingActions } = createNamespacedHelpers('building')
|
|
@@ -74,19 +76,50 @@ export default {
|
74
|
76
|
dialogImageUrl: "",
|
75
|
77
|
activityQuery: {
|
76
|
78
|
dynamicId:'',
|
77
|
|
- buildingId:'',
|
78
|
79
|
url:'',
|
79
|
80
|
startDate:'',
|
80
|
81
|
endDate:'',
|
81
|
82
|
buildingId:'',
|
82
|
83
|
title:'',
|
83
|
84
|
isEnlist:'',
|
84
|
|
- text:'',
|
|
85
|
+ desc:'',
|
85
|
86
|
enlistStart:'',
|
86
|
87
|
enlistEnd:'',
|
87
|
88
|
address:'',
|
88
|
89
|
personNum:''
|
89
|
|
- }
|
|
90
|
+ },
|
|
91
|
+ rules: {
|
|
92
|
+ buildingId: [
|
|
93
|
+ { required: true, message: '请选择活动区域', trigger: 'change' }
|
|
94
|
+ ],
|
|
95
|
+ url: [
|
|
96
|
+ { required: true, message: ' ', trigger: 'change' }
|
|
97
|
+ ],
|
|
98
|
+ title: [
|
|
99
|
+ { required: true, message: '请输入活动标题', trigger: 'blur' },
|
|
100
|
+ ],
|
|
101
|
+ startDate: [
|
|
102
|
+ { required: true, message: '请选择日期', trigger: 'change' }
|
|
103
|
+ ],
|
|
104
|
+ endDate: [
|
|
105
|
+ { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
|
|
106
|
+ ],
|
|
107
|
+ address: [
|
|
108
|
+ { required: true, message: '请输入活动地点', trigger: 'change' }
|
|
109
|
+ ],
|
|
110
|
+ personNum: [
|
|
111
|
+ { required: true, message: '请输入活动人数', trigger: 'change' }
|
|
112
|
+ ],
|
|
113
|
+ desc: [
|
|
114
|
+ { required: true, message: ' ', trigger: 'blur' }
|
|
115
|
+ ],
|
|
116
|
+ // img: [
|
|
117
|
+ // { required: true, message: ' '}
|
|
118
|
+ // ],
|
|
119
|
+ enlistStart:[
|
|
120
|
+ { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
|
|
121
|
+ ]
|
|
122
|
+ }
|
90
|
123
|
|
91
|
124
|
}
|
92
|
125
|
},
|
|
@@ -154,83 +187,72 @@ export default {
|
154
|
187
|
},
|
155
|
188
|
|
156
|
189
|
handleAvatarSuccess (res) {
|
157
|
|
- this.activityQuery.url = res.data
|
158
|
|
- this.updateDetail({...this.dynamic, imgUrl: res.data})
|
159
|
|
- this.loading.close()
|
|
190
|
+ this.imageUrl = res.data
|
160
|
191
|
},
|
161
|
|
- onSubmit () {
|
162
|
|
- // 新增
|
163
|
|
- console.log('this.imgList[0]',this.imgList[0])
|
164
|
|
- // this.activityQuery.url = this.imgList[0]
|
165
|
|
- this.updateActivity(
|
|
192
|
+ onSubmit (formName) {
|
|
193
|
+ this.$refs[formName].validate((valid) => {
|
|
194
|
+ if (valid) {
|
|
195
|
+ // 活动时间校验
|
|
196
|
+ const endDate = this.formateDate(this.activityQuery.endDate);
|
|
197
|
+ const startDate = this.formateDate(this.activityQuery.startDate);
|
|
198
|
+ if( endDate <= startDate){
|
|
199
|
+ this.$message({ showClose: true, message: '活动结束时间不能小于活动开始时间',type: 'error'});
|
|
200
|
+ return
|
|
201
|
+ }
|
|
202
|
+ // 富文本校验
|
|
203
|
+ if( this.activityQuery.desc === '' || this.activityQuery.desc === null|| this.activityQuery.desc ==='<p><br></p>'){
|
|
204
|
+ this.$message({ showClose: true, message: '活动详情不能为空',type: 'error'});
|
|
205
|
+ return
|
|
206
|
+ }
|
|
207
|
+ // 报名时间校验
|
|
208
|
+ const enlistStart = this.formateDate(this.activityQuery.enlistStart);
|
|
209
|
+ const enlistEnd = this.formateDate(this.activityQuery.enlistEnd);
|
|
210
|
+ if(this.activityQuery.isEnlist ==='1' && enlistEnd<= enlistStart ){
|
|
211
|
+ this.$message({ showClose: true, message: '报名结束时间不能小于报名开始时间',type: 'error'});
|
|
212
|
+ return
|
|
213
|
+ }
|
|
214
|
+ this.activityQuery.url = this.imageUrl
|
|
215
|
+ this.updateActivity(
|
166
|
216
|
JSON.stringify(this.activityQuery)
|
167
|
|
- ).then(() => {
|
168
|
|
- this.onCancel()
|
169
|
|
-
|
|
217
|
+ ).then((res) => {
|
|
218
|
+ this.$router.push({ name: "activity-list" });
|
|
219
|
+ })
|
|
220
|
+
|
|
221
|
+ } else {
|
|
222
|
+ console.log('error submit!!');
|
|
223
|
+ return false;
|
|
224
|
+ }
|
170
|
225
|
})
|
171
|
|
- this.$router.push({ name: "activity-list" });
|
172
|
226
|
},
|
173
|
227
|
onCancel () {
|
174
|
|
- this.$router.push({name: 'dynamiclist'})
|
|
228
|
+ this.$router.push({name: 'activity-list'})
|
175
|
229
|
},
|
176
|
230
|
getDetails(){
|
177
|
231
|
this.activityQuery.dynamicId = this.$route.query.row
|
178
|
232
|
this.activityDetails(this.activityQuery).then((data) => {
|
179
|
|
- console.log('55',data)
|
180
|
233
|
this.activityQuery.buildingId = data.buildingId
|
181
|
234
|
this.activityQuery.title = data.title
|
182
|
|
- this.activityQuery.startDate = data.startDate
|
|
235
|
+ this.activityQuery.startDate = data.startDate
|
183
|
236
|
this.activityQuery.endDate = data.endDate
|
184
|
237
|
this.activityQuery.address = data.address
|
185
|
238
|
this.activityQuery.personNum = data.personNum
|
186
|
239
|
this.imageUrl = data.url
|
187
|
240
|
this.activityQuery.isEnlist = data.isEnlist
|
|
241
|
+ this.activityQuery.desc = data.desc
|
188
|
242
|
|
189
|
243
|
|
190
|
244
|
})
|
191
|
|
- }
|
|
245
|
+ },
|
|
246
|
+ formateDate(dt) {
|
|
247
|
+ return !dt ? '' : dayjs(dt).format('YYYY-MM-DD HH:mm')
|
|
248
|
+ },
|
192
|
249
|
},
|
193
|
250
|
mounted () {
|
194
|
|
- const _that = this
|
195
|
|
- const phoneEditor = new E('#websiteEditorElem')
|
196
|
|
- phoneEditor.customConfig.zIndex = 1
|
197
|
|
- phoneEditor.customConfig.onchange = function (html) {
|
198
|
|
- _that.dynamic = {..._that.dynamic, url: html}
|
199
|
|
- _that.activityQuery.text =_that.dynamic.url
|
200
|
|
- }
|
201
|
|
- // phoneEditor.customConfig.uploadImgServer = this.upFileUrl
|
202
|
|
- // phoneEditor.customConfig.uploadFileName = 'uploadFiles'
|
203
|
|
-
|
204
|
|
- phoneEditor.customConfig.customUploadImg = function (files, insert) {
|
205
|
|
- _that.uploadImg(files[0]).then(data => {
|
206
|
|
- insert(data)
|
207
|
|
- })
|
208
|
|
- }
|
209
|
|
- phoneEditor.customConfig.menus = [
|
210
|
|
- 'head', // 标题
|
211
|
|
- 'bold', // 粗体
|
212
|
|
- 'fontSize', // 字号
|
213
|
|
- 'fontName', // 字体
|
214
|
|
- 'italic', // 斜体
|
215
|
|
- 'underline', // 下划线
|
216
|
|
- 'strikeThrough', // 删除线
|
217
|
|
- 'foreColor', // 文字颜色
|
218
|
|
- 'backColor', // 背景颜色
|
219
|
|
- 'justify', // 对齐方式
|
220
|
|
- 'image', // 插入图片
|
221
|
|
- ]
|
222
|
|
- phoneEditor.create()
|
|
251
|
+ // const editor = new E('#desc')
|
|
252
|
+ // editor.customConfig.zIndex = 1
|
|
253
|
+ // editor.create()
|
223
|
254
|
this.getDetails()
|
224
|
|
- this.getBuildings({
|
225
|
|
- pageNum: 1,
|
226
|
|
- pageSize: 100,
|
227
|
|
- }).then(() => {
|
228
|
|
- if ((this.$route.query.id || '') !== '') {
|
229
|
|
- this.getDetail({id: this.$route.query.id}).then((data) => {
|
230
|
|
- phoneEditor.txt.html(data.url)
|
231
|
|
- })
|
232
|
|
- }
|
233
|
|
- })
|
|
255
|
+
|
234
|
256
|
}
|
235
|
257
|
}
|
236
|
258
|
</script>
|