|
@@ -7,17 +7,17 @@
|
7
|
7
|
<div class="app-container">
|
8
|
8
|
<el-tabs type="border-card">
|
9
|
9
|
<el-tab-pane label="文章">
|
10
|
|
- <el-form label-width="80px" class="clearfix">
|
|
10
|
+ <el-form label-width="80px" class="clearfix" :model="form" ref="form" :element-loading-text="loadingText">
|
11
|
11
|
<el-row>
|
12
|
|
- <el-col :span="24">
|
|
12
|
+ <el-col :span="23">
|
13
|
13
|
<el-form-item label="文章标题:">
|
14
|
|
- <el-input placeholder="文章标题"></el-input>
|
|
14
|
+ <el-input v-model="form.act_name" placeholder="文章标题"></el-input>
|
15
|
15
|
</el-form-item>
|
16
|
|
- <el-form-item label="文章内容:" prop="org_introduction">
|
|
16
|
+ <el-form-item label="文章内容:">
|
17
|
17
|
<keep-alive>
|
18
|
18
|
<neditor ref="neditor"
|
19
|
19
|
id="editor"
|
20
|
|
- v-bind:r_content="form.org_introduction">
|
|
20
|
+ v-bind:r_content="form.act_content">
|
21
|
21
|
</neditor>
|
22
|
22
|
</keep-alive>
|
23
|
23
|
</el-form-item>
|
|
@@ -25,39 +25,66 @@
|
25
|
25
|
<el-radio v-model="radio" label="1" @click.native.prevent="select()" >单图</el-radio>
|
26
|
26
|
<el-radio v-model="radio" label="2" @click.native.prevent="clickitem()" >三图</el-radio>
|
27
|
27
|
</el-form-item>
|
28
|
|
- <el-form-item>
|
|
28
|
+ <el-form-item prop="org_log">
|
29
|
29
|
<el-col :span="3">
|
30
|
30
|
<div>
|
31
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
31
|
+ <el-upload
|
|
32
|
+ v-loading="uploading"
|
|
33
|
+ :element-loading-text="loadingText"
|
|
34
|
+ class="avatar-uploader"
|
|
35
|
+ :data="uploadData"
|
|
36
|
+ action="https://upload.qiniup.com"
|
|
37
|
+ :show-file-list="false"
|
|
38
|
+ :on-error="handleAvatarError"
|
|
39
|
+ :on-success="handleAvatarSuccess"
|
|
40
|
+ :before-upload="beforeAvatarUpload">
|
32
|
41
|
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
33
|
42
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
34
|
43
|
</el-upload>
|
35
|
44
|
</div>
|
36
|
45
|
</el-col>
|
37
|
46
|
<el-col :span="3">
|
38
|
|
- <div class="elupload" v-if="show">
|
39
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
40
|
|
- <img v-if="imageUrl" :src="imageUrl" class="avatar">
|
|
47
|
+ <div v-if="show">
|
|
48
|
+ <el-upload
|
|
49
|
+ v-loading="guploading"
|
|
50
|
+ :element-loading-text="loadingText"
|
|
51
|
+ class="avatar-uploader"
|
|
52
|
+ :data="uploadData"
|
|
53
|
+ action="https://upload.qiniup.com"
|
|
54
|
+ :show-file-list="false"
|
|
55
|
+ :on-error="handleAvatartwoError"
|
|
56
|
+ :on-success="handleAvatartwoSuccess"
|
|
57
|
+ :before-upload="beforeAvatartwoUpload">
|
|
58
|
+ <img v-if="imageUrlSecond" :src="imageUrlSecond" class="avatar">
|
41
|
59
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
42
|
60
|
</el-upload>
|
43
|
61
|
</div>
|
44
|
62
|
</el-col>
|
45
|
63
|
<el-col :span="3">
|
46
|
64
|
<div v-if="show">
|
47
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
48
|
|
- <img v-if="imageUrl" :src="imageUrl" class="avatar">
|
|
65
|
+ <el-upload
|
|
66
|
+ v-loading="uploading"
|
|
67
|
+ :element-loading-text="loadingText"
|
|
68
|
+ class="avatar-uploader"
|
|
69
|
+ :data="uploadData"
|
|
70
|
+ action="https://upload.qiniup.com"
|
|
71
|
+ :show-file-list="false"
|
|
72
|
+ :on-error="handleAvatarlastError"
|
|
73
|
+ :on-success="handleAvatarlastSuccess"
|
|
74
|
+ :before-upload="beforeAvatarlastUpload">
|
|
75
|
+ <img v-if="imageUrlLast" :src="imageUrlLast" class="avatar">
|
49
|
76
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
50
|
77
|
</el-upload>
|
51
|
78
|
</div>
|
52
|
79
|
</el-col>
|
53
|
80
|
</el-form-item>
|
54
|
81
|
<el-form-item label="所属分类:">
|
55
|
|
- <el-select v-model="value" placeholder="请先选择文章所属分类">
|
|
82
|
+ <el-select v-model="value" placeholder="请先选择文章所属分类" prop="act_type">
|
56
|
83
|
<el-option
|
57
|
84
|
v-for="item in options"
|
58
|
|
- :key="item.value"
|
59
|
|
- :label="item.label"
|
60
|
|
- :value="item.value">
|
|
85
|
+ :key="item.id"
|
|
86
|
+ :label="item.Name"
|
|
87
|
+ :value="item.id">
|
61
|
88
|
</el-option>
|
62
|
89
|
</el-select>
|
63
|
90
|
</el-form-item>
|
|
@@ -67,7 +94,7 @@
|
67
|
94
|
<el-row :span="24">
|
68
|
95
|
<el-col :span="24">
|
69
|
96
|
<el-form-item>
|
70
|
|
- <el-button size="small" type="primary" style="width: 100px">发布</el-button>
|
|
97
|
+ <el-button size="small" type="primary" style="width: 100px" @click="submitForm" :disabled="formsubmit">发布</el-button>
|
71
|
98
|
<el-button size="small" style="width: 100px">预览</el-button>
|
72
|
99
|
<el-button size="small" style="width: 100px">保存草稿</el-button>
|
73
|
100
|
<el-button size="small" style="width: 100px">取消</el-button>
|
|
@@ -85,7 +112,7 @@
|
85
|
112
|
<div class="video-select">
|
86
|
113
|
<el-upload
|
87
|
114
|
class="upload-demo"
|
88
|
|
- action="https://jsonplaceholder.typicode.com/posts/"
|
|
115
|
+ action="https://upload.qiniup.com"
|
89
|
116
|
:on-preview="handlePreview"
|
90
|
117
|
:on-remove="handleRemove"
|
91
|
118
|
:before-remove="beforeRemove"
|
|
@@ -112,18 +139,18 @@
|
112
|
139
|
</el-form-item>
|
113
|
140
|
<el-form-item label="视频封面:"></el-form-item>
|
114
|
141
|
<el-form-item>
|
115
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
142
|
+ <el-upload class="avatar-uploader" :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
116
|
143
|
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
117
|
144
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
118
|
145
|
</el-upload>
|
119
|
146
|
</el-form-item>
|
120
|
147
|
<el-form-item label="所属分类:">
|
121
|
|
- <el-select v-model="value" placeholder="请选择">
|
|
148
|
+ <el-select v-model="form.act_type" placeholder="请选择">
|
122
|
149
|
<el-option
|
123
|
|
- v-for="item in options"
|
124
|
|
- :key="item.value"
|
125
|
|
- :label="item.label"
|
126
|
|
- :value="item.value">
|
|
150
|
+ v-for="item in options"
|
|
151
|
+ :key="item.value"
|
|
152
|
+ :label="item.label"
|
|
153
|
+ :value="item.value">
|
127
|
154
|
</el-option>
|
128
|
155
|
</el-select>
|
129
|
156
|
</el-form-item>
|
|
@@ -153,6 +180,9 @@
|
153
|
180
|
import 'quill/dist/quill.snow.css'
|
154
|
181
|
import 'quill/dist/quill.bubble.css'
|
155
|
182
|
import Neditor from '@/components/Neditor'
|
|
183
|
+ import {submitForm,getArticleType} from '@/api/act/submitinfo'
|
|
184
|
+ import { getToken } from '@/api/qiniu'
|
|
185
|
+ import { getFileExtension} from '@/utils/tools'
|
156
|
186
|
export default {
|
157
|
187
|
name: 'createArticle',
|
158
|
188
|
components:{
|
|
@@ -166,17 +196,7 @@
|
166
|
196
|
{ path: '/articles/createArticle', name: '发布文章' }
|
167
|
197
|
],
|
168
|
198
|
radio:'1',
|
169
|
|
- imageUrl: '',
|
170
|
|
- options: [{
|
171
|
|
- value: '选项1',
|
172
|
|
- label: '科普教育'
|
173
|
|
- }, {
|
174
|
|
- value: '选项2',
|
175
|
|
- label: '肾病常识'
|
176
|
|
- }, {
|
177
|
|
- value: '选项3',
|
178
|
|
- label: '食物库'
|
179
|
|
- }],
|
|
199
|
+ options: [],
|
180
|
200
|
value: '',
|
181
|
201
|
show:false,
|
182
|
202
|
content: '',
|
|
@@ -188,13 +208,53 @@
|
188
|
208
|
company:"",
|
189
|
209
|
fileList: [{name: '123', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],
|
190
|
210
|
form:{
|
191
|
|
- org_introduction:'',
|
192
|
|
- }
|
|
211
|
+ act_name:'',
|
|
212
|
+ act_content:'',
|
|
213
|
+ act_picture:'',
|
|
214
|
+ act_category:'',
|
|
215
|
+ org_logo:'',
|
|
216
|
+ act_type:'',
|
|
217
|
+ },
|
|
218
|
+ acttypes:[],
|
|
219
|
+ imageUrl:'',
|
|
220
|
+ imageUrlSecond:'',
|
|
221
|
+ imageUrlLast:'',
|
|
222
|
+ formloading:false,
|
|
223
|
+ formsubmit:false,
|
|
224
|
+ qiniuDomain: 'https://images.shengws.com/',
|
|
225
|
+ uploading:false,
|
|
226
|
+ loadingText:'',
|
|
227
|
+ uploadData: { token: '', key: '' },
|
|
228
|
+ myConfig: {
|
|
229
|
+ // 如果需要上传功能,找后端小伙伴要服务器接口地址
|
|
230
|
+ serverUrl: '/api/web/upload/ueditor',
|
|
231
|
+ // 你的UEditor资源存放的路径,相对于打包后的index.html
|
|
232
|
+ UEDITOR_HOME_URL: '/NEditor/',
|
|
233
|
+ // 编辑器不自动被内容撑高
|
|
234
|
+ autoHeightEnabled: false,
|
|
235
|
+ // 初始容器高度
|
|
236
|
+ initialFrameHeight: 240,
|
|
237
|
+ // 初始容器宽度
|
|
238
|
+ initialFrameWidth: '100%',
|
|
239
|
+ // 关闭自动保存
|
|
240
|
+ enableAutoSave: false
|
|
241
|
+ },
|
193
|
242
|
}
|
194
|
243
|
},
|
|
244
|
+ created(){
|
|
245
|
+ this.getArticleType()
|
|
246
|
+ },
|
195
|
247
|
methods: {
|
|
248
|
+ //第一个图片
|
196
|
249
|
handleAvatarSuccess(res, file) {
|
197
|
250
|
this.imageUrl = URL.createObjectURL(file.raw);
|
|
251
|
+ this.form.org_logo = this.qiniuDomain + res.url;
|
|
252
|
+ this.uploading = false
|
|
253
|
+ },
|
|
254
|
+ handleAvatarError(err, file, fileList) {
|
|
255
|
+ this.$message.error(err);
|
|
256
|
+ this.uploading = false;
|
|
257
|
+ return false
|
198
|
258
|
},
|
199
|
259
|
beforeAvatarUpload(file) {
|
200
|
260
|
const isJPG = file.type === 'image/jpeg';
|
|
@@ -206,8 +266,120 @@
|
206
|
266
|
if (!isLt2M) {
|
207
|
267
|
this.$message.error('上传头像图片大小不能超过 2MB!');
|
208
|
268
|
}
|
209
|
|
- return isJPG && isLt2M;
|
|
269
|
+
|
|
270
|
+ var date = new Date()
|
|
271
|
+ var ext = getFileExtension(file.name)
|
|
272
|
+ var key = date.getFullYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() +'_o_' + file.uid + '.' + ext;
|
|
273
|
+ this.uploading = true;
|
|
274
|
+ this.loadingText = '封面图片上传中'
|
|
275
|
+
|
|
276
|
+ const _self = this
|
|
277
|
+ return new Promise((resolve, reject) => {
|
|
278
|
+ getToken().then(response => {
|
|
279
|
+ const token = response.data.data.uptoken
|
|
280
|
+ console.log("token是什么?",token)
|
|
281
|
+ _self._data.uploadData.token = token
|
|
282
|
+ _self._data.uploadData.key = key
|
|
283
|
+ resolve(true)
|
|
284
|
+ }).catch(err => {
|
|
285
|
+ reject(false)
|
|
286
|
+ this.uploading = false;
|
|
287
|
+ })
|
|
288
|
+ })
|
|
289
|
+
|
|
290
|
+ //return isJPG && isLt2M;
|
|
291
|
+ },
|
|
292
|
+ //第二个图片
|
|
293
|
+ handleAvatartwoSuccess(res, file) {
|
|
294
|
+ this.imageUrlSecond = URL.createObjectURL(file.raw);
|
|
295
|
+ this.form.org_logo = this.qiniuDomain + res.url;
|
|
296
|
+ this.uploading = false
|
|
297
|
+ },
|
|
298
|
+ handleAvatartwoError(err, file, fileList) {
|
|
299
|
+ this.$message.error(err);
|
|
300
|
+ this.uploading = false;
|
|
301
|
+ return false
|
|
302
|
+ },
|
|
303
|
+ beforeAvatartwoUpload(file) {
|
|
304
|
+ const isJPG = file.type === 'image/jpeg';
|
|
305
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
306
|
+
|
|
307
|
+ if (!isJPG) {
|
|
308
|
+ this.$message.error('上传头像图片只能是 JPG 格式!');
|
|
309
|
+ }
|
|
310
|
+ if (!isLt2M) {
|
|
311
|
+ this.$message.error('上传头像图片大小不能超过 2MB!');
|
|
312
|
+ }
|
|
313
|
+
|
|
314
|
+ var date = new Date()
|
|
315
|
+ var ext = getFileExtension(file.name)
|
|
316
|
+ var key = date.getFullYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() +'_o_' + file.uid + '.' + ext;
|
|
317
|
+ this.uploading = true;
|
|
318
|
+ this.loadingText = '封面图片上传中'
|
|
319
|
+
|
|
320
|
+ const _self = this
|
|
321
|
+ return new Promise((resolve, reject) => {
|
|
322
|
+ getToken().then(response => {
|
|
323
|
+ const token = response.data.data.uptoken
|
|
324
|
+ console.log("token是什么?",token)
|
|
325
|
+ _self._data.uploadData.token = token
|
|
326
|
+ _self._data.uploadData.key = key
|
|
327
|
+ resolve(true)
|
|
328
|
+ }).catch(err => {
|
|
329
|
+ reject(false)
|
|
330
|
+ this.uploading = false;
|
|
331
|
+ })
|
|
332
|
+ })
|
|
333
|
+
|
|
334
|
+ //return isJPG && isLt2M;
|
|
335
|
+ },
|
|
336
|
+
|
|
337
|
+ //第三张图片
|
|
338
|
+ //第二个图片
|
|
339
|
+ handleAvatarlastSuccess(res, file) {
|
|
340
|
+ this.imageUrlLast = URL.createObjectURL(file.raw);
|
|
341
|
+ this.form.org_logo = this.qiniuDomain + res.url;
|
|
342
|
+ this.uploading = false
|
|
343
|
+ },
|
|
344
|
+ handleAvatarlastError(err, file, fileList) {
|
|
345
|
+ this.$message.error(err);
|
|
346
|
+ this.uploading = false;
|
|
347
|
+ return false
|
210
|
348
|
},
|
|
349
|
+ beforeAvatarlastUpload(file) {
|
|
350
|
+ const isJPG = file.type === 'image/jpeg';
|
|
351
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
352
|
+
|
|
353
|
+ if (!isJPG) {
|
|
354
|
+ this.$message.error('上传头像图片只能是 JPG 格式!');
|
|
355
|
+ }
|
|
356
|
+ if (!isLt2M) {
|
|
357
|
+ this.$message.error('上传头像图片大小不能超过 2MB!');
|
|
358
|
+ }
|
|
359
|
+
|
|
360
|
+ var date = new Date()
|
|
361
|
+ var ext = getFileExtension(file.name)
|
|
362
|
+ var key = date.getFullYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() +'_o_' + file.uid + '.' + ext;
|
|
363
|
+ this.uploading = true;
|
|
364
|
+ this.loadingText = '封面图片上传中'
|
|
365
|
+
|
|
366
|
+ const _self = this
|
|
367
|
+ return new Promise((resolve, reject) => {
|
|
368
|
+ getToken().then(response => {
|
|
369
|
+ const token = response.data.data.uptoken
|
|
370
|
+ console.log("token是什么?",token)
|
|
371
|
+ _self._data.uploadData.token = token
|
|
372
|
+ _self._data.uploadData.key = key
|
|
373
|
+ resolve(true)
|
|
374
|
+ }).catch(err => {
|
|
375
|
+ reject(false)
|
|
376
|
+ this.uploading = false;
|
|
377
|
+ })
|
|
378
|
+ })
|
|
379
|
+
|
|
380
|
+ //return isJPG && isLt2M;
|
|
381
|
+ },
|
|
382
|
+
|
211
|
383
|
beforeUpload(file) {
|
212
|
384
|
var testmsg=file.name.substring(file.name.lastIndexOf('.')+1)
|
213
|
385
|
const extension = testmsg === 'mp4'
|
|
@@ -245,7 +417,37 @@
|
245
|
417
|
beforeRemove(file, fileList) {
|
246
|
418
|
return this.$confirm(`确定移除 ${ file.name }?`);
|
247
|
419
|
},
|
248
|
|
-
|
|
420
|
+ submitForm(){
|
|
421
|
+ var params = new Object()
|
|
422
|
+ params.act_name = this.form.act_name
|
|
423
|
+ params.act_content = this.$refs.neditor.content
|
|
424
|
+ params.org_logo = this.form.org_logo
|
|
425
|
+ this.formloading=true
|
|
426
|
+ this.submitForm =true
|
|
427
|
+ console.log("文章标题",params.act_name)
|
|
428
|
+ console.log("文章内容",params.act_content)
|
|
429
|
+ console.log("富文本编辑器的内容",params.act_content)
|
|
430
|
+ console.log("图片",params.org_logo)
|
|
431
|
+ submitForm(params).then(response => {
|
|
432
|
+ if(response.data.state === 1){
|
|
433
|
+ this.$message({
|
|
434
|
+ type: 'success',
|
|
435
|
+ message: '成功!'
|
|
436
|
+ })
|
|
437
|
+ }
|
|
438
|
+ })
|
|
439
|
+ },
|
|
440
|
+ getArticleType(){
|
|
441
|
+ getArticleType().then(response =>{
|
|
442
|
+ console.log("好嗨我")
|
|
443
|
+ if(response.data.state === 1){
|
|
444
|
+ var category = response.data.data.category
|
|
445
|
+ this.options = response.data.data.category
|
|
446
|
+ console.log("文章内容:",category)
|
|
447
|
+ console.log("文章",this.options)
|
|
448
|
+ }
|
|
449
|
+ })
|
|
450
|
+ }
|
249
|
451
|
},
|
250
|
452
|
}
|
251
|
453
|
</script>
|