|
@@ -1,26 +1,15 @@
|
|
|
<template>
|
|
|
<div class="createPost-container">
|
|
|
- <el-form ref="postForm" :model="postForm" :rules="rules" class="form-container">
|
|
|
+ <el-form ref="postForm" :label-position="labelPosition" :model="postForm" :rules="rules" class="form-container">
|
|
|
<div class="createPost-main-container">
|
|
|
- <el-row>
|
|
|
- <Warning />
|
|
|
-
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item style="margin-bottom: 40px;" prop="title">
|
|
|
- <MDinput v-model="postForm.title" :maxlength="50" name="name" required>
|
|
|
- 文章标题
|
|
|
- </MDinput>
|
|
|
- </el-form-item>
|
|
|
- <div class="postInfo-container">
|
|
|
- <div style="margin-bottom: 10px;">封面图</div>
|
|
|
- <el-form-item prop="cover_img" style="margin-bottom: 30px;" label="">
|
|
|
- <Upload v-model="postForm.cover_img" />
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-form-item prop="content" style="margin-bottom: 30px;">
|
|
|
- <Tinymce ref="editor" v-model="postForm.content" :height="400" />
|
|
|
+ <el-form-item prop="question" style="" label="问题">
|
|
|
+ <el-input v-model="postForm.question" placeholder="" style="width: 300px;" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="content" style="" label="回答">
|
|
|
+ <Tinymce ref="editor" v-model="postForm.answer" :height="400" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="sort" style="" label="排序">
|
|
|
+ <el-input v-model="postForm.sort" placeholder="" style="width: 100px;" />
|
|
|
</el-form-item>
|
|
|
<el-row>
|
|
|
<el-button v-if="!isEdit" v-loading="loading" type="success" @click="submitForm">
|
|
@@ -37,13 +26,11 @@
|
|
|
|
|
|
<script>
|
|
|
import Tinymce from '@/components/Tinymce'
|
|
|
-import Upload from '@/components/Upload/SingleImage3'
|
|
|
-import MDinput from '@/components/MDinput'
|
|
|
+
|
|
|
// import Sticky from '@/components/Sticky' // 粘性header组件
|
|
|
// import { validURL } from '@/utils/validate'
|
|
|
-import { fetchArticle, createArticle, updateArticle } from '@/api/article'
|
|
|
+import { fetchQuestion, createQuestion, updateQuestion } from '@/api/question'
|
|
|
import { searchUser } from '@/api/remote-search'
|
|
|
-import Warning from './Warning'
|
|
|
// import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from './Dropdown'
|
|
|
|
|
|
const defaultForm = {
|
|
@@ -62,7 +49,7 @@ const defaultForm = {
|
|
|
|
|
|
export default {
|
|
|
name: 'ArticleDetail',
|
|
|
- components: { Tinymce, MDinput, Warning, Upload },
|
|
|
+ components: { Tinymce },
|
|
|
props: {
|
|
|
isEdit: {
|
|
|
type: Boolean,
|
|
@@ -86,11 +73,12 @@ export default {
|
|
|
loading: false,
|
|
|
userListOptions: [],
|
|
|
rules: {
|
|
|
- cover_img: [{ message: '封面图不为空', validator: validateRequire }],
|
|
|
- title: [{ message: '标题不为空', validator: validateRequire }],
|
|
|
- content: [{ message: '内容不为空', validator: validateRequire }]
|
|
|
+ sort: [{ message: '排序不为空', validator: validateRequire }],
|
|
|
+ question: [{ message: '问题不为空', validator: validateRequire }],
|
|
|
+ answer: [{ message: '回答不为空', validator: validateRequire }]
|
|
|
},
|
|
|
- tempRoute: {}
|
|
|
+ tempRoute: {},
|
|
|
+ labelPosition: 'top'
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -122,7 +110,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
fetchData(id) {
|
|
|
- fetchArticle(id).then(response => {
|
|
|
+ fetchQuestion(id).then(response => {
|
|
|
this.postForm = response.data.info
|
|
|
// set tags view title
|
|
|
// this.setTagsViewTitle()
|
|
@@ -141,17 +129,17 @@ export default {
|
|
|
if (valid) {
|
|
|
this.loading = true
|
|
|
console.log(this.postForm)
|
|
|
- createArticle(this.postForm).then(response => {
|
|
|
+ createQuestion(this.postForm).then(response => {
|
|
|
this.$notify({
|
|
|
title: '成功',
|
|
|
- message: '发布文章成功',
|
|
|
+ message: '发布成功',
|
|
|
type: 'success',
|
|
|
duration: 2000
|
|
|
})
|
|
|
this.postForm.status = 'published'
|
|
|
this.loading = false
|
|
|
this.listLoading = false
|
|
|
- this.$router.push(`/article/list`)
|
|
|
+ this.$router.push(`/question/list`)
|
|
|
})
|
|
|
} else {
|
|
|
console.log('error submit!!')
|
|
@@ -161,17 +149,17 @@ export default {
|
|
|
},
|
|
|
updateArticle() {
|
|
|
console.log(this.postForm)
|
|
|
- updateArticle(this.postForm).then(response => {
|
|
|
+ updateQuestion(this.postForm).then(response => {
|
|
|
this.$notify({
|
|
|
title: '修改',
|
|
|
- message: '修改文章成功',
|
|
|
+ message: '修改成功',
|
|
|
type: 'success',
|
|
|
duration: 2000
|
|
|
})
|
|
|
this.postForm.status = 'published'
|
|
|
this.loading = false
|
|
|
this.listLoading = false
|
|
|
- this.$router.push(`/article/list`)
|
|
|
+ this.$router.push(`/question/list`)
|
|
|
})
|
|
|
},
|
|
|
draftForm() {
|