hfxc226 2 gadi atpakaļ
vecāks
revīzija
b164bcc1d7

+ 0 - 1
src/views/operate/article/Article.vue

@@ -104,7 +104,6 @@ export default {
       },
       typeMap: {},
       // 表头
-
       columns: [
         {
           title: '序号',

+ 36 - 3
src/views/operate/article/modules/BaseForm.vue

@@ -17,7 +17,7 @@
         :labelCol="labelCol"
         :wrapperCol="wrapperCol"
       >
-        <a-select v-decorator="['type', {rules: [{required: true, message: '类别不能为空'}]}]" placeholder="请选择">
+        <a-select @change="handleChangeType" v-decorator="['type', {rules: [{required: true, message: '类别不能为空'}]}]" placeholder="请选择">
           <a-select-option
             v-for="(value,key) in typeMap"
             :key="key"
@@ -33,6 +33,21 @@
         <a-input
           v-decorator="['title', {rules: [{required: true, message: '标题不能为空'}]}]" />
       </a-form-item>
+      <a-form-item
+        label="父文章"
+        :labelCol="labelCol"
+        :wrapperCol="wrapperCol"
+        v-show="type==3||type==4||type==5"
+      >
+        <a-select v-decorator="['parentId']" >
+          <a-select-option
+            v-for="({id,title}) in pData"
+            :key="id"
+            :label="title"
+            :value="id">{{ title }}
+          </a-select-option>
+        </a-select>
+      </a-form-item>
       <a-form-item
         label="简介"
         :labelCol="labelCol"
@@ -115,7 +130,7 @@
 
 <script>
 import pick from 'lodash.pick'
-import { addArticle, updateArticle } from '@/api/operate/article'
+import { addArticle, updateArticle, queryArticle } from '@/api/operate/article'
 import WangEditor from '@/components/Editor/WangEditor'
 import UploadImg from '@/components/Upload/UploadImg'
 import UploadArticleFile from '@/components/Upload/UploadArticleFile'
@@ -137,6 +152,7 @@ export default {
         sm: { span: 20 }
       },
       topFlag: 0,
+      pData: [],
       status: 1,
       confirmLoading: false,
       mdl: {},
@@ -145,7 +161,8 @@ export default {
       visible: false,
       content: '',
       picture: '',
-      resultContent: ''
+      resultContent: '',
+      type: null
     }
   },
   props: {
@@ -154,6 +171,11 @@ export default {
       default: () => ({})
     }
   },
+  created () {
+    queryArticle({ type: 2 }).then(res => {
+      this.pData = res.data
+    })
+  },
   methods: {
     base (record) {
       this.visible = true
@@ -165,10 +187,12 @@ export default {
         return
       }
       this.modalTitle = '编辑'
+      this.type = record.type
       const { form: { setFieldsValue } } = this
       this.$nextTick(() => {
         setFieldsValue(Object.assign(pick(record, [
           'id',
+          'parentId',
           'type',
           'title',
           'sort',
@@ -196,6 +220,9 @@ export default {
     catchData (content) {
       this.resultContent = content
     },
+    handleChangeType (value) {
+      this.type = value
+    },
     catchImage (fileList) {
       if (fileList.length !== 0) {
         this.picture = fileList[0].url
@@ -216,6 +243,12 @@ export default {
           status: this.status,
           content: this.resultContent ? this.resultContent : this.content
         }
+        if (this.type === 2) {
+          if (values.parentId == null) {
+            this.$message.error('请选择父文章')
+            return
+          }
+        }
         if (this.BaseTool.String.isBlank(values.id)) {
           addArticle(values)
             .then(() => {