3f535f30
杨鑫
'初始'
|
1
2
|
<template>
<view class="page">
|
b1fef010
杨鑫
'最新代码'
|
3
|
<u-form :model="form" ref="uForm" label-position="left" :label-width="180">
|
e5b57447
杨鑫
'分包问卷'
|
4
|
<view class="add-list" style="padding-bottom: 0;">
|
2210df30
wesley88
1
|
5
|
<u-form-item :required="true" label="封面图片" borderBottom labelPosition="top">
|
b1fef010
杨鑫
'最新代码'
|
6
7
8
|
<!-- <u-upload :action="$upload" :auto-upload="true" ref="uUpload" :max-count="1" ></u-upload> -->
<u-upload :action="$upload" :auto-upload="false" ref="coverImage" :max-count="1" :file-list="fist"
@on-choose-complete="(response, file, fileList) => onsuccess1(response, file, fileList, 'coverImage')"></u-upload>
|
e5b57447
杨鑫
'分包问卷'
|
9
|
</u-form-item>
|
3f535f30
杨鑫
'初始'
|
10
|
</view>
|
e5b57447
杨鑫
'分包问卷'
|
11
|
<view class="add-list" style="padding-bottom: 0;">
|
2210df30
wesley88
1
|
12
|
<u-form-item :required="true" label="活动名称" borderBottom>
|
cb9b8d90
杨鑫
最新1
|
13
|
<u-input v-model="form.activityName" />
|
e5b57447
杨鑫
'分包问卷'
|
14
|
</u-form-item>
|
2210df30
wesley88
1
|
15
|
<u-form-item :required="true" label="开始时间" borderBottom>
|
cb9b8d90
杨鑫
最新1
|
16
|
<u-input v-model="form.startTime" type="select" @click="startShow = true" placeholder="请选择" />
|
e5b57447
杨鑫
'分包问卷'
|
17
18
|
<u-picker mode="time" v-model="startShow" :params="params" @confirm="startTimeChange"></u-picker>
</u-form-item>
|
2210df30
wesley88
1
|
19
|
<u-form-item :required="true" label="结束时间" borderBottom>
|
cb9b8d90
杨鑫
最新1
|
20
|
<u-input v-model="form.endTime" type="select" @click="endShow = true" placeholder="请选择" />
|
e5b57447
杨鑫
'分包问卷'
|
21
22
|
<u-picker mode="time" v-model="endShow" :params="params" @confirm="endTimeChange"></u-picker>
</u-form-item>
|
2210df30
wesley88
1
|
23
|
<u-form-item :required="true" label="活动类型" borderBottom>
|
cb9b8d90
杨鑫
最新1
|
24
|
<u-input v-model="form.activityType" type="select" @click="typeShow = true" placeholder="请选择" />
|
e5b57447
杨鑫
'分包问卷'
|
25
26
|
<u-select v-model="typeShow" :list="typeList" @confirm="typeChange"></u-select>
</u-form-item>
|
2210df30
wesley88
1
|
27
|
<u-form-item :required="true" label="可参与人数" borderBottom>
|
e5b57447
杨鑫
'分包问卷'
|
28
29
|
<u-number-box v-model="form.maxParticipants" :input-width="'100%'" :min="0"></u-number-box>
</u-form-item>
|
2210df30
wesley88
1
|
30
|
<u-form-item :required="true" label="举办区域" borderBottom>
|
e5b57447
杨鑫
'分包问卷'
|
31
32
|
<u-input v-model="form.region" />
</u-form-item>
|
2210df30
wesley88
1
|
33
34
|
<u-form-item :required="true" label="活动内容" borderBottom label-position="top">
<u-input border type="textarea" height="150" v-model="form.content" />
|
e5b57447
杨鑫
'分包问卷'
|
35
|
</u-form-item>
|
3f535f30
杨鑫
'初始'
|
36
|
</view>
|
cb9b8d90
杨鑫
最新1
|
37
|
|
e5b57447
杨鑫
'分包问卷'
|
38
39
|
</u-form>
<u-toast ref="uToast" />
|
3f535f30
杨鑫
'初始'
|
40
|
<!-- 保存按钮 -->
|
e5b57447
杨鑫
'分包问卷'
|
41
|
<view style="height: 120rpx;"></view>
|
3f535f30
杨鑫
'初始'
|
42
|
<view class="page-footer">
|
cb9b8d90
杨鑫
最新1
|
43
|
<u-button style="width: 100%;" type="success" @click="submit">提交</u-button>
|
3f535f30
杨鑫
'初始'
|
44
45
46
47
48
49
50
51
|
</view>
</view>
</template>
<script>
export default {
data() {
return {
|
e5b57447
杨鑫
'分包问卷'
|
52
53
54
|
fileList: [],
form: {
activityName: '',
|
cb9b8d90
杨鑫
最新1
|
55
56
57
58
59
60
61
62
63
64
|
startTime: '',
endTime: '',
activityType: '',
maxParticipants: 0,
region: '',
content: '',
auditStatus: '1',
createUser: '',
createDate: '',
coverImage: '',
|
e5b57447
杨鑫
'分包问卷'
|
65
66
67
68
69
70
71
72
|
},
active: '', // 文件上传地址
startShow: false,
endShow: false,
params: {
year: true,
month: true,
day: true,
|
60e2cd8b
杨鑫
'最新'
|
73
74
75
|
hour: true,
minute: true,
second: true
|
e5b57447
杨鑫
'分包问卷'
|
76
77
|
},
typeShow: false,
|
cb9b8d90
杨鑫
最新1
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
typeList: [{
value: '1',
label: '社交活动'
}, {
value: '2',
label: '营销活动'
}, {
value: '3',
label: '公益活动'
}, {
value: '4',
label: '教育学习活动'
}, {
value: '5',
label: '文化艺术活动'
}],
|
e5b57447
杨鑫
'分包问卷'
|
94
|
readOnly: false,
|
844aa73a
杨鑫
'最新'
|
95
|
formats: {},
|
cb9b8d90
杨鑫
最新1
|
96
97
|
fist: [],
pageIndex: {
|
844aa73a
杨鑫
'最新'
|
98
99
|
pageNumber: 0,
pageSize: 10,
|
cb9b8d90
杨鑫
最新1
|
100
|
id: ''
|
844aa73a
杨鑫
'最新'
|
101
|
},
|
cb9b8d90
杨鑫
最新1
|
102
|
typeEdit: false
|
3f535f30
杨鑫
'初始'
|
103
104
|
};
},
|
844aa73a
杨鑫
'最新'
|
105
|
onLoad(option) {
|
cb9b8d90
杨鑫
最新1
|
106
|
if (option.ids) {
|
844aa73a
杨鑫
'最新'
|
107
|
this.typeEdit = true
|
cb9b8d90
杨鑫
最新1
|
108
109
110
111
112
113
114
|
this.pageIndex.id = option.ids
this.$http.sendRequest('/cereActivityApplication/queryByPage', 'POST', this.pageIndex, 1).then(res => {
this.form = res.data.data.content[0]
this.form.maxParticipants = Number(this.form.maxParticipants)
this.fist.push({
url: `${this.$img+this.form.coverImage}`
})
|
844aa73a
杨鑫
'最新'
|
115
116
117
|
})
}
},
|
cb9b8d90
杨鑫
最新1
|
118
|
methods: {
|
e5b57447
杨鑫
'分包问卷'
|
119
120
121
122
123
124
|
startTimeChange(val) {
this.form.startTime = this.timeChange(val);
this.form.endTime = '';
},
endTimeChange(val) {
const time = this.timeChange(val);
|
cb9b8d90
杨鑫
最新1
|
125
|
if (new Date(time).getTime() > new Date(this.form.startTime).getTime()) {
|
e5b57447
杨鑫
'分包问卷'
|
126
127
128
129
130
131
132
133
134
|
this.form.endTime = time
} else {
this.$refs.uToast.show({
title: '结束时间不能小于开始时间',
type: 'error',
})
}
},
timeChange(val) {
|
cb9b8d90
杨鑫
最新1
|
135
136
137
138
139
140
141
142
|
const {
year,
month,
day,
hour,
minute,
second
} = val;
|
60e2cd8b
杨鑫
'最新'
|
143
|
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
e5b57447
杨鑫
'分包问卷'
|
144
145
146
147
|
},
typeChange(val) {
this.form.activityType = val[0].label;
},
|
cb9b8d90
杨鑫
最新1
|
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
|
check() {
if (!this.form.activityName) {
uni.showToast({
icon: 'none',
title: '请输入活动名称'
});
return false;
}
if (!this.form.startTime) {
uni.showToast({
icon: 'none',
title: '请选择开始时间'
});
return false;
}
if (!this.form.endTime) {
uni.showToast({
icon: 'none',
title: '请选择结束时间'
});
return false;
}
if (!this.form.activityType) {
uni.showToast({
icon: 'none',
title: '请选择活动类型'
});
return false;
}
if (!this.form.maxParticipants) {
uni.showToast({
icon: 'none',
title: '请输入可参与人数'
});
return false;
}
if (!this.form.region) {
uni.showToast({
icon: 'none',
title: '请输入举办区域'
});
return false;
}
if (!this.form.content) {
uni.showToast({
icon: 'none',
title: '请输入活动内容'
});
return false;
}
if (this.form.coverImage == '') {
uni.showToast({
icon: 'none',
title: '请上传封面图片'
});
return false;
}
return true;
|
b1fef010
杨鑫
'最新代码'
|
206
|
},
|
e5b57447
杨鑫
'分包问卷'
|
207
|
submit() {
|
b1fef010
杨鑫
'最新代码'
|
208
|
let show = this.check()
|
cb9b8d90
杨鑫
最新1
|
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
if (show == false) {
return
}
this.form.createUser = uni.getStorageSync('user').phone
this.form.createDate = this.currentTime()
let info = {
...this.form,
coverImage: this.form.coverImage.replace(this.$img, '')
}
if (this.typeEdit) {
this.$http.sendRequest('/cereActivityApplication/edit', 'POST', info, 1).then(res => {
uni.redirectTo({
url: '/pages/mycreated/mycreated'
})
})
} else {
this.$http.sendRequest('/cereActivityApplication/add', 'POST', info, 1).then(res => {
uni.redirectTo({
url: '/pages/mycreated/mycreated'
})
}).catch(err => {
console.log(err)
//请求失败
})
}
},
// 获取时间
currentTime() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1; // 月份从0~11,所以加一
let day = date.getDate();
let hours = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds();
// 为月、日、时、分、秒添加前导零(如果需要)
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
hours = hours < 10 ? '0' + hours : hours;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
// 拼接日期和时间字符串
let strDate = `${year}-${month}-${day} ${hours}:${minutes}`;
return strDate;
},
onsuccess1(e, file, fileList, ziduan) {
uni.uploadFile({
url: this.$upload, // 仅为示例,请替换为您的服务器上传接口
filePath: e[0].url,
name: 'file', // 后端接收的文件参数名
formData: {
filePath: 'xcx', // 其他表单数据
},
success: (uploadFileRes) => {
this.form.coverImage = this.$img + JSON.parse(uploadFileRes.data).data
// let obj ={
// url:this.$img + JSON.parse(uploadFileRes.data).data
// }
// this.fist.push(obj)
uni.showToast({
title: '上传成功',
icon: 'success',
});
},
fail: (err) => {
console.error('上传失败', err);
uni.showToast({
title: '上传失败',
icon: 'none',
});
},
});
},
|
3f535f30
杨鑫
'初始'
|
290
291
292
293
294
295
|
}
}
</script>
<style scoped lang="scss">
@import 'activityAdd.scss';
|
cb9b8d90
杨鑫
最新1
|
296
|
</style>
|