|
@@ -7,7 +7,7 @@
|
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" :model="form" ref="form" v-loading="formloading" :element-loading-text="loadingText">
|
|
10
|
+ <el-form label-width="80px" class="clearfix" :model="form" ref="form" :element-loading-text="loadingText">
|
11
|
11
|
<el-row>
|
12
|
12
|
<el-col :span="24">
|
13
|
13
|
<el-form-item label="文章标题:">
|
|
@@ -25,7 +25,7 @@
|
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 prop="org_logo">
|
|
28
|
+ <el-form-item prop="org_log">
|
29
|
29
|
<el-col :span="3">
|
30
|
30
|
<div>
|
31
|
31
|
<el-upload
|
|
@@ -45,24 +45,46 @@
|
45
|
45
|
</el-col>
|
46
|
46
|
<el-col :span="3">
|
47
|
47
|
<div v-if="show">
|
48
|
|
- <el-upload
|
49
|
|
- class="avatar-uploader"
|
50
|
|
- :show-file-list="false"
|
51
|
|
- :on-success="handleAvatarSuccess"
|
52
|
|
- :before-upload="beforeAvatarUpload">
|
53
|
|
- <img v-if="imageUrl" :src="imageUrl" class="avatar">
|
|
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">
|
|
59
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
60
|
+ </el-upload>
|
|
61
|
+ </div>
|
|
62
|
+ </el-col>
|
|
63
|
+ <el-col :span="3">
|
|
64
|
+ <div v-if="show">
|
|
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">
|
54
|
76
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
55
|
77
|
</el-upload>
|
56
|
78
|
</div>
|
57
|
79
|
</el-col>
|
58
|
80
|
</el-form-item>
|
59
|
81
|
<el-form-item label="所属分类:">
|
60
|
|
- <el-select v-model="value" placeholder="请先选择文章所属分类">
|
|
82
|
+ <el-select v-model="value" placeholder="请先选择文章所属分类" prop="act_type">
|
61
|
83
|
<el-option
|
62
|
84
|
v-for="item in options"
|
63
|
|
- :key="item.value"
|
64
|
|
- :label="item.label"
|
65
|
|
- :value="item.value">
|
|
85
|
+ :key="item.id"
|
|
86
|
+ :label="item.Name"
|
|
87
|
+ :value="item.id">
|
66
|
88
|
</el-option>
|
67
|
89
|
</el-select>
|
68
|
90
|
</el-form-item>
|
|
@@ -72,7 +94,7 @@
|
72
|
94
|
<el-row :span="24">
|
73
|
95
|
<el-col :span="24">
|
74
|
96
|
<el-form-item>
|
75
|
|
- <el-button size="small" type="primary" style="width: 100px" @click="submitForm">发布</el-button>
|
|
97
|
+ <el-button size="small" type="primary" style="width: 100px" @click="submitForm" :disabled="formsubmit">发布</el-button>
|
76
|
98
|
<el-button size="small" style="width: 100px">预览</el-button>
|
77
|
99
|
<el-button size="small" style="width: 100px">保存草稿</el-button>
|
78
|
100
|
<el-button size="small" style="width: 100px">取消</el-button>
|
|
@@ -90,7 +112,7 @@
|
90
|
112
|
<div class="video-select">
|
91
|
113
|
<el-upload
|
92
|
114
|
class="upload-demo"
|
93
|
|
- action="https://jsonplaceholder.typicode.com/posts/"
|
|
115
|
+ action="https://upload.qiniup.com"
|
94
|
116
|
:on-preview="handlePreview"
|
95
|
117
|
:on-remove="handleRemove"
|
96
|
118
|
:before-remove="beforeRemove"
|
|
@@ -123,12 +145,12 @@
|
123
|
145
|
</el-upload>
|
124
|
146
|
</el-form-item>
|
125
|
147
|
<el-form-item label="所属分类:">
|
126
|
|
- <el-select v-model="value" placeholder="请选择">
|
|
148
|
+ <el-select v-model="form.act_type" placeholder="请选择">
|
127
|
149
|
<el-option
|
128
|
|
- v-for="item in options"
|
129
|
|
- :key="item.value"
|
130
|
|
- :label="item.label"
|
131
|
|
- :value="item.value">
|
|
150
|
+ v-for="item in options"
|
|
151
|
+ :key="item.value"
|
|
152
|
+ :label="item.label"
|
|
153
|
+ :value="item.value">
|
132
|
154
|
</el-option>
|
133
|
155
|
</el-select>
|
134
|
156
|
</el-form-item>
|
|
@@ -158,7 +180,7 @@
|
158
|
180
|
import 'quill/dist/quill.snow.css'
|
159
|
181
|
import 'quill/dist/quill.bubble.css'
|
160
|
182
|
import Neditor from '@/components/Neditor'
|
161
|
|
- import {submitForm} from '@/api/act/submitinfo'
|
|
183
|
+ import {submitForm,getArticleType} from '@/api/act/submitinfo'
|
162
|
184
|
import { getToken } from '@/api/qiniu'
|
163
|
185
|
import { getFileExtension} from '@/utils/tools'
|
164
|
186
|
export default {
|
|
@@ -174,17 +196,7 @@
|
174
|
196
|
{ path: '/articles/createArticle', name: '发布文章' }
|
175
|
197
|
],
|
176
|
198
|
radio:'1',
|
177
|
|
- imageUrl: '',
|
178
|
|
- options: [{
|
179
|
|
- value: '选项1',
|
180
|
|
- label: '科普教育'
|
181
|
|
- }, {
|
182
|
|
- value: '选项2',
|
183
|
|
- label: '肾病常识'
|
184
|
|
- }, {
|
185
|
|
- value: '选项3',
|
186
|
|
- label: '食物库'
|
187
|
|
- }],
|
|
199
|
+ options: [],
|
188
|
200
|
value: '',
|
189
|
201
|
show:false,
|
190
|
202
|
content: '',
|
|
@@ -201,18 +213,43 @@
|
201
|
213
|
act_picture:'',
|
202
|
214
|
act_category:'',
|
203
|
215
|
org_logo:'',
|
|
216
|
+ act_type:'',
|
204
|
217
|
},
|
|
218
|
+ acttypes:[],
|
|
219
|
+ imageUrl:'',
|
|
220
|
+ imageUrlSecond:'',
|
|
221
|
+ imageUrlLast:'',
|
205
|
222
|
formloading:false,
|
|
223
|
+ formsubmit:false,
|
206
|
224
|
qiniuDomain: 'https://images.shengws.com/',
|
207
|
225
|
uploading:false,
|
208
|
226
|
loadingText:'',
|
209
|
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
|
+ },
|
210
|
242
|
}
|
211
|
243
|
},
|
|
244
|
+ created(){
|
|
245
|
+ this.getArticleType()
|
|
246
|
+ },
|
212
|
247
|
methods: {
|
|
248
|
+ //第一个图片
|
213
|
249
|
handleAvatarSuccess(res, file) {
|
214
|
|
- //this.imageUrl = URL.createObjectURL(file.raw);
|
|
250
|
+ this.imageUrl = URL.createObjectURL(file.raw);
|
215
|
251
|
this.form.org_logo = this.qiniuDomain + res.url;
|
|
252
|
+ this.uploading = false
|
216
|
253
|
},
|
217
|
254
|
handleAvatarError(err, file, fileList) {
|
218
|
255
|
this.$message.error(err);
|
|
@@ -240,6 +277,7 @@
|
240
|
277
|
return new Promise((resolve, reject) => {
|
241
|
278
|
getToken().then(response => {
|
242
|
279
|
const token = response.data.data.uptoken
|
|
280
|
+ console.log("token是什么?",token)
|
243
|
281
|
_self._data.uploadData.token = token
|
244
|
282
|
_self._data.uploadData.key = key
|
245
|
283
|
resolve(true)
|
|
@@ -251,6 +289,97 @@
|
251
|
289
|
|
252
|
290
|
//return isJPG && isLt2M;
|
253
|
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
|
|
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
|
+
|
254
|
383
|
beforeUpload(file) {
|
255
|
384
|
var testmsg=file.name.substring(file.name.lastIndexOf('.')+1)
|
256
|
385
|
const extension = testmsg === 'mp4'
|
|
@@ -292,10 +421,13 @@
|
292
|
421
|
var params = new Object()
|
293
|
422
|
params.act_name = this.form.act_name
|
294
|
423
|
params.act_content = this.$refs.neditor.content
|
|
424
|
+ params.org_logo = this.form.org_logo
|
295
|
425
|
this.formloading=true
|
|
426
|
+ this.submitForm =true
|
296
|
427
|
console.log("文章标题",params.act_name)
|
297
|
428
|
console.log("文章内容",params.act_content)
|
298
|
429
|
console.log("富文本编辑器的内容",params.act_content)
|
|
430
|
+ console.log("图片",params.org_logo)
|
299
|
431
|
submitForm(params).then(response => {
|
300
|
432
|
if(response.data.state === 1){
|
301
|
433
|
this.$message({
|
|
@@ -305,7 +437,17 @@
|
305
|
437
|
}
|
306
|
438
|
})
|
307
|
439
|
},
|
308
|
|
-
|
|
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
|
+ }
|
309
|
451
|
},
|
310
|
452
|
}
|
311
|
453
|
</script>
|